Collaborative legislation summary

This commit is contained in:
German Galia
2019-06-03 12:34:25 +02:00
parent 2f8505332e
commit 4f50e67ac3
22 changed files with 649 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
<div class="row">
<div class="debate-chooser">
<div class="resume_title small-12 medium-9 column">
<h3><%= t("legislation.summary.debates_phase") %></h3>
</div>
<div class="small-12 medium-3 column">
<h3><%= t("legislation.questions.question.total", count: @process.questions.count) %></h3>
</div>
<div class="row">
<div class="small-12 medium-11 column">
<div class="debate-list">
<% if @process.questions.empty? %>
<div class="callout primary">
<p><%= t("legislation.processes.debate.empty_questions") %></p>
</div>
<% else %>
<%= render "resume_questions", process: @process %>
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@@ -52,6 +52,15 @@
<% end %>
</li>
<% end %>
<% if process.result_publication.enabled? && process.end_date <= Date.today %>
<li <%= "class=is-active" if phase == :resume %>>
<%= link_to resume_legislation_process_path(process) do %>
<h4><%= t("legislation.summary.title") %></h4>
<span><%= format_date(process.result_publication_date) %></span>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>

View File

@@ -0,0 +1,23 @@
<div class="row">
<div class="debate-chooser">
<div class="resume_title small-12 medium-9 column">
<h3><%= t("legislation.summary.proposal_phase") %></h3>
</div>
<div class="small-12 medium-3 column">
<h3><%= t("legislation.proposals.total", count: Legislation::Proposal.where(legislation_process_id: @process).where(selected: true).count) %></h3>
</div>
<div class="row">
<div class="small-12 medium-11 column">
<div class="debate-list">
<% if Legislation::Proposal.where(legislation_process_id: @process).where(selected: true).empty? %>
<div class="callout primary">
<p><%= t("legislation.processes.proposals.empty_proposals") %></p>
</div>
<% else %>
<%= render "resume_proposal", process: @process %>
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,17 @@
<% Legislation::Proposal.where(legislation_process_id: @process)
.where(selected: true).order('cached_votes_score desc').each do |proposal| %>
<div class="row">
<div class="proposal">
<div class="panel panel_resume" style="min-height: 5rem;">
<div class="small-12 medium-9 column">
<h3>
<%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %>
</h3>
</div>
<div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column">
<p class="centered_votes"> <%= proposal.cached_votes_total - proposal.cached_votes_down %> <%= t("legislation.summary.votes") %> </p>
</div>
</div>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,34 @@
<% @process.questions.each do |question| %>
<div class="row">
<div class="proposal">
<div class="panel panel_resume" style="min-height: 5rem;">
<div class="row question_title">
<div class="small-12 medium-9 column">
<div>
<h4><%= link_to question.title, legislation_process_question_path(question.process, question) %></h4>
</div>
</div>
<div id="<%= dom_id(question) %>_votes" class="small-12 medium-3 column">
<span class="icon-comments" aria-hidden="true"></span>
<span class="debate-comments">
<%= link_to t("legislation.summary.comments", count: question.comments.count), legislation_process_question_path(question.process, question) %>
</span>
</div>
</div>
<% if question.comments.count > 0 %>
<span><%= t("legislation.summary.most_voted_comments") %> </span>
<% end %>
<div class="row">
<% question.best_comments(3).each do |comment| %>
<div class="small-12 medium-9 column">
<p class="comment_box"> <%= link_to comment.body, comment_path(comment) %></p>
</div>
<div class="small-12 medium-3 column">
<p class="centered_votes"> <%= comment.cached_votes_up - comment.cached_votes_down %> <%= t("legislation.summary.votes") %></p>
</div>
<% end %>
</div>
</div>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,29 @@
<% @process.get_best_annotation_comments.take(10).each do |comment| %>
<div class="row">
<div class="proposal">
<div class="panel panel_resume" style="min-height: 5rem;">
<div class="row">
<div class="small-12 medium-9 column">
<span><%= t("legislation.annotations.index.comment_about") %> </span>
</div>
</div>
<div class="row question_title">
<div class="small-12 medium-9 column">
<div class="annotation_text question_title">
<span> "<%= Legislation::Annotation.find_by(id: comment.commentable_id).quote %>" </span>
</div>
</div>
<div class="small-12 medium-3 column">
<span> <%= comment.cached_votes_up - comment.cached_votes_down %> <%= t("legislation.summary.votes") %> </span>
</div>
</div>
<span><%= t("legislation.annotations.show.title") %>:</span>
<div class="row">
<div class="small-12 medium-9 column">
<p class="comment_box"> <%= link_to comment.body, comment_path(comment) %></p>
</div>
</div>
</div>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,32 @@
<div class="row">
<div class="debate-chooser">
<div class="small-12 medium-9 column resume_title">
<h3><%= t("legislation.summary.comments_phase") %>
<% if !@process.get_last_draft_version.nil? %>
(<%= t("legislation.summary.version") %> <%= @process.get_last_draft_version.title %>)</h3>
<% end %>
</div>
<div class="small-12 medium-3 column">
<h3><%= t("legislation.annotations.index.comments_count", count: @process.get_best_annotation_comments.count) %></h3>
</div>
<div class="row">
<div class="small-12 medium-11 column">
<div class="debate-list">
<% if !@process.get_last_draft_version.nil? %>
<% if @process.get_last_draft_version.annotations.empty? %>
<div class="callout primary">
<p><%= t("legislation.summary.no_allegation") %></p>
</div>
<% else %>
<%= render "resume_text", process: @process %>
<% end %>
<% else %>
<div class="callout primary">
<p><%= t("legislation.summary.no_allegation") %></p>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,28 @@
<% provide(:title) {@process.title} %>
<%= render "legislation/processes/header", process: @process, header: :full %>
<%= render "key_dates", process: @process, phase: @phase %>
<% if !@process.debate_phase.enabled? && !@process.proposals_phase.enabled? && !@process.allegations_phase.enabled? %>
<div class="callout primary">
<p><%= t("legislation.summary.process_empty") %></p>
</div>
<% else %>
<button class="button hollow download-button">
<%= link_to 'Download', resume_legislation_process_path(format: :xlsx) %>
</button>
<% if @process.debate_phase.enabled? %>
<%= render "debate_phase", process: @process %>
<% end %>
<% if @process.proposals_phase.enabled? %>
<%= render "proposal_phase", process: @process %>
<% end %>
<% if @process.allegations_phase.enabled? %>
<%= render "text_comment_phase", process: @process %>
<% end %>
<% end %>

