diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin_request_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 18 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 2 |
3 files changed, 16 insertions, 9 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/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 5f51948ee..560206900 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -65,24 +65,28 @@ class PublicBodyController < ApplicationController end def list + # XXX move some of these tag SQL queries into has_tag_string.rb @tag = params[:tag] if @tag.nil? @tag = "all" conditions = [] elsif @tag == 'other' category_list = PublicBodyCategories::CATEGORIES.map{|c| "'"+c+"'"}.join(",") - conditions = ['(select count(*) from public_body_tags where public_body_tags.public_body_id = public_bodies.id - and public_body_tags.name in (' + category_list + ')) = 0'] + conditions = ['(select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id + and has_tag_string_tags.model = \'PublicBody\' + and has_tag_string_tags.name in (' + category_list + ')) = 0'] elsif @tag.size == 1 @tag.upcase! conditions = ['first_letter = ?', @tag] elsif @tag.include?(":") - name, value = PublicBodyTag.split_tag_into_name_value(@tag) - conditions = ['(select count(*) from public_body_tags where public_body_tags.public_body_id = public_bodies.id - and public_body_tags.name = ? and public_body_tags.value = ?) > 0', name, value] + name, value = HasTagString::HasTagStringTag.split_tag_into_name_value(@tag) + conditions = ['(select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id + and has_tag_string_tags.model = \'PublicBody\' + and has_tag_string_tags.name = ? and has_tag_string_tags.value = ?) > 0', name, value] else - conditions = ['(select count(*) from public_body_tags where public_body_tags.public_body_id = public_bodies.id - and public_body_tags.name = ?) > 0', @tag] + conditions = ['(select count(*) from has_tag_string_tags where has_tag_string_tags.model_id = public_bodies.id + and has_tag_string_tags.model = \'PublicBody\' + and has_tag_string_tags.name = ?) > 0', @tag] end @public_bodies = PublicBody.paginate( :order => "public_bodies.name", :page => params[:page], :per_page => 1000, # fit all councils on one page diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index e9475e1b2..734c649dd 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -180,7 +180,7 @@ class RequestController < ApplicationController # First time we get to the page, just display it if params[:submitted_new_request].nil? || params[:reedit] # Read parameters in - public body must be passed in - params[:info_request] = { :public_body_id => params[:public_body_id] } if !params[:info_request] + params[:info_request] = { :public_body_id => params[:public_body_id], :tag_string => params[:tags] } if !params[:info_request] if !params[:info_request][:public_body_id] redirect_to frontpage_url return |