Report generation. Download csv

This commit is contained in:
German Galia
2019-06-12 10:17:31 +02:00
parent 139b2720d8
commit 9d1ca3bfd4
63 changed files with 1528 additions and 40 deletions

View File

@@ -9,6 +9,22 @@
</li>
<% end %>
<% if feature?(:debates) %>
<li class="section-title <%= "is-active" if controller_name == "debates" %>">
<%= link_to admin_debates_path do %>
<span class="icon-debates"></span>
<strong><%= t("admin.menu.debates") %></strong>
<% end %>
</li>
<% end %>
<li class="section-title <%= "is-active" if controller_name == "comments" %>">
<%= link_to admin_comments_path do %>
<span class="icon-comments"></span>
<strong><%= t("admin.menu.comments") %></strong>
<% end %>
</li>
<% if feature?(:polls) %>
<li class="section-title <%= "is-active" if menu_polls? %>">
<%= link_to admin_polls_path do %>
@@ -212,6 +228,50 @@
<% end %>
</li>
<li class="section-title">
<a href="#">
<span class="icon-arrow-down"></span>
<strong><%= t("admin.menu.download_settings.title") %></strong>
</a>
<ul <%= "class=is-active" if controller_name == "download_settings" %>>
<% if feature?(:debates) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "debates" %>>
<%= link_to t("admin.menu.download_settings.debates"), admin_edit_download_settings_path(resource: "debates") %>
</li>
<% end %>
<% if feature?(:proposals) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "proposals" %>>
<%= link_to t("admin.menu.download_settings.proposals"), admin_edit_download_settings_path(resource: "proposals") %>
</li>
<% end %>
<% if feature?(:legislation) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "legislation_processes" %>>
<%= link_to t("admin.menu.download_settings.legislation_processes"), admin_edit_download_settings_path(resource: "legislation_processes") %>
</li>
<% end %>
<% if feature?(:budgets) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "budget_investments" %>>
<%= link_to t("admin.menu.download_settings.budget_investments"), admin_edit_download_settings_path(resource: "budget_investments") %>
</li>
<% end %>
<% if feature?(:budgets) %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "budget_investments" %>>
<%= link_to t("admin.menu.download_settings.budget_investments_milestones"), admin_edit_download_settings_path(resource: "budget_investments", config: 1) %>
</li>
<% end %>
<li <%= "class=is-active" if !@download_resource.nil? && @download_resource == "comments" %>>
<%= link_to t("admin.menu.download_settings.comments"), admin_edit_download_settings_path(resource: "comments") %>
</li>
</ul>
</li>
<li class="section-title">
<a href="#">
<span class="icon-settings"></span>

View File

@@ -1,6 +1,4 @@
<%= link_to t("admin.budget_investments.index.download_current_selection"),
admin_budget_budget_investments_path(csv_params),
class: "float-right small clear" %>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.budget_investments.index.download_current_selection") %></a>
<% if params[:advanced_filters].include?("winners") %>
@@ -62,3 +60,5 @@
<%= t("admin.budget_investments.index.no_budget_investments") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "budget_investments" } %>

View File

@@ -0,0 +1,49 @@
<% provide(:title) do %>
<%= t("admin.header.title") %> - <%= t("admin.comments.index.title") %>
<% end %>
<h2><%= t("admin.comments.index.title") %></h2>
<% if @comments.any? %>
<h3 class="inline-block"><%= page_entries_info @comments %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.comments.index.link") %></a>
<table>
<thead>
<tr>
<th class="text-center"><%= t("admin.comments.index.id") %></th>
<th><%= t("admin.comments.index.content") %></th>
<th><%= t("admin.comments.index.author") %></th>
<th><%= t("admin.comments.index.commentable_type") %></th>
<th><%= t("admin.comments.index.table_link") %></th>
</tr>
</thead>
<tbody>
<% @comments.each do |comment| %>
<tr id="<%= dom_id(comment) %>" class="debates">
<td class="text-center"><%= comment.id %></td>
<td><%= comment.body %></td>
<td><%= comment.author.username %></td>
<td><%= comment.commentable_type.constantize.model_name.human %></td>
<td>
<% if comment.commentable.hidden? %>
(<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>)
<% else %>
<%= link_to comment.commentable.title, commentable_path(comment) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @comments %>
<% else %>
<div class="callout primary margin">
<%= t("admin.comments.index.no_comments") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "comments" } %>

