#169 Team delete-restore

* adds restorable delete functionality to Team model
* refactors minor code model parts by introducing DeletableObjectMixin
* only non-deleted Teams can be chosen for sharing
* deleted Teams can be restored using the proper function on the backend admin
* deleted Teams do not provide
* adds migration
This commit is contained in:
2022-05-30 15:38:16 +02:00
parent 8aa3fbd97a
commit e7031d0bc2
13 changed files with 111 additions and 35 deletions
+5 -1
View File
@@ -230,8 +230,8 @@ class NewTeamModalForm(BaseModalForm):
team = Team.objects.create(
name=self.cleaned_data.get("name", None),
description=self.cleaned_data.get("description", None),
admins__in=[self.user],
)
team.admins.add(self.user)
members = self.cleaned_data.get("members", User.objects.none())
if self.user.id not in members:
members = members.union(
@@ -335,6 +335,10 @@ class RemoveTeamModalForm(RemoveModalForm):
super().__init__(*args, **kwargs)
self.form_caption = _("ATTENTION!\n\nRemoving the team means all members will lose their access to data, based on this team! \n\nAre you sure to remove this team?")
def save(self):
self.instance.mark_as_deleted(self.user)
return self.instance
class LeaveTeamModalForm(RemoveModalForm):
def __init__(self, *args, **kwargs):