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' layout 'site'
def list def list
@traces = Trace.find(:all) @traces = Trace.find(:all, :conditions => ['public = true'])
end end
def mine def mine
@ -12,7 +12,11 @@ class TraceController < ApplicationController
def view def view
@trace = Trace.find(params[:id]) @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 end
def create 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' set_table_name 'gpx_files'
belongs_to :user belongs_to :user
has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id'
def tags=(bleh) def tagstring=(s)
end self.tags = s.split().collect {|tag|
tt = Tracetag.new
def mime_type=(bleh) tt.tag = tag
tt
}
end end
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> <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">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">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 align="right">public?</td><td><%= check_box('trace', 'public', {:checked => 'checked'}) %></td></tr>
<tr><td></td><td> <tr><td></td><td>
<%= submit_tag 'Upload' %> | <a href="http://wiki.openstreetmap.org/index.php/Upload">help</a> <%= submit_tag 'Upload' %> | <a href="http://wiki.openstreetmap.org/index.php/Upload">help</a>

View file

@ -18,3 +18,9 @@ alter table current_way_tags change v v varchar(255) not null default '';
alter table gpx_files change private public boolean default 1 not null; alter table gpx_files change private public boolean default 1 not null;
update gpx_files set public = !public; update gpx_files set public = !public;
alter table gpx_file_tags change sequence_id sequence_id int(11);
alter table gpx_file_tags drop primary key;
alter table gpx_file_tags drop column sequence_id;
create index gpx_file_tags_gpxid_idx on gpx_file_tags(gpx_id);
alter table gpx_file_tags add id int(20) auto_increment not null, add primary key(id);

View file

@ -0,0 +1,11 @@
class CreateTracetags < ActiveRecord::Migration
def self.up
create_table :tracetags do |t|
# t.column :name, :string
end
end
def self.down
drop_table :tracetags
end
end