View File

@@ -0,0 +1,38 @@
<% provide(:title) do %>
<%= t("admin.header.title") %> - <%= t("admin.debates.index.title") %>
<% end %>
<h2><%= t("admin.debates.index.title") %></h2>
<% if @debates.any? %>
<%= render "/admin/shared/debate_search", url: admin_debates_path %>
<h3 class="inline-block"><%= page_entries_info @debates %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.debates.index.link") %></a>
<table>
<thead>
<th class="text-center"><%= t("admin.debates.index.id") %></th>
<th><%= t("admin.debates.index.title") %></th>
<th><%= t("admin.debates.index.author") %></th>
</thead>
<tbody>
<% @debates.each do |debate| %>
<tr id="<%= dom_id(debate) %>" class="debates">
<td class="text-center"><%= debate.id %></td>
<td><%= link_to debate.title, admin_debate_path(debate) %></td>
<td><%= debate.author.username %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @debates %>
<% else %>
<div class="callout primary margin">
<%= t("admin.debates.index.no_debates") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "debates" } %>

View File

@@ -0,0 +1,56 @@
<% provide :title do %>
<%= t("admin.header.title") %> - <%= t("admin.menu.debates") %> - <%= @debate.title %>
<% end %>
<div class="debate-show">
<h2><%= @debate.title %></h2>
<% if @debate.conflictive? %>
<div data-alert class="callout alert margin-top">
<strong><%= t("debates.show.flag") %></strong>
</div>
<% end %>
<div class="debate-info">
<%= render '/shared/author_info', resource: @debate %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= l @debate.created_at.to_date %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="icon-comments"></span>&nbsp;
<%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="js-flag-actions">
<%= render 'debates/flag_actions', debate: @debate %>
</span>
</div>
<%= safe_html_with_links @debate.description %>
<h3><%= t("votes.supports") %></h3>
<span class="total-votes">
<%= t("debates.debate.votes", count: @debate.votes_score) %>
</span>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<div class="in-favor inline-block">
<span class="icon-like">
<span class="show-for-sr"><%= t('votes.agree') %></span>
</span>
<span class="percentage"><%= votes_percentage('likes', @debate) %></span>
</div>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<div class="against inline-block">
<span class="icon-unlike">
<span class="show-for-sr"><%= t('votes.disagree') %></span>
</span>
<span class="percentage"><%= votes_percentage('dislikes', @debate) %></span>
</div>
</div>
<%= render 'shared/tags', taggable: @debate %>

View File

@@ -0,0 +1,19 @@
<table>
<thead>
<tr>
<th><%= t("download.edit.fields") %></th>
<th><%= t("download.edit.description") %></th>
<th class="small"><%= t("download.edit.downloadable") %></th>
</tr>
</thead>
<tbody>
<% download_settings.each do |attr| %>
<tr>
<td><%= attr.name_field %></td>
<td><%= t("download.fielddescription.#{resource[:name]}.#{attr.name_field}", default: "") %></td>
<td class="text-center small"><%= check_box_tag "downloadable[]", attr.name_field, attr.downloadable, class: "js-download-settings-check" %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -0,0 +1,30 @@
<% if params[:search].present? %>
<%= hidden_field_tag "search", params[:search] %>
<% end %>
<% if params[:commit].present? %>
<%= hidden_field_tag "commit", params[:commit] %>
<% end %>
<% if params[:filter].present? %>
<%= hidden_field_tag "filter", params[:filter] %>
<% end %>
<% if params[:page].present? %>
<%= hidden_field_tag "page", params[:page] %>
<% end %>
<% if params[:administrator_id].present? %>
<%= hidden_field_tag "administrator_id", params[:administrator_id] %>
<% end %>
<% if params[:valuator_or_group_id].present? %>
<%= hidden_field_tag "valuator_or_group_id", params[:valuator_or_group_id] %>
<% end %>
<% if params[:heading_id].present? %>
<%= hidden_field_tag "heading_id", params[:heading_id] %>
<% end %>
<% if params[:title_or_id].present? %>
<%= hidden_field_tag "title_or_id", params[:title_or_id] %>
<% end %>
<% if params[:tag_name].present? %>
<%= hidden_field_tag "tag_name", params[:tag_name] %>
<% end %>
<% if params[:min_total_supports].present? %>
<%= hidden_field_tag "min_total_supports", params[:min_total_supports] %>
<% end %>

