Import budgeting projects into accountability results#9604
Import budgeting projects into accountability results#9604ahukkanen merged 43 commits intodecidim:developfrom
Conversation
The imports works with some exceptions: - The system does not check if the record is already exist. - The import don't show how many records are being imported.
Add js functionality, so the number of items to be added is being shown on as the user select the original component for import.
move some shared methods to form section and remove the redundants.
ahukkanen
left a comment
There was a problem hiding this comment.
Overall great work for the first feature PR! Everything works as expected when testing it in the development app.
Regarding the code, I've left some refactoring comments below, can you please go through.
I've also found one bug that the message how many projects are available is not visible if I submit the form and it had errors:

Also, this feels kind of weird as a "success" message:

So can we either
a) change the message to an error message showing something like "There were no projects to import within the selected component"
OR
b) prevent submitting the form in case there are no projects altogether
decidim-accountability/spec/commands/admin/import_projects_to_accountability_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/commands/admin/import_projects_to_accountability_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/commands/admin/import_projects_to_accountability_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/commands/admin/import_projects_to_accountability_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/forms/admin/result_import_projects_form_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/forms/admin/result_import_projects_form_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/permissions/decidim/accountability/admin/permissions_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/system/admin/admin_imports_projects_to_accountability_spec.rb
Show resolved
Hide resolved
|
I found this old bug report regarding the proposal imports (import proposals between components): #7608. I think this is also a relevant point regarding this PR that we should consider here. So, we still need to do the following changes here:
We have similar functionality already in Decidim where you can take inspiration from, such as the CSV import within the same accountability component. The other point about handling long running jobs better mentioned at #7608 is a separate issue and we need to tackle that later on. Right now, just follow what is already being done in other imports that are background processed. |
ahukkanen
left a comment
There was a problem hiding this comment.
It's starting to be pretty close to completed.
A couple of further cleanup efforts + one bugfix still needed I noticed when going through.
...im-accountability/app/controllers/decidim/accountability/admin/projects_import_controller.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/app/forms/decidim/accountability/admin/result_import_projects_form.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/app/packs/src/decidim/accountability/admin/imports.js
Outdated
Show resolved
Hide resolved
decidim-accountability/app/packs/entrypoints/decidim_accountability_admin_imports.js
Outdated
Show resolved
Hide resolved
...ountability/spec/controllers/decidim/accountability/admin/projects_import_controller_spec.rb
Outdated
Show resolved
Hide resolved
decidim-accountability/spec/jobs/decidim/accountability/admin/import_projects_job_spec.rb
Outdated
Show resolved
Hide resolved
ahukkanen
left a comment
There was a problem hiding this comment.
LGTM!
Before merging, we need to go it through and demo it for @decidim/product before we merge it to the core to see if they are happy with the changes.
|
Thanks for the demo @sinaeftekhar! I would only suggest grouping the import options (csv, budgets) in a single drop-down button. Otherwise, looks good to me. |
Thanks @carolromero for the comment. The suggestion has been applied, and is now ready for the review |
ahukkanen
left a comment
There was a problem hiding this comment.
Great!
Just one more request regarding the import dropdown positionning and then I think this is done.
decidim-accountability/app/views/decidim/accountability/admin/results/index.html.erb
Show resolved
Hide resolved
ahukkanen
left a comment
There was a problem hiding this comment.
Great work!
Before merging this, could you @carolromero also confirm that this is now good to go from product standpoint? This is what the requested import dropdown now looks like after the latest changes:

|
@ahukkanen looks great, green light to merge! |
* Import projects without checkpoints The imports works with some exceptions: - The system does not check if the record is already exist. - The import don't show how many records are being imported. * Fix bugs in adding already existing projects twice * Complete import functionality Add js functionality, so the number of items to be added is being shown on as the user select the original component for import. * Add permission to imports * revise en locale for import message * Remove text color when there are projects * Fix a bug in command with current_component * Remove unused methods from the controller * Add tests for commands * Complete tests for commands * Mark unnecessary methods to be removed later * Complete tests for ProjectImportController * Refactor ImportProjectsToResults command move some shared methods to form section and remove the redundants. * Fix some introduced bugs from previous refactoring * Complete form tests * Add permission specs for the feature * Refactor commands; remove extra spaces * Add system test * Show import link only in main page * Fix linting violations * Fix lint violation in imports.js file * Add error when there are no projects to import * Fix lint violations * Address reviewers' comments These changes have been applied: - Redundant testing regrading for the permissions were removed - Messages for the translation has been updated - Extra comments were removed. * Add mailer job to the Imports The import is now being handled with a job, and the user will be informed once the projects are imported. * Fix a bug regarding the translation * Add job to import task The followings are being changes/edited: - The tasks related to import projects moves to the job - Mailer task added to inform the user once the task finished - Fix violated tests, and added required tests - Refactored some parts, with respect to the concept of job * Fix a linting error * Remove unused locales * Fix issues mentioned by reviewer's * Revert package-lock.json * Fix the last set of comments * Fix a typo * Fix errors in pull request failure * Fix a bug in a spec * Resolve issues mentioned by reviewers * Wrap up the import buttons into an 'Import button' * Change the position of import button in the view
🎩 What? Why?
A normal proceeding order in a PB process is:
Right now we can import accepted proposals to projects.
But, we cannot import "selected" projects to results.
This is a problem for admins who prefer not to waste their time doing copy-paste work.
We have added a similar importing feature in the accountability component as we have right now in the budgets component.
The import considers the following:
Above, the "default" status refers to the first status ordered by their progress percentages.
📌 Related Issues
Testing
No prerequisite is needed to run the tests. Run the tests, as if you would normally.
📷 Screenshots
Navigate to the your Accountability component, and click on "Import Projects to Results" link (as shown below)


Now, select the origin component, from which you want to import the selected projects, select "Import all selected projects" and click Import:
Your project is now added to the list with a success message:
