scancode.io
scancode.io copied to clipboard
Process deleting projects as background task
-
Fix Default Filtering in ProjectFilterSet:
- Modified the
ProjectFilterSetto includeis_marked_for_deletionin the default filtering whenis_archivedis not provided. - This ensures that projects marked for deletion are excluded from default views.
- Modified the
-
Migration for
is_marked_for_deletion:- Added a migration (
0052_project_is_marked_for_deletion.py) to introduce theis_marked_for_deletionfield in theProjectmodel.
- Added a migration (
-
Updated
ProjectModel:- Added
is_marked_for_deletionfield to theProjectmodel with a default value ofFalse.
- Added
-
Modified
ProjectListViewto Exclude Marked Projects:- Modified the
get_querysetmethod inProjectListViewto only fetch projects withis_marked_for_deletion=False.
- Modified the
-
Introduced
mark_for_deletionMethod:- Added a
mark_for_deletionmethod in theProjectmodel to set theis_marked_for_deletionflag and save the model.
- Added a
-
Changed
deleteMethod inProjectModel:- Renamed the
deletemethod todelete_actionin theProjectmodel to avoid conflicts. - Introduced a new
deletemethod that marks the project for deletion and enqueues a background deletion task.
- Renamed the
-
Background Deletion Task:
- Created a background deletion task using
django_rqto handle project deletion asynchronously. - Checks if the project is still marked for deletion before proceeding.
- If an error occurs during deletion, updates project status and logs an error.
- Created a background deletion task using
-
Updated
ProjectActionViewSuccess Message:- Modified the success message in
ProjectActionViewfor the "delete" action to provide a more informative message based on the count.
- Modified the success message in
Fixes: #1002
This is a good approach and well explained... it is likely missing not much to get this merged... @jayanth-kumar-morem do you mind looking into some of the comments?