#101 Team sharing form
* adds team sharing field to share form * splits sharing logic into user based and teams based * adds TeamAdmin for admin backend * adds validity check on Team name -> only unused names shall be valid
This commit is contained in:
@@ -253,7 +253,7 @@ class NewInterventionForm(BaseForm):
|
||||
intervention.log.add(action)
|
||||
|
||||
# Add the performing user as the first user having access to the data
|
||||
intervention.share_with(user)
|
||||
intervention.share_with_user(user)
|
||||
return intervention
|
||||
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ class ShareModalForm(BaseModalForm):
|
||||
|
||||
def _add_teams_to_field(self):
|
||||
form_data = {
|
||||
"teams": []
|
||||
"team_select": self.instance.teams.all()
|
||||
}
|
||||
self.load_initial_data(form_data)
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to default group
|
||||
default_group = Group.objects.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([default_group])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -190,7 +190,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to default group
|
||||
default_group = Group.objects.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([default_group])
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -236,7 +236,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to zb group
|
||||
zb_group = self.groups.get(name=ZB_GROUP)
|
||||
self.superuser.groups.set([zb_group])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -282,7 +282,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to zb group
|
||||
zb_group = self.groups.get(name=ZB_GROUP)
|
||||
self.superuser.groups.set([zb_group])
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -328,7 +328,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to ets group
|
||||
ets_group = Group.objects.get(name=ETS_GROUP)
|
||||
self.superuser.groups.set([ets_group])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -374,7 +374,7 @@ class InterventionViewTestCase(BaseViewTestCase):
|
||||
# Add user to default group
|
||||
ets_group = Group.objects.get(name=ETS_GROUP)
|
||||
self.superuser.groups.set([ets_group])
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
|
||||
@@ -30,7 +30,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
super().setUp()
|
||||
# Recreate a new (bare minimum) intervention before each test
|
||||
self.intervention = self.create_dummy_intervention()
|
||||
self.intervention.share_with(self.superuser)
|
||||
self.intervention.share_with_user(self.superuser)
|
||||
|
||||
def test_new(self):
|
||||
"""
|
||||
@@ -365,7 +365,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase):
|
||||
if self.eco_account.recorded is None:
|
||||
rec_action = UserActionLogEntry.get_recorded_action(self.superuser)
|
||||
self.eco_account.recorded = rec_action
|
||||
self.eco_account.share_with_list([self.superuser])
|
||||
self.eco_account.share_with_user_list([self.superuser])
|
||||
self.eco_account.save()
|
||||
num_all_deducs = EcoAccountDeduction.objects.count()
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@ def share_view(request: HttpRequest, id: str, token: str):
|
||||
request,
|
||||
_("{} has been shared with you").format(intervention.identifier)
|
||||
)
|
||||
intervention.share_with(user)
|
||||
intervention.share_with_user(user)
|
||||
return redirect("intervention:detail", id=id)
|
||||
else:
|
||||
messages.error(
|
||||
|
||||
Reference in New Issue
Block a user