scancode.io icon indicating copy to clipboard operation
scancode.io copied to clipboard

Process deleting projects as background task

Open jayanth-kumar-morem opened this issue 2 years ago • 1 comments

  1. Fix Default Filtering in ProjectFilterSet:

    • Modified the ProjectFilterSet to include is_marked_for_deletion in the default filtering when is_archived is not provided.
    • This ensures that projects marked for deletion are excluded from default views.
  2. Migration for is_marked_for_deletion:

    • Added a migration (0052_project_is_marked_for_deletion.py) to introduce the is_marked_for_deletion field in the Project model.
  3. Updated Project Model:

    • Added is_marked_for_deletion field to the Project model with a default value of False.
  4. Modified ProjectListView to Exclude Marked Projects:

    • Modified the get_queryset method in ProjectListView to only fetch projects with is_marked_for_deletion=False.
  5. Introduced mark_for_deletion Method:

    • Added a mark_for_deletion method in the Project model to set the is_marked_for_deletion flag and save the model.
  6. Changed delete Method in Project Model:

    • Renamed the delete method to delete_action in the Project model to avoid conflicts.
    • Introduced a new delete method that marks the project for deletion and enqueues a background deletion task.
  7. Background Deletion Task:

    • Created a background deletion task using django_rq to 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.
  8. Updated ProjectActionView Success Message:

    • Modified the success message in ProjectActionView for the "delete" action to provide a more informative message based on the count.

Fixes: #1002

jayanth-kumar-morem avatar Jan 26 '24 13:01 jayanth-kumar-morem

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?

pombredanne avatar Feb 26 '24 14:02 pombredanne