Improve reporting of errors in GPX uploads, and allow private traces
to be uploaded once again.
This commit is contained in:
parent
2afcb4b222
commit
bd5793f7a6
3 changed files with 22 additions and 7 deletions
|
@ -115,10 +115,6 @@ class TraceController < ApplicationController
|
|||
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
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
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
|
||||
|
@ -15,6 +15,10 @@ class Trace < ActiveRecord::Base
|
|||
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
|
||||
|
|
15
app/views/trace/create.rhtml
Normal file
15
app/views/trace/create.rhtml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<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 %>
|
Loading…
Add table
Add a link
Reference in a new issue