Skip to content

Commit

Permalink
Merge pull request #163 from ukparliament/development
Browse files Browse the repository at this point in the history
Development merge
  • Loading branch information
j-corry authored Aug 28, 2024
2 parents f664ff1 + 589f86e commit b6c6d2d
Show file tree
Hide file tree
Showing 58 changed files with 1,151 additions and 1,261 deletions.
2 changes: 1 addition & 1 deletion app/helpers/date_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ def format_date(data)

return if data[:value].blank?

data[:value].strftime(ApplicationHelper::DATE_DISPLAY_FORMAT)
data[:value].to_date.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT)
end
end
11 changes: 9 additions & 2 deletions app/models/content_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def associated_objects
end

def amendments
# TODO: temporary superclass method for non-EDM objects to be able to use a standard view for all result types
nil
end

Expand Down Expand Up @@ -187,7 +186,7 @@ def primary_sponsor
end

def primary_sponsor_party
get_first_from('primarySponsorParty_ses')
get_all_from('primarySponsorParty_ses')
end

def legislature
Expand Down Expand Up @@ -288,6 +287,10 @@ def member_party
get_first_from('memberParty_ses')
end

def member_parties
get_all_from('memberParty_ses')
end

def answering_member
get_first_from('answeringMember_ses')
end
Expand All @@ -300,6 +303,10 @@ def asking_member_party
get_first_from('askingMemberParty_ses')
end

def asking_member_parties
get_all_from('askingMemberParty_ses')
end

def lead_member
get_first_from('leadMember_ses')
end
Expand Down
49 changes: 20 additions & 29 deletions app/models/edm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,29 @@ def amendments
# Title is the title of the motion itself, with 'Amendment N' on the front
# Reference is taken from identifier_t, after removing the first item

return if content_object_data['amendmentText_t'].blank?
return if content_object_data['amendment_numberOfSignatures_s'].blank?
return if content_object_data['amendment_primarySponsorPrinted_t'].blank?
return if content_object_data['amendment_primarySponsorParty_ses'].blank?
return if content_object_data['identifier_t'].blank?
return if content_object_data['amendment_dateTabled_dt'].blank?

original_hash = {
text: content_object_data['amendmentText_t'],
number_of_signatures: content_object_data['amendment_numberOfSignatures_s'],
primary_sponsor: content_object_data['amendment_primarySponsorPrinted_t'],
primary_sponsor_party: content_object_data['amendment_primarySponsorParty_ses'],
reference: content_object_data['identifier_t'].drop(1),
date_tabled: content_object_data['amendment_dateTabled_dt'],
text: content_object_data['amendmentText_t'].blank? ? {} : { value: content_object_data['amendmentText_t'], field_name: 'amendmentText_t' },
number_of_signatures: content_object_data['amendment_numberOfSignatures_s'].blank? ? {} : { value: content_object_data['amendment_numberOfSignatures_s'], field_name: 'amendment_numberOfSignatures_s' },
primary_sponsor: content_object_data['amendment_primarySponsor_ses'].blank? ? {} : { value: content_object_data['amendment_primarySponsor_ses'], field_name: 'amendment_primarySponsor_ses' },
primary_sponsor_text: content_object_data['amendment_primarySponsorPrinted_t'].blank? ? {} : { value: content_object_data['amendment_primarySponsorPrinted_t'], field_name: 'amendment_primarySponsorPrinted_t' },
primary_sponsor_party: content_object_data['amendment_primarySponsorParty_ses'].blank? ? {} : { value: content_object_data['amendment_primarySponsorParty_ses'], field_name: 'amendment_primarySponsorParty_ses' },
reference: content_object_data['identifier_t']&.drop(1).blank? ? {} : { value: content_object_data['identifier_t']&.drop(1), field_name: 'identifier_t' },
date_tabled: content_object_data['amendment_dateTabled_dt'].blank? ? {} : { value: content_object_data['amendment_dateTabled_dt'], field_name: 'amendment_dateTabled_dt' }
}

