mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Remove relationship to folder when archiving a template
When a template is archived, it should no longer belong to any folder. If we don’t do this it will make it very hard to delete folders later (because folders can only be deleted if they have no templates or folders inside them). We originally tried to check if the link between a template and folder should be removed with `if template.archived and template.folder:` instead of using `if template.archived:`. However, this caused issues because checking `template.folder` flushes the session. Since the session is no longer dirty, the versioning decorator doesn't work as expected and doesn't create a new row in `TemplateHistory`.
This commit is contained in:
@@ -38,6 +38,9 @@ def dao_create_template(template):
|
||||
@transactional
|
||||
@version_class(Template, TemplateHistory)
|
||||
def dao_update_template(template):
|
||||
if template.archived:
|
||||
template.folder = None
|
||||
|
||||
db.session.add(template)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user