From: Tom Hughes Date: Sun, 23 Sep 2007 17:05:31 +0000 (+0000) Subject: Allow trace descriptions and tags to be edited. X-Git-Tag: live~8094 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/868ce8d467210564211f6ed68f5f40fdd444ded5?ds=sidebyside Allow trace descriptions and tags to be edited. --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 3b3097755..3eb7f5c7e 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -120,6 +120,24 @@ class TraceController < ApplicationController render :nothing => true, :status => :not_found end + def edit + @trace = Trace.find(params[:id]) + + if @user and @trace.user == @user + if params[:trace] + @trace.description = params[:trace][:description] + @trace.tagstring = params[:trace][:tagstring] + if @trace.save + redirect_to :action => 'view' + end + end + else + render :nothing, :status => :forbidden + end + rescue ActiveRecord::RecordNotFound + render :nothing => true, :status => :not_found + end + def delete trace = Trace.find(params[:id]) diff --git a/app/views/trace/edit.rhtml b/app/views/trace/edit.rhtml new file mode 100644 index 000000000..22405c1fc --- /dev/null +++ b/app/views/trace/edit.rhtml @@ -0,0 +1,43 @@ +

<%= @title %>

+ + + +<% form_for :trace, @trace do |f| %> + + + + + + + + + + + <% if @trace.inserted? %> + + + + + + + + <% end %> + + + + + + + + + + + + +
Filename:<%= @trace.name %> (<%= link_to 'download', :controller => 'trace', :action => 'data', :id => @trace.id %>)
Uploaded at:<%= @trace.timestamp %>
Points:<%= @trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %>
Start coordinate:
<%= @trace.latitude %>; <%= @trace.longitude %>
(<%=link_to 'map', :controller => 'site', :action => 'index', :lat => @trace.latitude, :lon => @trace.longitude, :zoom => 14 %> / <%=link_to 'edit', :controller => 'site', :action => 'edit', :lat => @trace.latitude, :lon => @trace.longitude, :gpx=> @trace.id, :zoom => 14 %>)
Owner:<%= link_to @trace.user.display_name, {:controller => 'user', :action => 'view', :display_name => @trace.user.display_name} %>
Description:<%= f.text_field :description %>
Tags:<%= f.text_field :tagstring %>
+ +

+ +<%= submit_tag 'Save Changes' %> + +<% end %> diff --git a/app/views/trace/view.rhtml b/app/views/trace/view.rhtml index 60f71b7c7..a5b0cef09 100644 --- a/app/views/trace/view.rhtml +++ b/app/views/trace/view.rhtml @@ -50,6 +50,9 @@ <%= button_to 'Make this track public permanently', :controller => 'trace', :action => 'make_public', :id => @trace.id %> <% end %> <% if @trace.user.id == @user.id %> + <%= button_to 'Edit this track', :controller => 'trace', :action => 'edit', :id => @trace.id %> + <% end %> + <% if @trace.user.id == @user.id %> <%= button_to 'Delete this track', :controller => 'trace', :action => 'delete', :id => @trace.id %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index b9d5d41c9..0cbdd36a4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,6 +75,7 @@ ActionController::Routing::Routes.draw do |map| map.connect '/traces/mine/tag/:tag', :controller => 'trace', :action => 'mine' map.connect '/traces/mine/tag/:tag/page/:page', :controller => 'trace', :action => 'mine' map.connect '/trace/create', :controller => 'trace', :action => 'create' + map.connect '/trace/:id/edit', :controller => 'trace', :action => 'edit' map.connect '/trace/:id/delete', :controller => 'trace', :action => 'delete' map.connect '/trace/:id/make_public', :controller => 'trace', :action => 'make_public' map.connect '/user/:display_name/traces', :controller => 'trace', :action => 'list'