Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development merge #12

Merged
merged 6 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions app/models/content_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ def reference
end

def subjects
return if content_object_data['subject_sesrollup'].blank?
return if content_object_data['subject_ses'].blank?

content_object_data['subject_sesrollup']
content_object_data['subject_ses']
end

def topics
# note - have not yet verified key as missing from test data
return if content_object_data['topic_sesrollup'].blank?
return if content_object_data['topic_ses'].blank?

content_object_data['topic_sesrollup']
content_object_data['topic_ses']
end

def legislation
return if content_object_data['legislationTitle_ses'].blank?

content_object_data['legislationTitle_ses'].first
content_object_data['legislationTitle_ses']
end

def department
Expand Down Expand Up @@ -106,7 +106,6 @@ def notes
end

def related_items
# no test data for related items currently available
# based on provided information, this will return one or more URIs of related item object pages

return if content_object_data['relation_t'].blank?
Expand Down
35 changes: 33 additions & 2 deletions app/models/edm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ def amendments
result_hashes
end

def amendments_count
return if amendments.blank?

amendments.size
end

def withdrawn?
return false unless state == 'Withdrawn'

true
end

def state
# e.g. 'Open'
return if content_object_data['edmStatus_t'].blank?

content_object_data['edmStatus_t']
end

def amendment_text
return if content_object_data['amendmentText_t'].blank?

Expand All @@ -72,16 +91,28 @@ def other_supporters
content_object_data['signedMember_ses']
end

def number_of_signatures
return if content_object_data['numberOfSignatures_t'].blank?

content_object_data['numberOfSignatures_t'].first
end

def motion_text
return if content_object_data['motionText_t'].blank?

content_object_data['motionText_t'].first
end

def primary_sponsor
return if content_object_data['primarySponsorPrinted_s'].blank?
return if content_object_data['primarySponsor_ses'].blank?

content_object_data['primarySponsor_ses'].first
end

def primary_sponsor_party
return if content_object_data['primarySponsorParty_ses'].blank?

content_object_data['primarySponsorPrinted_s'].first
content_object_data['primarySponsorParty_ses'].first
end

def date_tabled
Expand Down
7 changes: 7 additions & 0 deletions app/models/research_briefing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def creator

content_object_data['creator_ses'].first
end
def creator_party
# this is for the prelim 'by...'

return if content_object_data['creatorParty_ses'].blank?

content_object_data['creatorParty_ses'].first
end

def published_by
# this is the publishing organisation and is to be used in the secondary attributes
Expand Down
55 changes: 53 additions & 2 deletions app/models/written_question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def answered_was_holding?
# There is no state string for this, it must be derived
return false unless state == 'Answered'

# the following correspond to the holding state and their presence allows us to determine that this answered
# question formerly had the state 'holding':
# 1. the question has received a holding answer:
return false unless holding_answer?

# 2. the date this question received a holding answer:
return false if date_of_holding_answer.blank?

true
Expand All @@ -48,8 +52,35 @@ def withdrawn?
def corrected?
# There is no state string for this, it must be derived
# Prior to July 2014, correctedWmsMc_b flag + related links will contain a link to the correction
# After July 2014, correctedWmsMc_b + correctingItem_uri OR correctingItem_t
state == 'Corrected'
# After July 2014, correctedWmsMc_b + correctingItem_uri OR correctingItem_t / s as a fallback

# There's the potential for some confusion here at this is not mutually exclusive with the other states
# e.g. a written question could, under this model, be answered and corrected, or tabled and corrected

return false unless content_object_data['correctedWmsMc_b'] == 'true'

true
end

def correcting_object
# Note - this is experimental and sets up correcting_object as a written question in its own right.
#
# In the view, we can then call object.correcting_object.department, object.correcting_object.date_of_question and
# object.correcting_object.correcting_member to get the information we need regarding the correction.
#
# This only applies to corrections before July 2014, and for corrected written questions after this date
# this method should return nil as content_object_data['correctingItem_uri'] will be blank. We can therefore
# check correcting_object is not nil to determine whether or not we attempt to show its data in the view.
#
# May need to adjust this to cache response first time around
# Also worth noting here: we're assuming that the correcting object is a written question

return unless corrected?