View File

@@ -0,0 +1,13 @@
<div class="small reveal" id="download-modal" data-reveal>
<h1><%= t('download.modal.title') %></h1>
<%= form_tag current_path_with_query_params(format: :csv), method: :get do |f| %>
<%= render 'admin/download_settings/form_hidden_params' %>
<%= render 'admin/download_settings/form', resource: resource, download_settings: get_attrs(get_model(resource[:name])) %>
<div class="medium-5 column clear end">
<button type="submit" data-close id="js-download-modal-submit" class="button success expanded"><%= t("download.modal.submit") %></button>
</div>
<% end %>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">&times;</span>
</button>
</div>

View File

@@ -0,0 +1,16 @@
<% unless @download_settings.empty? %>
<% provide(:title) do %>
<%= t("admin.header.title") %> - <%= t("download.edit.#{@download_resource[:name]}") %>
<% end %>
<h2><%= t("download.edit.#{@download_resource[:name]}") %> <%= t("download.edit.config.#{@download_resource[:config].to_s}") unless @download_resource[:config] == 0 %></h2>
<%= form_tag admin_update_download_settings_path(resource: @download_resource[:name], config: @download_resource[:config]), method: :put do %>
<%= render 'form', resource: @download_resource, download_settings: @download_settings %>
<div class="small-12 medium-3 column clear end">
<%= submit_tag t("download.edit.submit"), class: "button success expanded" %>
</div>
<% end %>
<% end %>

View File

@@ -9,8 +9,8 @@
<table>
<thead>
<th scope="col" class="small-8"><%= t("admin.shared.description") %></th>
<th scope="col"><%= t("admin.shared.actions") %></th>
<th scope="col" class="small-8"><%= t("admin.shared.description") %></th>
<th scope="col"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @comments.each do |comment| %>
@@ -25,15 +25,15 @@
</td>
<td>
<%= link_to t("admin.actions.restore"),
restore_admin_hidden_comment_path(comment, request.query_parameters),
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
restore_admin_hidden_comment_path(comment, request.query_parameters),
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
<% unless comment.confirmed_hide? %>
<%= link_to t("admin.actions.confirm_hide"),
confirm_hide_admin_hidden_comment_path(comment, request.query_parameters),
method: :put,
class: "button" %>
confirm_hide_admin_hidden_comment_path(comment, request.query_parameters),
method: :put,
class: "button" %>
<% end %>
</td>
</tr>

View File

@@ -9,9 +9,9 @@
<table>
<thead>
<th scope="col"><%= t("admin.shared.title") %></th>
<th scope="col" class="small-6"><%= t("admin.shared.description") %></th>
<th scope="col" class="small-4"><%= t("admin.shared.actions") %></th>
<th scope="col"><%= t("admin.shared.title") %></th>
<th scope="col" class="small-6"><%= t("admin.shared.description") %></th>
<th scope="col" class="small-4"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @debates.each do |debate| %>
@@ -26,15 +26,15 @@
</td>
<td class="align-top">
<%= link_to t("admin.actions.restore"),
restore_admin_hidden_debate_path(debate, request.query_parameters),
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
restore_admin_hidden_debate_path(debate, request.query_parameters),
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
<% unless debate.confirmed_hide? %>
<%= link_to t("admin.actions.confirm_hide"),
confirm_hide_admin_hidden_debate_path(debate, request.query_parameters),
method: :put,
class: "button" %>
confirm_hide_admin_hidden_debate_path(debate, request.query_parameters),
method: :put,
class: "button" %>
<% end %>
</td>
</tr>

