#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:
@@ -1,10 +1,11 @@
|
||||
from django.db import models
|
||||
|
||||
from konova.models import UuidModel
|
||||
from konova.models import UuidModel, DeletableObjectMixin
|
||||
from konova.utils.mailer import Mailer
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
|
||||
class Team(UuidModel):
|
||||
class Team(UuidModel, DeletableObjectMixin):
|
||||
""" Groups users in self managed teams. Can be used for multi-sharing of data
|
||||
|
||||
"""
|
||||
@@ -16,6 +17,19 @@ class Team(UuidModel):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def mark_as_deleted(self, user):
|
||||
""" Creates an UserAction entry and stores it in the correct field
|
||||
|
||||
Args:
|
||||
user (User): The performing user
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
delete_action = UserActionLogEntry.get_deleted_action(user, "Team deleted")
|
||||
self.deleted = delete_action
|
||||
self.save()
|
||||
|
||||
def send_mail_shared_access_given_team(self, obj_identifier, obj_title):
|
||||
""" Sends a mail to the team members in case of given shared access
|
||||
|
||||
|
||||
Reference in New Issue
Block a user