diff options
author | Francis Irving <francis@mysociety.org> | 2010-09-29 09:59:37 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-09-29 09:59:37 +0100 |
commit | e1bd825b316db54aef5c35bcf8ec9afa6ea2f49e (patch) | |
tree | 66a462563245c467f07d1fefb9eda650c1c7c022 | |
parent | 2959490347b95295b85b2037dc4de812e6210740 (diff) |
Tags for requests, with admin interface to view/edit them.
-rw-r--r-- | app/controllers/admin_request_controller.rb | 5 | ||||
-rw-r--r-- | app/models/info_request.rb | 2 | ||||
-rw-r--r-- | app/views/admin_request/_tags.rhtml | 8 | ||||
-rw-r--r-- | app/views/admin_request/edit.rhtml | 3 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 1 | ||||
-rw-r--r-- | db/migrate/094_remove_old_tags_foreign_key.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 6 | ||||
-rw-r--r-- | todo.txt | 3 |
8 files changed, 41 insertions, 4 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 7e6c365c1..d5bd4c4d6 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -46,6 +46,7 @@ class AdminRequestController < AdminController old_awaiting_description = @info_request.awaiting_description old_allow_new_responses_from = @info_request.allow_new_responses_from old_handle_rejected_responses = @info_request.handle_rejected_responses + old_tag_string = @info_request.tag_string @info_request.title = params[:info_request][:title] @info_request.prominence = params[:info_request][:prominence] @@ -55,6 +56,7 @@ class AdminRequestController < AdminController @info_request.awaiting_description = params[:info_request][:awaiting_description] == "true" ? true : false @info_request.allow_new_responses_from = params[:info_request][:allow_new_responses_from] @info_request.handle_rejected_responses = params[:info_request][:handle_rejected_responses] + @info_request.tag_string = params[:info_request][:tag_string] if @info_request.valid? @info_request.save! @@ -65,7 +67,8 @@ class AdminRequestController < AdminController :old_described_state => old_described_state, :described_state => @info_request.described_state, :old_awaiting_description => old_awaiting_description, :awaiting_description => @info_request.awaiting_description, :old_allow_new_responses_from => old_allow_new_responses_from, :allow_new_responses_from => @info_request.allow_new_responses_from, - :old_handle_rejected_responses => old_handle_rejected_responses, :handle_rejected_responses => @info_request.handle_rejected_responses + :old_handle_rejected_responses => old_handle_rejected_responses, :handle_rejected_responses => @info_request.handle_rejected_responses, + :old_tag_string => old_tag_string, :tag_string => @info_request.tag_string }) flash[:notice] = 'Request successfully updated.' redirect_to request_admin_url(@info_request) diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 4f997baa6..3f5224907 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -50,6 +50,8 @@ class InfoRequest < ActiveRecord::Base has_many :censor_rules, :order => 'created_at desc' has_many :exim_logs, :order => 'exim_log_done_id' + has_tag_string + # user described state (also update in info_request_event, admin_request/edit.rhtml) validates_inclusion_of :described_state, :in => [ 'waiting_response', diff --git a/app/views/admin_request/_tags.rhtml b/app/views/admin_request/_tags.rhtml new file mode 100644 index 000000000..22fbf13c8 --- /dev/null +++ b/app/views/admin_request/_tags.rhtml @@ -0,0 +1,8 @@ +<% for t in info_request.tags %> + <% if t.value %> + <%=h t.name %>:<%=h t.value %> + <% else %> + <%=h t.name %> + <% end %> +<% end %> + diff --git a/app/views/admin_request/edit.rhtml b/app/views/admin_request/edit.rhtml index 1bfe4cb90..b659c676d 100644 --- a/app/views/admin_request/edit.rhtml +++ b/app/views/admin_request/edit.rhtml @@ -41,6 +41,9 @@ <br/>(don't forget to change 'awaiting description' when you set described state)<br/> </p> + <p><label for="info_request_tag_string"><strong>Tags</strong> <small>(space separated, can use key:value)</small></label><br/> + <%= text_field 'info_request', 'tag_string', :size => 60 %></p> + <p><%= submit_tag 'Save changes', :accesskey => 's' %> </p> diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index 279d09295..aac68ad2e 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -43,6 +43,7 @@ </span> <br> <strong>Incoming email address:</strong> <%= link_to h(@info_request.incoming_email), "mailto:" + @info_request.incoming_email %> <br> +<b>Tags:</b> <%= render :partial => 'tags', :locals => { :info_request => @info_request} %> <br> </p> <% end %> diff --git a/db/migrate/094_remove_old_tags_foreign_key.rb b/db/migrate/094_remove_old_tags_foreign_key.rb new file mode 100644 index 000000000..1a87b97c2 --- /dev/null +++ b/db/migrate/094_remove_old_tags_foreign_key.rb @@ -0,0 +1,17 @@ +class RemoveOldTagsForeignKey < ActiveRecord::Migration + def self.up + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE has_tag_string_tags DROP CONSTRAINT fk_public_body_tags_public_body" + end + + remove_index :public_body_tags, [:public_body_id, :name, :value] + remove_index :public_body_tags, :name + + add_index :has_tag_string_tags, [:model, :model_id, :name, :value] + add_index :has_tag_string_tags, :name + end + + def self.down + raise "no reverse migration" + end +end diff --git a/db/schema.rb b/db/schema.rb index 6df97a137..cf117c4e3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 93) do +ActiveRecord::Schema.define(:version => 94) do create_table "acts_as_xapian_jobs", :force => true do |t| t.string "model", :null => false @@ -73,9 +73,9 @@ ActiveRecord::Schema.define(:version => 93) do t.string "model", :null => false end + add_index "has_tag_string_tags", ["model", "model_id", "name", "value"], :name => "index_has_tag_string_tags_on_model_and_model_id_and_name_and_va" add_index "has_tag_string_tags", ["model", "model_id"], :name => "index_has_tag_string_tags_on_model_and_model_id" - add_index "has_tag_string_tags", ["model_id", "name", "value"], :name => "index_public_body_tags_on_public_body_id_and_name_and_value", :unique => true - add_index "has_tag_string_tags", ["name"], :name => "index_public_body_tags_on_name" + add_index "has_tag_string_tags", ["name"], :name => "index_has_tag_string_tags_on_name" create_table "holidays", :force => true do |t| t.date "day" @@ -1,3 +1,6 @@ +destroy request + + Next (things that will reduce admin time mainly) ==== |