-
Notifications
You must be signed in to change notification settings - Fork 2
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
Export consultation results to CSV #42
Conversation
This exports it following the exact same table format we render in the page that includes membership data. It adheres to Decidim's exporter's conventions which send an email with a zip containing the CSV file.
app/controllers/decidim/action_delegator/admin/exports_controller.rb
Outdated
Show resolved
Hide resolved
app/jobs/decidim/action_delegator/export_consultation_results_job.rb
Outdated
Show resolved
Hide resolved
app/jobs/decidim/action_delegator/export_consultation_results_job.rb
Outdated
Show resolved
Hide resolved
app/controllers/decidim/action_delegator/admin/exports_controller.rb
Outdated
Show resolved
Hide resolved
app/views/decidim/consultations/admin/consultations/results.html.erb
Outdated
Show resolved
Hide resolved
90db955
to
6ed4c1e
Compare
The goal is to avoid devs thinking that this is a generic controller that deals with all kinds of exports.
So we don't end up with an N+1.
b881752
to
c453152
Compare
c453152
to
008a044
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sauloperez, great job! 🌟 I left some suggestions (most of them concerning style) though everything looks good to me (after a painful setup of the environment required to test it 😭).
app/jobs/decidim/action_delegator/export_consultation_results_job.rb
Outdated
Show resolved
Hide resolved
app/queries/decidim/action_delegator/responses_by_membership.rb
Outdated
Show resolved
Hide resolved
app/views/decidim/consultations/admin/consultations/results.html.erb
Outdated
Show resolved
Hide resolved
c621ad2
to
f68e9c6
Compare
This way users will have a named in Catalan which will be more user friendly for them.
f68e9c6
to
f51d063
Compare
And reuse a single action. The meaning is the same.
@@ -7,6 +7,13 @@ | |||
/ | |||
<%= t "decidim.admin.consultations.results.participants", count: current_consultation.total_participants %> | |||
</span> | |||
<span id="export-consultation-results" class="button--title"> | |||
<% if allowed_to?(:export_consultation_results, :consultation, { consultation: current_consultation }, [::Decidim::ActionDelegator::Permissions]) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is yet another example of what we need to solve in #24. Permissions are increasingly growing in complexity and that hampers changeability.
In this case, because the controller is on Decidim's core, it does not return our permissions chain, using Decidim::Consultations::Permissions
to handle :export_consultation_results
.
I'll move on with this and fix it in #24
This exports the consultation's results following the exact same table format we render on the page that includes membership data.
It adheres to Decidim's exporter's conventions which send an email with a zip containing the CSV file. Note it also allows you to translate the filename 👌 Thanks @verarojman !
📸
Table
with unpublished results
with published results
Email with 📎
CSV file
Missing