to be uploaded once again.
before_filter :authorize_web
before_filter :authorize, :only => [:api_details, :api_data, :api_create]
layout 'site'
-
+
# Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
# target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces
# paging_action - the action that will be linked back to from view
logger.info("id is #{@trace.id}")
flash[:notice] = "Your GPX file has been uploaded and is awaiting insertion in to the database. This will usually happen within half an hour, and an email will be sent to you on completion."
redirect_to :action => 'mine'
- else
- # fixme throw an error here
- redirect_to :action => 'mine'
- flash[:notice] = "You haven't entered a tag or a description for yoru traces."
end
end
class Trace < ActiveRecord::Base
set_table_name 'gpx_files'
- validates_presence_of :user_id, :name, :public, :timestamp
+ validates_presence_of :user_id, :name, :timestamp
validates_presence_of :description, :on => :create
# validates_numericality_of :latitude, :longitude
- validates_inclusion_of :inserted, :in => [ true, false]
+ validates_inclusion_of :public, :inserted, :in => [ true, false]
belongs_to :user
has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id', :dependent => :delete_all
FileUtils.rm_f(trace_name, icon_picture_name, large_picture_name)
end
+ def tagstring
+ return tags.collect {|tt| tt.tag}.join(" ")
+ end
+
def tagstring=(s)
self.tags = s.split().collect {|tag|
tt = Tracetag.new
--- /dev/null
+<h1>Upload GPS Trace</h1>
+
+<%= error_messages_for 'trace' %>
+
+<% form_tag({:action => 'create'}, :multipart => true) do %>
+<table>
+<tr><td align="right">Upload GPX File</td><td><%= file_field('trace', 'gpx_file', {:size => 50, :maxlength => 255}) %></td></tr>
+<tr><td align="right">Description</td><td><%= text_field('trace', 'description', {:size => 50, :maxlength => 255}) %></td></tr>
+<tr><td align="right">Tags</td><td><%= text_field('trace', 'tagstring', {:size => 50, :maxlength => 255}) %></td></tr>
+<tr><td align="right">Public?</td><td><%= check_box('trace', 'public') %></td></tr>
+<tr><td></td><td>
+<%= submit_tag 'Upload' %> | <a href="http://wiki.openstreetmap.org/index.php/Upload">help</a>
+</td></tr>
+</table>
+<% end %>