return if content_object_data['correctingItem_uri'].blank?

correcting_item_data = ApiCall.new(object_uri: content_object_data['correctingItem_uri']).object_data
ContentObject.generate(correcting_item_data)
end

def prelim_partial
Expand Down Expand Up @@ -101,6 +132,14 @@ def date_of_answer
valid_date_string.to_date
end

def date_for_answer
# This is required by the views as currently wireframed:
# 'it was due for answer on <date>'
# Currently unclear on the field holding this information

nil
end

def date_of_holding_answer
return if content_object_data['dateOfHoldingAnswer_dt'].blank?

Expand All @@ -116,12 +155,24 @@ def tabling_member
content_object_data['tablingMember_ses'].first
end

def tabling_member_party
return if content_object_data['tablingMemberParty_ses'].blank?

content_object_data['tablingMemberParty_ses'].first
end

def answering_member
return if content_object_data['answeringMember_ses'].blank?

content_object_data['answeringMember_ses'].first
end

def answering_member_party
return if content_object_data['answeringMemberParty_ses'].blank?

content_object_data['tablingMemberParty_ses'].first
end

def answer_text
return if content_object_data['answerText_t'].blank?

Expand Down
2 changes: 1 addition & 1 deletion app/models/written_statement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def object_name
def attachment
return if content_object_data['attachment_t'].blank?

content_object_data['attachment_t'].first
content_object_data['attachment_t']
end

def notes
Expand Down
20 changes: 12 additions & 8 deletions app/views/search/fragments/_data.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<%# A template to render the raw SOLR data. %>
<details class="solr-data">
<summary>
SOLR data
</summary>
<code>
<%= data %>
</code>
</details>
<section class="content-section">
<div class="about-item">
<details class="solr-data">
<summary>
SOLR data
</summary>
<code>
<%= data %>
</code>
</details>
</div>
</section>
19 changes: 17 additions & 2 deletions app/views/search/fragments/_edm_prelim.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
<div class="content-prelim-box">
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
An <%= object_link('Early Day Motion', '/') %> tabled by <%= object_link(object.primary_sponsor, '/') %>
on <strong><%= object.date_tabled&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>.
An <%= object_link('Early Day Motion', '/') %> sponsored by <%= object_link(object.primary_sponsor, '/') %>
(primary sponsor, <%= object_link(object.primary_sponsor_party, '/') %>)
<% unless object.other_supporters.blank? %>
<% object.other_supporters.each do |supporter| %>
<%= object_link(supporter, '/') %>,
<% end %>
<% end %>
and tabled on <strong><%= object.date_tabled&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
in the <%= object_link(object.legislature, '/') %>.
It is a fatal prayer
<strong>signed by <%= object.number_of_signatures %> members in total</strong><%= object.amendments_count ? \
',' : '.' %>
<% if object.amendments_count %> and has received <%= object_link(object.amendments_count, '#amendments') %>.
<% end %>
<% if object.withdrawn? %>
The primary sponsor has subsequently withdrawn this motion.
<% end %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="content-prelim-box">
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
An <%= object_link("#{object.object_name.titleize}", '/') %>
A <%= object_link("#{object.object_name.titleize}", '/') %>
by <%= object_link("#{object.creator}", '/') %>
published on <strong><%= object.published_on&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>.
<% if object.updated_on %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
A <%= object_link("#{object.object_name.titleize}", '/') %>
was asked by <%= object_link("#{object.tabling_member}", '/') %>
asked by <%= object_link("#{object.tabling_member}", '/') %> (<%= object.tabling_member_party %>)
on <strong><%= object.date_of_question.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>,
in the <%= object_link("#{object.department}", '/') %>.
in the <%= object_link("#{object.legislature}", '/') %>.
It was due for answer
on <strong><%= object.date_of_answer.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on <strong><%= object.date_for_answer.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
(named day).
It was answered by <%= object_link("#{object.answering_member}", '/') %>
It was answered by <%= object_link("#{object.answering_member}", '/') %> (<%= object.answering_member_party %>)
on <strong><%= object.date_of_answer.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.legislature}", '/') %>.
on behalf of the <%= object_link("#{object.department}", '/') %>.
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
A <%= object_link("#{object.object_name.titleize}", '/') %>
was asked by <%= object_link("#{object.tabling_member}", '/') %>
asked by <%= object_link("#{object.tabling_member}", '/') %> (<%= object.tabling_member_party %>)
on <strong><%= object.date_of_question&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>,
in the <%= object_link("#{object.department}", '/') %>.
in the <%= object_link("#{object.legislature}", '/') %>.
It was due for answer
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
(named day).
A holding answer was provided by <%= object_link("#{object.answering_member}", '/') %>
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.legislature}", '/') %>.
(<%= object.answering_member_party %>)
on <strong><%= object.date_of_holding_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.department}", '/') %>.

