add tags to gpx files
This commit is contained in:
parent
93dab8a127
commit
a7e3b58b41
8 changed files with 41 additions and 7 deletions
|
@ -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,8 +12,12 @@ class TraceController < ApplicationController
|
|||
|
||||
def view
|
||||
@trace = Trace.find(params[:id])
|
||||
unless @trace.public
|
||||
if @user
|
||||
render :nothing, :status => 401 if @trace.user.id != @user.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
filename = "/tmp/#{rand}"
|
||||
|
|
2
app/controllers/tracetag_controller.rb
Normal file
2
app/controllers/tracetag_controller.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class TracetagController < ApplicationController
|
||||
end
|
2
app/helpers/tracetag_helper.rb
Normal file
2
app/helpers/tracetag_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module TracetagHelper
|
||||
end
|
|
@ -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
6
app/models/tracetag.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class Tracetag < ActiveRecord::Base
|
||||
set_table_name 'gpx_file_tags'
|
||||
|
||||
belongs_to :trace, :foreign_key => 'gpx_id'
|
||||
|
||||
end
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
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);
|
||||
|
||||
|
|
11
db/migrate/016_create_tracetags.rb
Normal file
11
db/migrate/016_create_tracetags.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue