Skip to content
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

Create backend support for soft delete on Components (e.g. Elements) #142

Open
gregelin opened this issue Dec 20, 2021 · 2 comments
Open
Labels
backend Related to backend enhancement New feature or request

Comments

@gregelin
Copy link
Contributor

gregelin commented Dec 20, 2021

Stories

As an admin user, I want to be able to delete components from the component library so that I can I manage outdated components.

Discussion

The purpose of this ticket is to make the database changes, view changes, tests and other backend changes to support "soft-delete" of Components (AKA Elements).

Soft-delete means flagging the instance in the database as being deleted but not removing the data from the database.

Component means a System Element (controls.models.Element) from the Component Library along with all the Component's associated statements (or type control_implementation_prototype and control_implementation), assignments to systems, and other related fields.

Questions to consider:

  • Should component statement's also get a delete flag individually or is it sufficient to know a statement is tied to a component that has a soft-delete?

Branch: component-delete

Components are tracked by the controls.models.Element. Statements associated with components have the relationship producer_elements.

Note that the soft-delete applies to deleting a Component from the Component Library. GovReady-Q already supports removing/deleting a component from a system's list of selected components. Removing a component from a system's list of selected component removes the data from the database of that relationship. (Because the component still exists in the Library, the component can quickly be added back into the list of selected components.)

At this point, only an administrator should have permission to soft-delete a component. We also want to log that a component has been marked deleted.

Why

Creating components involves lots of work. Deleting a component will remove all the statements associated with the component and will orphan all the statements from that component already assigned to systems.

It is better to first mark a component as deleted, then subsequently allow admins to purge deleted components. This allows times to see impact of deletion, allow any effective systems to choose a substitute component, etc.

By having a soft-delete on components, we will retain several UI options for communicating to users that a component has been deleted.

controls.models.Element

  • Add boolean field 'deleted' to element so we can exclude elements that have delete=True
    deleted = models.BooleanField(default=False, help_text="Mark Component as deleted")

controls.models.Statement

  • What statements make assumptions about producer_element?

Misc

  • Create a nice deleted tag (css/glyphicons)
  • Change count of components associated with a selected control in a system to not include statements from component marked as deleted
@gregelin gregelin added enhancement New feature or request backend Related to backend frontend Related to front end labels Dec 20, 2021
@gregelin gregelin changed the title Marke a Component deleted Mark a Component deleted Dec 20, 2021
@gregelin gregelin changed the title Mark a Component deleted Create soft delete on Components (e.g. Elements) Dec 20, 2021
@gregelin gregelin changed the title Create soft delete on Components (e.g. Elements) Create backend support for soft delete on Components (e.g. Elements) Dec 20, 2021
@gregelin gregelin removed the frontend Related to front end label Dec 20, 2021
@gregelin
Copy link
Contributor Author

@alexanderward I updated the this ticket to only focus on the backend changes.

@alexanderward
Copy link
Collaborator

alexanderward commented Jan 3, 2022

controls/components/1

  • Should have a button to delete
  • called mark for deletion
  • should have an optional text field for reason

mark_for_deletion= models.BooleanField(default=False, help_text="Mark Component for deletion")
mark_for_deletion_reason = models.TextField(blank=True, null=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants