Default group required
* adds access checks depending on the current group confgiguration of a user * removes buttons for adding/editing or removing data if default group is not set for a user * removes buttons for adding/removing related data in unshared interventions * removes shared-user setting from share menu of an intervention if user is not zb or ets * renames has_access() from intervention Model into is_shared_with() for more clarity * fixes bug in group check in_group() from utils.py
This commit is contained in:
+17
-12
@@ -18,7 +18,8 @@ from intervention.models import Intervention
|
||||
from konova.enums import UserActionLogEntryEnum
|
||||
from konova.forms import BaseForm, BaseModalForm
|
||||
from konova.models import Document
|
||||
from konova.settings import DEFAULT_LAT, DEFAULT_LON, DEFAULT_ZOOM
|
||||
from konova.settings import DEFAULT_LAT, DEFAULT_LON, DEFAULT_ZOOM, ZB_GROUP, ETS_GROUP
|
||||
from konova.utils.user_checks import in_group
|
||||
from organisation.models import Organisation
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
@@ -293,18 +294,22 @@ class ShareInterventionForm(BaseModalForm):
|
||||
)
|
||||
|
||||
# Initialize users field
|
||||
users = self.instance.users.all()
|
||||
choices = []
|
||||
for n in users:
|
||||
choices.append(
|
||||
(n.id, n.username)
|
||||
# Remove field if user is not in registration or conservation group
|
||||
if not in_group(self.request.user, ZB_GROUP) and not in_group(self.request.user, ETS_GROUP):
|
||||
del self.fields["users"]
|
||||
else:
|
||||
users = self.instance.users.all()
|
||||
choices = []
|
||||
for n in users:
|
||||
choices.append(
|
||||
(n.id, n.username)
|
||||
)
|
||||
self.fields["users"].choices = choices
|
||||
u_ids = list(users.values_list("id", flat=True))
|
||||
self.initialize_form_field(
|
||||
"users",
|
||||
u_ids
|
||||
)
|
||||
self.fields["users"].choices = choices
|
||||
u_ids = list(users.values_list("id", flat=True))
|
||||
self.initialize_form_field(
|
||||
"users",
|
||||
u_ids
|
||||
)
|
||||
|
||||
def save(self):
|
||||
accessing_users = User.objects.filter(
|
||||
|
||||
Reference in New Issue
Block a user