GovReady / govready-q-private

Other
0 stars 1 forks source link

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

Open gregelin opened 2 years ago

gregelin commented 2 years ago

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:

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

controls.models.Statement

Misc

gregelin commented 2 years ago

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

alexanderward commented 2 years ago

controls/components/1

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