Import proposals from a spreadsheet#7084
Conversation
|
Hi @lahdeero! Is there any staging where we can test this? Thanks! |
|
Hello @carolromero! Unfortunately not currently, but we have plans to make one. |
I'll create one |
|
|
||
| def call | ||
| return broadcast(:invalid) if form.invalid? | ||
| return broadcast(:invalid) unless form.creator |
There was a problem hiding this comment.
Could this be moved to a form validation?
There was a problem hiding this comment.
Yep. I removed creator check from the command.
|
@decidim/product this can be tested in https://decidim-staging-pr-264.herokuapp.com/ |
|
Hi @lahdeero the import works very well, good job!
Thanks! |
Yes, other creators are expected. For proposals component probably not (maybe for comments), but for budgets for example, we could have separate creators for budgets and projects.
Yep. Added guidance and updated button label. Thanks for the feedback! |
|
@lahdeero some tests seem to be failing after the latest changes, can you check them please? 😄 |
|
@mrcasals Done 😅 |
|
@lahdeero can you redeploy this so @decidim/product can re-review it? 😄 |
|
@mrcasals I haven't created the instance. @oriolgual Can you redeploy please? |
|
Whoops, sorry about that @lahdeero. @decidim/product I've redeployed the app with the latest changes! Give it 15min from now and you should be able to review them 😄 |
|
@mrcasals can't access to the admin panel of the review app. It throws a system error 🤔 |
|
@carolromero solved now, sorry about that! |
|
Hey did a little testing on my end on the link you shared.
|
|
@mrcasals I'm getting the server error as well |
|
@virgile-dev @carolromero sorry, there was an issue with the review app. Should be fixed now! |
|
@mrcasals I'm still getting the server error when accessing the import from file option 😢 |
|
@lahdeero the error we're getting is this: I think you need to either require the file in |
|
Also, some conflicts appeared @lahdeero! |
e349dca to
4ae54e2
Compare
|
I rebased and added |
|
@carolromero can you re-check the review app, please? https://decidim-staging-pr-264.herokuapp.com/ |
|
@mrcasals now it's working great, thanks!
@lahdeero thanks for adding the help on the file format!
Regarding the creator field, we have discussed it with the rest of @decidim/product and we prefer to remove it for now. If in the future there is a need to add it because there are another roles we can discuss it. |
I made it so that if there is less than 2 creators, it doesn't show creator select. Is this ok? @carolromero |
|
@lahdeero sorry to bother you with this but I just don't understand the logic 😢 .
So, for better understanding, could you give me an example of another possible value that could appear in the |
|
Not bothering at all 😊 Clearly there is room for making this more understandable for users. Little bit technical background: I have tried to making this similar to export feature that we can use in all components. In every resource needs to be created differently (purpose of creator class), but the file upload view for example would look like same in every component. Now that I think more about this, maybe this is what it should look like:
It determines (under the hood) which class is responsible for the creating actual resource from parsed data.
We could call it by resource, but if there is more resources (creators before) in same component we would have to change text (dynamically) when we select another resource and that might be confusing for the user as well.
Another value could be Comment creator, if we want to import comments (as we can already export them). That creator we could use with other commentable resources too. Bottom line is that before importing we need to have following information:
Hopefully this clears this at least a bit. @carolromero |
|
Hi @lahdeero, thank you very much for the explanation ❤️!
Understood!
yes, better to leave a generic text then and not the name of the specific resource. Although I am anticipating that the help text in the upload file will have to be dynamic. But we can discuss that when that option is available. Ok, so to move forward with this PR, let's do what you proposed, if there is only one creator it is not shown to the user. It's already working like that, isn't it? |
Yes, help text is dynamic already (not that it really matters yet with just one creator/resource).
Yes, selection is hidden if component has just one creator. Thanks! |
| def call | ||
| return broadcast(:invalid) if form.invalid? | ||
|
|
||
| form.context[:user_group] = user_group |
There was a problem hiding this comment.
I think this should be inside the form, with a def user_group rather than modifying the form from the command
There was a problem hiding this comment.
Yep. Moved user_group assign to the form.
| importer = importer_for(form.file_path, form.mime_type) | ||
| imported_data = importer.prepare | ||
|
|
||
| return broadcast(:invalid_lines, importer.invalid_lines) unless importer.invalid_lines.empty? | ||
|
|
There was a problem hiding this comment.
Maybe consider moving this logic also to the form and adding a validation there?
There was a problem hiding this comment.
Yep. Form validates invalid_lines now.
| include Decidim::ComponentPathHelper | ||
| def new |
There was a problem hiding this comment.
| include Decidim::ComponentPathHelper | |
| def new | |
| include Decidim::ComponentPathHelper | |
| def new |
| include Decidim::ComponentPathHelper | ||
| def new | ||
| enforce_permission_to :import, :component_data, component: current_component | ||
| @import = form(Admin::ImportForm).from_params( |
There was a problem hiding this comment.
I'd rename this to @form so it's easier to udnerstand
| @import = form(Admin::ImportForm).from_params( | |
| @form = form(Admin::ImportForm).from_params( |
There was a problem hiding this comment.
Yep. Renamed import -> form
| def create | ||
| enforce_permission_to :import, :component_data, component: current_component | ||
|
|
||
| @import = form(Admin::ImportForm).from_params( |
| @@ -0,0 +1 @@ | |||
| ,elahdenpera,THINK7,07.01.2021 11:38,file:///home/elahdenpera/.config/libreoffice/4; No newline at end of file | |||
There was a problem hiding this comment.
Should this file be here?



🎩 What? Why?
Non-digital natives and people who don't want their personal information on the internet, tell their ideas (proposals) more preferably to a trusted person. Therefore, admin users want to bulk import paper collected ideas to Decidim. This PR has implementation for importing proposals from files (csv, xls and json). Implementation is similar to export feature and should be easily expandable to other components as well.
📌 Related Issues
https://meta.decidim.org/processes/roadmap/f/122/proposals/14939
Testing
Create a csv or excel spreadsheet with column names title/en and body/en (or another locale which you prefer eg. title/ca and body/ca). Also scope/id and category/id columns are supported. For each row enter valid title and body, then save. After saving the spreadsheet go to -> Admin dashboard -> Processes -> pick process -> Proposals -> Import -> Import from a file -> Browse -> -> Start import -> check out new proposals
📋 Checklist
🚨 Please review the guidelines for contributing to this repository.
docs/.📷 Screenshots
Please add screenshots of the changes you're proposing
