add tags to gpx files

This commit is contained in:
Steve Coast 2006-12-06 17:10:59 +00:00
parent 93dab8a127
commit a7e3b58b41
8 changed files with 41 additions and 7 deletions

View file

@ -3,7 +3,7 @@ class TraceController < ApplicationController
layout 'site'
def list
@traces = Trace.find(:all)
@traces = Trace.find(:all, :conditions => ['public = true'])
end
def mine
@ -12,7 +12,11 @@ class TraceController < ApplicationController
def view
@trace = Trace.find(params[:id])
render :nothing, :status => 401 if @trace.user.id != @user.id
unless @trace.public
if @user
render :nothing, :status => 401 if @trace.user.id != @user.id
end
end
end
def create

View file

@ -0,0 +1,2 @@
class TracetagController < ApplicationController
end

View file

@ -0,0 +1,2 @@
module TracetagHelper
end

View file

@ -2,10 +2,13 @@ class Trace < ActiveRecord::Base
set_table_name 'gpx_files'
belongs_to :user
has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id'
def tags=(bleh)
end
def mime_type=(bleh)
def tagstring=(s)
self.tags = s.split().collect {|tag|
tt = Tracetag.new
tt.tag = tag
tt
}
end
end

6
app/models/tracetag.rb Normal file
View file

@ -0,0 +1,6 @@
class Tracetag < ActiveRecord::Base
set_table_name 'gpx_file_tags'
belongs_to :trace, :foreign_key => 'gpx_id'
end

View file

@ -8,7 +8,7 @@
<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', 'tags', {: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', {:checked => 'checked'}) %></td></tr>
<tr><td></td><td>
<%= submit_tag 'Upload' %> | <a href="http://wiki.openstreetmap.org/index.php/Upload">help</a>