#146 Record-unshare with default
* adds automatic unsharing with default-only users if entry is recorded
This commit is contained in:
parent
e029f8c61e
commit
dd0b3c0680
@ -289,6 +289,8 @@ class RecordableObjectMixin(models.Model):
|
||||
from user.models import UserActionLogEntry
|
||||
if self.recorded:
|
||||
return None
|
||||
|
||||
self.unshare_with_default_users()
|
||||
action = UserActionLogEntry.get_recorded_action(user)
|
||||
self.recorded = action
|
||||
self.save()
|
||||
@ -608,6 +610,26 @@ class ShareableObjectMixin(models.Model):
|
||||
"""
|
||||
raise NotImplementedError("Must be implemented in subclasses!")
|
||||
|
||||
def unshare_with_default_users(self):
|
||||
""" Removes all shared users from direct shared access which are only default group users
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
from konova.utils.user_checks import is_default_group_only
|
||||
users = self.shared_users
|
||||
cleaned_users = []
|
||||
default_users = []
|
||||
for user in users:
|
||||
if not is_default_group_only(user):
|
||||
cleaned_users.append(user)
|
||||
else:
|
||||
default_users.append(user)
|
||||
self.share_with_user_list(cleaned_users)
|
||||
|
||||
for user in default_users:
|
||||
celery_send_mail_shared_access_removed.delay(self.identifier, self.title, user.id)
|
||||
|
||||
|
||||
class GeoReferencedMixin(models.Model):
|
||||
geometry = models.ForeignKey("konova.Geometry", null=True, blank=True, on_delete=models.SET_NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user