From de8050a8ca08f9420c36f9f7a3552acdd8b6cfb6 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 15 Sep 2025 11:31:05 +0100 Subject: [PATCH] Add author validation in collection_take_start and implement is_author method in AuthorMixin --- atlas/views.py | 3 +++ generic/mixins.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/atlas/views.py b/atlas/views.py index a3426330..8ba8d18b 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -2125,6 +2125,9 @@ def collection_take_start(request, pk, cid=None, passcode=None): valid_user = False #valid_user = collection.check_logged_in_user(request) + if not valid_user and collection.is_author(request.user): + valid_user = True + cid_exam = None diff --git a/generic/mixins.py b/generic/mixins.py index 872a7fd6..99765d4f 100644 --- a/generic/mixins.py +++ b/generic/mixins.py @@ -63,6 +63,10 @@ class AuthorMixin(): """Remove an author from the object""" self.author.remove(user) + def is_author(self, user: User) -> bool: + """Returns True if the user is an author of the object""" + return self.author.filter(id=user.id).exists() + class UserConfigurablePaginationMixin: default_per_page = 25