<!-- need details on where replacement answer Member and department are sourced from -->
A replacement answer was provided by <%= object_link("#{object.answering_member}", '/') %>
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.legislature}", '/') %>.
on behalf of <%= object_link("#{object.department}", '/') %>.
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
A <%= object_link("#{object.object_name.titleize}", '/') %>
was asked by <%= object_link("#{object.tabling_member}", '/') %>
asked by <%= object_link("#{object.tabling_member}", '/') %> (<%= object.tabling_member_party %>)
on <strong><%= object.date_of_question&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>,
in the <%= object_link("#{object.department}", '/') %>.
in the <%= object_link("#{object.legislature}", '/') %>.
It was due for answer
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
(named day).
It was answered by <%= object_link("#{object.answering_member}", '/') %>
It was answered by <%= object_link("#{object.answering_member}", '/') %> (<%= object.answering_member_party %>)
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.legislature}", '/') %>.
The answer was corrected by <%= object_link("#{object.answering_member}", '/') %>
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.legislature}", '/') %>.
on behalf of <%= object_link("#{object.department}", '/') %>.
<% if object.correcting_item? %>
The answer was corrected by <%= object_link("#{object.correcting_item.answering_member}", '/') %>
(<%= object.correcting_item.answering_member_party %>) on
<strong><%= object.correcting_item.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.correcting_item.department}", '/') %>.
<% else %>
It has since been corrected.
<% end %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
A <%= object_link("#{object.object_name.titleize}", '/') %>
was asked by <%= object_link("#{object.tabling_member}", '/') %>
asked by <%= object_link("#{object.tabling_member}", '/') %> (<%= object.tabling_member_party %>)
on <strong><%= object.date_of_question&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>,
in the <%= object_link("#{object.department}", '/') %>.
in the <%= object_link("#{object.legislature}", '/') %>.
It was due for answer
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on <strong><%= object.date_for_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
(named day).
A holding answer was provided by <%= object_link("#{object.answering_member}", '/') %>
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.legislature}", '/') %>.
(<%= object.answering_member_party %>)
on <strong><%= object.date_of_holding_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on behalf of <%= object_link("#{object.department}", '/') %>.
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
A <%= object_link("#{object.object_name.titleize}", '/') %>
was tabled by <%= object_link("#{object.tabling_member}", '/') %>
tabled by <%= object_link("#{object.tabling_member}", '/') %> (<%= object.tabling_member_party %>)
on <strong><%= object.date_of_question&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>,
in the <%= object_link("#{object.department}", '/') %> for the
<%= object_link("#{object.legislature}", '/') %>.
in the <%= object_link("#{object.legislature}", '/') %> for the
<%= object_link("#{object.department}", '/') %>.
It is due for answer
on <strong><%= object.date_of_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
on <strong><%= object.date_for_answer&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>
(named day).
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div class="content-prelim-inner">
<div class="content-prelim-text" id="prelim-text">
A <%= object_link("#{object.object_name.titleize}", '/') %>
was asked by <%= object_link("#{object.tabling_member}", '/') %>
asked by <%= object_link("#{object.tabling_member}", '/') %>
on <strong><%= object.date_of_question&.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) %></strong>,
in the <%= object_link("#{object.department}", '/') %>.
The asking Member has subsequently withdrawn this question and no longer needs to be answered by
in the <%= object_link("#{object.legislature}", '/') %>.
The Member has subsequently withdrawn this question. An answer is no longer expected from
the <%= object_link("#{object.department}", '/') %>.
</div>
</div>
Expand Down
Loading
Loading