Skip to content

Commit

Permalink
Merge branch 'extract-public-body-excluded-tags' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed May 17, 2024
2 parents 5fc95f8 + b7d2bff commit 2dc9cc6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ def index
def search
# perform_seach sets @query but typeahead_search doesn't
@query = params[:authority_query] || ""
excluded_tags = %w(defunct not_apply)
@search = typeahead_search(@query, model: PublicBody,
exclude_tags: excluded_tags)
@search = typeahead_search(
@query,
model: PublicBody,
exclude_tags: PublicBody.batch_excluded_tags
)

unless @search.blank?
@result_limit = calculate_result_limit(@search)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ def update_bodies
case update_bodies_params[:action]
when 'add-all'
@draft ||= current_user.draft_info_request_batches.create
requestable = PublicBody.with_tag(category_tag).select(&:is_requestable?)
requestable = PublicBody.without_tag(PublicBody.batch_excluded_tags).
with_tag(category_tag).select(&:is_requestable?)
@draft.public_bodies << requestable
when 'add'
public_body = PublicBody.find(update_bodies_params[:public_body_id])
public_body = PublicBody.without_tag(PublicBody.batch_excluded_tags).
find(update_bodies_params[:public_body_id])
@draft ||= current_user.draft_info_request_batches.create
@draft.public_bodies << public_body
when 'remove'
Expand Down
4 changes: 4 additions & 0 deletions app/models/public_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def self.admin_title
# Set to 0 to prevent application of the not_many_requests tag
cattr_accessor :not_many_public_requests_size, default: 5

# Any PublicBody tagged with any of the follow tags won't be returned in the
# batch authority search results or batch category UI
cattr_accessor :batch_excluded_tags, default: %w[not_apply defunct]

has_many :info_requests,
-> { order(created_at: :desc) },
inverse_of: :public_body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<ul>
<% heading.children.each do |category| %>
<% next if category.category_tag == 'school' #FIXME quickfix to preventing loading of large category %>
<% next if PublicBody.batch_excluded_tags.include?(category.category_tag) %>
<% selected = category.category_tag == category_tag %>
<li class="batch-builder__list__group <%= 'batch-builder__list__group--closed' unless selected %>">
<div class="batch-builder__list__item">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul>
<% public_bodies = PublicBody.with_tag(category_tag).with_translations.is_requestable %>
<% public_bodies = PublicBody.without_tag(PublicBody.batch_excluded_tags).with_tag(category_tag).with_translations.is_requestable %>
<% public_bodies.each do |public_body| %>
<%= render partial: 'alaveteli_pro/batch_request_authority_searches/search_result',
locals: { public_body: public_body,
Expand Down

0 comments on commit 2dc9cc6

Please sign in to comment.