#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:
@@ -400,7 +400,7 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
||||
comment=comment,
|
||||
legal=legal
|
||||
)
|
||||
acc.share_with(user)
|
||||
acc.share_with_user(user)
|
||||
|
||||
# Add the log entry to the main objects log list
|
||||
acc.log.add(action)
|
||||
|
||||
@@ -103,7 +103,7 @@ class CompensationViewTestCase(BaseViewTestCase):
|
||||
client = Client()
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
self.superuser.groups.set([])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
# Since the user has no groups, it does not matter that data has been shared. There SHOULD not be any difference
|
||||
# to a user without access, since the important permissions are missing
|
||||
@@ -143,7 +143,7 @@ class CompensationViewTestCase(BaseViewTestCase):
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
self.superuser.groups.set([])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
# Since the user has no groups, it does not matter that data is unshared. There SHOULD not be any difference
|
||||
# to a user having shared access, since all important permissions are missing
|
||||
@@ -185,7 +185,7 @@ class CompensationViewTestCase(BaseViewTestCase):
|
||||
group = self.groups.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([group])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -221,7 +221,7 @@ class CompensationViewTestCase(BaseViewTestCase):
|
||||
group = self.groups.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([group])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
|
||||
@@ -25,7 +25,7 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
|
||||
super().setUp()
|
||||
|
||||
# Give the user shared access to the dummy intervention -> inherits the access to the compensation
|
||||
self.intervention.share_with(self.superuser)
|
||||
self.intervention.share_with_user(self.superuser)
|
||||
|
||||
# Make sure the intervention itself would be fine with valid data
|
||||
self.intervention = self.fill_out_intervention(self.intervention)
|
||||
|
||||
@@ -78,7 +78,7 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
client = Client()
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
self.superuser.groups.set([])
|
||||
self.eco_account.share_with_list([self.superuser])
|
||||
self.eco_account.share_with_user_list([self.superuser])
|
||||
|
||||
# Since the user has no groups, it does not matter that data has been shared. There SHOULD not be any difference
|
||||
# to a user without access, since the important permissions are missing
|
||||
@@ -119,7 +119,7 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
client = Client()
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
self.superuser.groups.set([])
|
||||
self.eco_account.share_with_list([])
|
||||
self.eco_account.share_with_user_list([])
|
||||
|
||||
# Since the user has no groups, it does not matter that data is unshared. There SHOULD not be any difference
|
||||
# to a user having shared access, since all important permissions are missing
|
||||
@@ -163,7 +163,7 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
group = self.groups.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([group])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.eco_account.share_with_list([self.superuser])
|
||||
self.eco_account.share_with_user_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
@@ -200,7 +200,7 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
group = self.groups.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([group])
|
||||
self.eco_account.share_with_list([])
|
||||
self.eco_account.share_with_user_list([])
|
||||
|
||||
success_urls = [
|
||||
self.index_url,
|
||||
|
||||
@@ -27,7 +27,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
# Add user to conservation office group and give shared access to the account
|
||||
self.superuser.groups.add(self.groups.get(name=DEFAULT_GROUP))
|
||||
self.superuser.groups.add(self.groups.get(name=ETS_GROUP))
|
||||
self.eco_account.share_with_list([self.superuser])
|
||||
self.eco_account.share_with_user_list([self.superuser])
|
||||
|
||||
def test_new(self):
|
||||
""" Test the creation of an EcoAccount
|
||||
@@ -73,7 +73,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.eco_account.share_with(self.superuser)
|
||||
self.eco_account.share_with_user(self.superuser)
|
||||
|
||||
url = reverse("compensation:acc:edit", args=(self.eco_account.id,))
|
||||
pre_edit_log_count = self.eco_account.log.count()
|
||||
@@ -129,7 +129,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
|
||||
"""
|
||||
# Add proper privilege for the user
|
||||
self.eco_account.share_with(self.superuser)
|
||||
self.eco_account.share_with_user(self.superuser)
|
||||
pre_record_log_count = self.eco_account.log.count()
|
||||
|
||||
# Prepare url and form data
|
||||
@@ -178,7 +178,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
|
||||
"""
|
||||
# Give user shared access to the dummy intervention, which will be needed here
|
||||
self.intervention.share_with(self.superuser)
|
||||
self.intervention.share_with_user(self.superuser)
|
||||
pre_deduction_acc_log_count = self.eco_account.log.count()
|
||||
pre_deduction_int_log_count = self.intervention.log.count()
|
||||
|
||||
@@ -231,7 +231,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
def test_edit_deduction(self):
|
||||
test_surface = self.eco_account.get_available_rest()[0]
|
||||
self.eco_account.set_recorded(self.superuser)
|
||||
self.intervention.share_with(self.superuser)
|
||||
self.intervention.share_with_user(self.superuser)
|
||||
self.eco_account.refresh_from_db()
|
||||
self.assertIn(self.superuser, self.intervention.is_shared_with(self.superuser))
|
||||
|
||||
@@ -281,8 +281,8 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
"confirm": True,
|
||||
}
|
||||
|
||||
intervention.share_with(self.superuser)
|
||||
account.share_with(self.superuser)
|
||||
intervention.share_with_user(self.superuser)
|
||||
account.share_with_user(self.superuser)
|
||||
|
||||
pre_edit_intervention_log_count = intervention.log.count()
|
||||
pre_edit_account_log_count = account.log.count()
|
||||
|
||||
@@ -64,7 +64,7 @@ class PaymentViewTestCase(BaseViewTestCase):
|
||||
client = Client()
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
self.superuser.groups.set([])
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
# Since the user has no groups, it does not matter that data has been shared. There SHOULD not be any difference
|
||||
# to a user without access, since the important permissions are missing
|
||||
@@ -91,7 +91,7 @@ class PaymentViewTestCase(BaseViewTestCase):
|
||||
client.login(username=self.superuser.username, password=self.superuser_pw)
|
||||
self.superuser.groups.set([])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
# Since the user has no groups, it does not matter that data is unshared. There SHOULD not be any difference
|
||||
# to a user having shared access, since all important permissions are missing
|
||||
@@ -120,7 +120,7 @@ class PaymentViewTestCase(BaseViewTestCase):
|
||||
group = self.groups.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([group])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.intervention.share_with_list([self.superuser])
|
||||
self.intervention.share_with_user_list([self.superuser])
|
||||
|
||||
success_urls = [
|
||||
self.new_url,
|
||||
@@ -143,7 +143,7 @@ class PaymentViewTestCase(BaseViewTestCase):
|
||||
group = self.groups.get(name=DEFAULT_GROUP)
|
||||
self.superuser.groups.set([group])
|
||||
# Sharing is inherited by base intervention for compensation. Therefore configure the interventions share state
|
||||
self.intervention.share_with_list([])
|
||||
self.intervention.share_with_user_list([])
|
||||
|
||||
success_urls = [
|
||||
]
|
||||
|
||||
@@ -21,7 +21,7 @@ class PaymentWorkflowTestCase(BaseWorkflowTestCase):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
# Give the user shared access to the dummy intervention
|
||||
self.intervention.share_with(self.superuser)
|
||||
self.intervention.share_with_user(self.superuser)
|
||||
|
||||
self.payment = Payment.objects.get_or_create(
|
||||
intervention=self.intervention,
|
||||
|
||||
@@ -796,7 +796,7 @@ def share_view(request: HttpRequest, id: str, token: str):
|
||||
request,
|
||||
_("{} has been shared with you").format(obj.identifier)
|
||||
)
|
||||
obj.share_with(user)
|
||||
obj.share_with_user(user)
|
||||
return redirect("compensation:acc:detail", id=id)
|
||||
else:
|
||||
messages.error(
|
||||
|
||||
Reference in New Issue
Block a user