View File

@@ -12,6 +12,8 @@
<% if @processes.any? %>
<h3><%= page_entries_info @processes %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.legislation.processes.index.link") %></a>
<table class="stack">
<thead>
<tr>
@@ -50,3 +52,5 @@
<%= page_entries_info @processes %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "legislation_processes" } %>

View File

@@ -7,7 +7,9 @@
<% if @proposals.any? %>
<%= render "/admin/shared/proposal_search", url: admin_proposals_path %>
<h3><%= page_entries_info @proposals %></h3>
<h3 class="inline-block"><%= page_entries_info @proposals %></h3>
<a class="small float-right clear" data-open="download-modal"><%= t("admin.proposals.index.link") %></a>
<table>
<thead>
@@ -39,3 +41,5 @@
<%= t("admin.proposals.index.no_proposals") %>
</div>
<% end %>
<%= render "admin/download_settings/modal", resource: { name: "proposals" } %>

View File

@@ -0,0 +1,10 @@
<%= form_for(Debate.new, url: url, as: :debate, method: :get) do |f| %>
<div class="small-12 medium-6">
<div class="input-group">
<%= text_field_tag :search, "", placeholder: t("admin.shared.debate_search.placeholder") %>
<div class="input-group-button">
<%= f.submit t("admin.shared.debate_search.button"), class: "button" %>
</div>
</div>
</div>
<% end %>

View File

@@ -42,6 +42,10 @@
</div>
<div class="small-12 medium-9 large-10 column">
<%= link_to t("shared.download.link.investments"), current_path_with_query_params(format: :csv),
class: "button hollow margin-bottom margin-right float-right-medium" %>
<%= form_tag(budget_executions_path(@budget), method: :get) do %>
<div class="small-12 medium-3 column">
<%= label_tag :milestone_tag, t("budgets.executions.filters.milestone_tag.label") %>

View File

@@ -48,6 +48,9 @@
data: {"toggle-selector" => ".js-discarded",
"toggle-text" => t("budgets.results.hide_discarded_link")} %>
<%= link_to t("shared.download.link.investments"), current_path_with_query_params(format: :csv),
class: "button hollow margin-bottom margin-right float-right-medium" %>
<%= render "results_table", results_type: :compatible,
title: @heading.name,
heading_price: @heading.price,

View File

@@ -98,6 +98,7 @@
<aside class="margin-bottom">
<%= link_to t("debates.index.start_debate"), new_debate_path, class: "button expanded" %>
<%= render "shared/tag_cloud", taggable: "debate" %>
<%= render "shared/download_links", downloadable: 'debate' %>
</aside>
</div>

View File

@@ -25,6 +25,14 @@
</p>
<p><%= t("legislation.processes.index.section_footer.description") %></p>
</div>
</div>
</div>
<div class="small-12 medium-3 column">
<aside class="margin-bottom">
<%= render "shared/download_links", downloadable: 'legislation_process' %>
</aside>
</div>
</div>

View File

@@ -139,6 +139,7 @@
<% end %>
<%= render "retired" %>
<%= render "proposals_lists" %>
<%= render "shared/download_links", downloadable: "proposal" %>
</aside>
</div>

View File

@@ -0,0 +1,4 @@
<div class="sidebar-divider"></div>
<h2 class="sidebar-title"><%= t("shared.download.title") %></h2>
<p><%= link_to t("shared.download.link.#{downloadable}"), current_path_with_query_params(format: :csv), class: "small" %></p>