result_hashes = original_hash[:text].zip(
original_hash[:number_of_signatures],
original_hash[:primary_sponsor],
original_hash[:primary_sponsor_party],
original_hash[:reference],
original_hash[:date_tabled],
).map.with_index do |values, index|
{
index: index,
text: { value: values[0], field_name: 'amendmentText_t' },
number_of_signatures: { value: values[1], field_name: 'amendment_numberOfSignatures_s' },
primary_sponsor: { value: values[2], field_name: 'amendment_primarySponsorPrinted_t' },
primary_sponsor_party: { value: values[3], field_name: 'amendment_primarySponsorParty_ses' },
reference: { value: values[4], field_name: 'identifier_t' },
date_tabled: { value: values[5]&.to_date, field_name: 'amendment_dateTabled_dt' },
}
return [] if original_hash.values.pluck(:value).compact.blank?

number_of_amendments = original_hash.values.pluck(:value).compact.map(&:size).max
keys = original_hash.keys
result_hashes = []

number_of_amendments.times do |iteration|
ret = {}
keys.each do |key|
ret[key] = { value: original_hash.dig(key, :value).blank? ? nil : original_hash.dig(key, :value)[iteration], field_name: original_hash.dig(key, :field_name) }
end
ret[:index] = iteration
result_hashes << ret
end

result_hashes
Expand Down
8 changes: 8 additions & 0 deletions app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def tabling_member_party
get_first_from('tablingMemberParty_ses')
end

def tabling_member_parties
get_all_from('tablingMemberParty_ses')
end

def answer_text
get_first_as_html_from('answerText_t')
end
Expand Down Expand Up @@ -100,6 +104,10 @@ def answering_member_party
get_first_from('answeringMemberParty_ses')
end

def answering_member_parties
get_all_from('answeringMemberParty_ses')
end

def question?
true
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/written_question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ def answering_body
get_first_from('departmentPrinted_t')
end

def asking_or_tabling_member_party
fallback(get_first_from('tablingMemberParty_ses'), get_first_from('askingMemberParty_ses'))
end

def attachment
# this is the title of the attachment, rather than a link to the resource
# there can be multiple titles, all of which will be displayed
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/fragments/_simple_list.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%span>= terminator
- elsif items.size == 2
%span= object_display_name(items.first, singular: singular)
%span= "; "
%span>= "; "
%span= object_display_name(items.last, singular: singular)
%span>= terminator
- elsif items.size > 2
Expand Down
4 changes: 2 additions & 2 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<% end %>
<% if Rails.env.development? %>
<%#= render 'search/fragments/data', data: @associated_object_data, title: 'Associated object data' %>
<%#= render 'search/fragments/data', data: @search_data.search, title: 'Search response' %>
<%= render 'search/fragments/data', data: @associated_object_data, title: 'Associated object data' %>
<%= render 'search/fragments/data', data: @search_data.search, title: 'Search response' %>
<%#= render 'search/fragments/data', data: @ses_data, title: 'SES results' %>
<%= render 'search/fragments/data', data: @search_data.facets, title: 'Facets' %>
<%#= render 'search/fragments/data', data: @top_level, title: 'Hierarchy top level types' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/preliminary_sentences/_edm.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%span= " (primary sponsor)"
- else
%span= " (primary sponsor, "
%span>= search_link(object.primary_sponsor_party)
%span>= render 'search/fragments/list', items: object.primary_sponsor_party, terminator: '', singular: false
%span= ")"
- unless object.other_sponsors.blank?
%span>= render 'search/fragments/edm_sponsor_list', items: object.other_sponsors, terminator: '', singular: false
Expand Down
3 changes: 1 addition & 2 deletions app/views/search/results/_bill.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<div class="row">
<div class="three-panel">
<div class="left" id="primary-person">
<%= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
<%= render 'search/results/item_details/member', member: object.member, member_party: object.member_parties %>
</div>
<div class="centre" id="secondary-person">

