layout 'site'
def list
- @traces = Trace.find(:all)
+ @traces = Trace.find(:all, :conditions => ['public = true'])
end
def mine
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
--- /dev/null
+class TracetagController < ApplicationController
+end
--- /dev/null
+module TracetagHelper
+end
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
--- /dev/null
+class Tracetag < ActiveRecord::Base
+ set_table_name 'gpx_file_tags'
+
+ belongs_to :trace, :foreign_key => 'gpx_id'
+
+end
<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>
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);
+
--- /dev/null
+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