View File

@@ -0,0 +1,37 @@
wb = xlsx_package.workbook
space = " "
wb.add_worksheet(name: "Resume") do |sheet|
if @process.debate_phase.enabled? && !@process.questions.empty?
sheet.add_row [t("legislation.summary.debates_phase"), t("legislation.questions.question.total", count: @process.questions.count)]
@process.questions.each do |question|
sheet.add_row [question.title, t("legislation.summary.comments", count: question.comments.count)]
sheet.add_hyperlink :location => legislation_process_question_url(question.process, question), :ref => sheet.rows.last.cells.first
question.best_comments(3).each do |comment|
sheet.add_row [comment.body, (comment.cached_votes_up - comment.cached_votes_down).to_s + space +t("legislation.summary.votes")]
sheet.add_hyperlink :location => comment_url(comment), :ref => sheet.rows.last.cells.first
end
sheet.add_row ["",""]
end
end
if @process.proposals_phase.enabled? && !Legislation::Proposal.where(legislation_process_id: @process).where(selected: true).empty?
sheet.add_row [t("legislation.summary.proposal_phase"), t("legislation.proposals.total", count: Legislation::Proposal.where(legislation_process_id: @process).where(selected: true).count)]
Legislation::Proposal.where(legislation_process_id: @process).where(selected: true).order('cached_votes_score desc').each do |proposal|
sheet.add_row [proposal.title,
(proposal.cached_votes_total - proposal.cached_votes_down).to_s + space + t("legislation.summary.votes")]
sheet.add_hyperlink :location => legislation_process_proposal_url(proposal.legislation_process_id, proposal), :ref => sheet.rows.last.cells.first
end
sheet.add_row ["",""]
end
if @process.allegations_phase.enabled? && !@process.get_last_draft_version.nil? && !@process.get_last_draft_version.annotations.empty?
sheet.add_row [t("legislation.summary.comments_phase")+" ("+t("legislation.summary.version")+@process.get_last_draft_version.title+")",
t("legislation.annotations.index.comments_count", count: @process.get_best_annotation_comments.count)]
@process.get_best_annotation_comments.take(10).each do |comment|
sheet.add_row [Legislation::Annotation.find_by(id: comment.commentable_id).quote,""]
sheet.add_row [comment.body, (comment.cached_votes_up - comment.cached_votes_down).to_s + space + t("legislation.summary.votes")]
sheet.add_hyperlink :location => comment_url(comment), :ref => sheet.rows.last.cells.first
end
end
end