</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: false %>
Expand Down
1 change: 0 additions & 1 deletion app/views/search/results/_command_paper.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</div>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: false %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/search/results/_committee_proceeding.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<div class="row">
<div class="three-panel">
<div class="left" id="primary-person">
<%= render 'search/results/item_details/lead_member', lead_member: object.lead_member, lead_member_party: object.lead_member_party %>
<%= render 'search/results/item_details/lead_members', lead_members: object.lead_members, lablel: "Lead Member" %>
</div>
<div class="centre" id="secondary-person">
<%= render 'search/results/item_details/answering_member', answering_member: object.answering_member, answering_member_party: nil, label: 'Answering Member' %>
<%= render 'search/results/item_details/answering_members', answering_members: object.answering_members, label: 'Answering Member' %>
</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: true %>
Expand Down
2 changes: 0 additions & 2 deletions app/views/search/results/_deposited_paper.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
<div class="row">
<div class="three-panel">
<div class="left" id="primary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: true %>
Expand Down
6 changes: 0 additions & 6 deletions app/views/search/results/_early_day_motion.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
<%= render 'search/results/item_details/primary_sponsor', primary_sponsor: object.primary_sponsor, primary_sponsor_party: object.primary_sponsor_party %>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%#= render 'search/results/item_details/departments', departments: object.departments, hide_label: false %>
</div>
</div>
</div>
Expand Down Expand Up @@ -95,19 +93,15 @@
<% end %>
<%= render 'search/results/item_details/legislation', legislation: object.legislation unless object.legislation.blank? %>
<%#= render 'search/results/item_details/witnesses', witnesses: object.witnesses unless object.witnesses.blank? %>
<%= render 'search/results/item_details/subjects', subjects: object.subjects unless object.subjects.blank? %>
<%#= render 'search/results/item_details/topics', topics: object.topics unless object.topics.blank? %>
<%= render 'search/results/item_details/notes', notes: object.notes unless object.notes.blank? %>
<% unless object.commons_library_location.blank? && object.lords_library_location.blank? %>
<div class="row">
<div class="two-panel">
<div class="left" id="commons-library-location">
<%#= render 'search/results/item_details/commons_library_location', location: object.commons_library_location unless object.commons_library_location.blank? %>
</div>
<div class="right" id="lords-library-location">
<%#= render 'search/results/item_details/lords_library_location', location: object.lords_library_location unless object.lords_library_location.blank? %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
<div class="row">
<div class="three-panel">
<div class="left" id="primary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: true %>
Expand Down Expand Up @@ -80,21 +78,15 @@
<div class="row">
<div class="two-panel">
<div class="left" id="amending-member">
<%#= render 'search/results/item_details/amended_by', primary_sponsor: amendment.dig(:primary_sponsor, :value) unless amendment.dig(:primary_sponsor, :value).blank? %>
</div>
<div class="right" id="amendment-date">
<%#= render 'search/results/item_details/amended_on', date_tabled: amendment.dig(:date_tabled, :value) unless amendment.dig(:date_tabled, :value).blank? %>
</div>
</div>
</div>
<% end %>
<% end %>
<%#= render 'search/results/item_details/legislation', legislation: object.legislation unless object.legislation.blank? %>
<%#= render 'search/results/item_details/witnesses', witnesses: object.witnesses unless object.witnesses.blank? %>
<%= render 'search/results/item_details/subjects', subjects: object.subjects unless object.subjects.blank? %>
<%#= render 'search/results/item_details/topics', topics: object.topics unless object.topics.blank? %>
<%#= render 'search/results/item_details/notes', notes: object.notes unless object.notes.blank? %>
<% unless object.commons_library_location.blank? && object.lords_library_location.blank? %>
<div class="row">
Expand Down
7 changes: 0 additions & 7 deletions app/views/search/results/_european_material.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
</div>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%#= render 'search/results/item_details/departments', departments: object.departments, hide_label: false %>
</div>
</div>
</div>
Expand Down Expand Up @@ -81,21 +79,16 @@
<div class="row">
<div class="two-panel">
<div class="left" id="amending-member">
<%#= render 'search/results/item_details/amended_by', primary_sponsor: amendment.dig(:primary_sponsor, :value) unless amendment.dig(:primary_sponsor, :value).blank? %>
</div>
<div class="right" id="amendment-date">
<%#= render 'search/results/item_details/amended_on', date_tabled: amendment.dig(:date_tabled, :value) unless amendment.dig(:date_tabled, :value).blank? %>
</div>
</div>
</div>
<% end %>
<% end %>
<%= render 'search/results/item_details/legislation', legislation: object.legislation unless object.legislation.blank? %>
<%#= render 'search/results/item_details/witnesses', witnesses: object.witnesses unless object.witnesses.blank? %>
<%= render 'search/results/item_details/subjects', subjects: object.subjects unless object.subjects.blank? %>
<%#= render 'search/results/item_details/topics', topics: object.topics unless object.topics.blank? %>
<%#= render 'search/results/item_details/notes', notes: object.notes unless object.notes.blank? %>
<% unless object.commons_library_location.blank? && object.lords_library_location.blank? %>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
<div class="row">
<div class="three-panel">
<div class="left" id="primary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: true %>
Expand Down Expand Up @@ -79,21 +77,15 @@
<div class="row">
<div class="two-panel">
<div class="left" id="amending-member">
<%#= render 'search/results/item_details/amended_by', primary_sponsor: amendment.dig(:primary_sponsor, :value) unless amendment.dig(:primary_sponsor, :value).blank? %>
</div>
<div class="right" id="amendment-date">
<%#= render 'search/results/item_details/amended_on', date_tabled: amendment.dig(:date_tabled, :value) unless amendment.dig(:date_tabled, :value).blank? %>
</div>
</div>
</div>
<% end %>
<% end %>
<%#= render 'search/results/item_details/legislation', legislation: object.legislation unless object.legislation.blank? %>
<%#= render 'search/results/item_details/witnesses', witnesses: object.witnesses unless object.witnesses.blank? %>
<%= render 'search/results/item_details/subjects', subjects: object.subjects unless object.subjects.blank? %>
<%#= render 'search/results/item_details/topics', topics: object.topics unless object.topics.blank? %>
<%#= render 'search/results/item_details/notes', notes: object.notes unless object.notes.blank? %>
<% unless object.commons_library_location.blank? && object.lords_library_location.blank? %>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<%= render 'search/results/item_details/corresponding_minister', corresponding_minister: object.corresponding_minister %>
</div>
<div class="centre" id="secondary-person">
<%#= render 'search/results/item_details/member', member: object.member, member_party: object.member_party %>
</div>
<div class="right" id="primary-group">
<%= render 'search/results/item_details/departments', departments: object.departments, hide_label: true %>
Expand Down Expand Up @@ -81,21 +80,15 @@
<div class="row">
<div class="two-panel">
<div class="left" id="amending-member">
<%#= render 'search/results/item_details/amended_by', primary_sponsor: amendment.dig(:primary_sponsor, :value) unless amendment.dig(:primary_sponsor, :value).blank? %>
</div>
<div class="right" id="amendment-date">
<%#= render 'search/results/item_details/amended_on', date_tabled: amendment.dig(:date_tabled, :value) unless amendment.dig(:date_tabled, :value).blank? %>
</div>
</div>
</div>
<% end %>
<% end %>
<%#= render 'search/results/item_details/legislation', legislation: object.legislation unless object.legislation.blank? %>
<%#= render 'search/results/item_details/witnesses', witnesses: object.witnesses unless object.witnesses.blank? %>
<%= render 'search/results/item_details/subjects', subjects: object.subjects unless object.subjects.blank? %>
<%#= render 'search/results/item_details/topics', topics: object.topics unless object.topics.blank? %>
<%#= render 'search/results/item_details/notes', notes: object.notes unless object.notes.blank? %>
<% unless object.commons_library_location.blank? && object.lords_library_location.blank? %>
<div class="row">
Expand Down
Loading

0 comments on commit b6c6d2d

Please sign in to comment.