Refactoring #43
@ -19,7 +19,7 @@ from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm,
|
||||
NewEcoAccountDocumentForm
|
||||
from compensation.models import EcoAccount, EcoAccountDocument, CompensationState, CompensationAction
|
||||
from compensation.tables import EcoAccountTable
|
||||
from intervention.forms.modalForms import NewDeductionModalForm, ShareInterventionModalForm
|
||||
from intervention.forms.modalForms import NewDeductionModalForm, ShareModalForm
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required, \
|
||||
shared_access_required
|
||||
@ -642,7 +642,7 @@ def create_share_view(request: HttpRequest, id: str):
|
||||
|
||||
"""
|
||||
obj = get_object_or_404(EcoAccount, id=id)
|
||||
form = ShareInterventionModalForm(request.POST or None, instance=obj, request=request)
|
||||
form = ShareModalForm(request.POST or None, instance=obj, request=request)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_success=_("Share settings updated")
|
||||
|
@ -10,11 +10,11 @@ from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm,
|
||||
from compensation.models import CompensationAction, CompensationState
|
||||
from ema.forms import NewEmaForm, EditEmaForm, NewEmaDocumentForm
|
||||
from ema.tables import EmaTable
|
||||
from intervention.forms.modalForms import ShareInterventionModalForm
|
||||
from intervention.forms.modalForms import ShareModalForm
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import conservation_office_group_required, shared_access_required
|
||||
from ema.models import Ema, EmaDocument
|
||||
from konova.forms import RemoveModalForm, NewDocumentForm, SimpleGeomForm, RecordModalForm
|
||||
from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
from konova.utils.documents import get_document, remove_document
|
||||
from konova.utils.generators import generate_qr_code
|
||||
@ -546,7 +546,7 @@ def create_share_view(request: HttpRequest, id: str):
|
||||
|
||||
"""
|
||||
obj = get_object_or_404(Ema, id=id)
|
||||
form = ShareInterventionModalForm(request.POST or None, instance=obj, request=request)
|
||||
form = ShareModalForm(request.POST or None, instance=obj, request=request)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_success=_("Share settings updated")
|
||||
|
@ -20,7 +20,7 @@ from konova.utils.general import format_german_float
|
||||
from konova.utils.user_checks import is_default_group_only
|
||||
|
||||
|
||||
class ShareInterventionModalForm(BaseModalForm):
|
||||
class ShareModalForm(BaseModalForm):
|
||||
url = forms.CharField(
|
||||
label=_("Share link"),
|
||||
label_suffix="",
|
||||
|
@ -284,25 +284,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
||||
)
|
||||
return deduction
|
||||
|
||||
def update_sharing_user(self, form):
|
||||
""" Adds a new user with shared access to the intervention
|
||||
|
||||
Args:
|
||||
form (ShareInterventionModalForm): The form holding the data
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
form_data = form.cleaned_data
|
||||
|
||||
keep_accessing_users = form_data["users"]
|
||||
new_accessing_users = list(form_data["user_select"].values_list("id", flat=True))
|
||||
accessing_users = keep_accessing_users + new_accessing_users
|
||||
users = User.objects.filter(
|
||||
id__in=accessing_users
|
||||
)
|
||||
self.share_with_list(users)
|
||||
|
||||
|
||||
class InterventionDocument(AbstractDocument):
|
||||
"""
|
||||
|
@ -4,7 +4,7 @@ from django.http import HttpRequest, JsonResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
from intervention.forms.forms import NewInterventionForm, EditInterventionForm
|
||||
from intervention.forms.modalForms import ShareInterventionModalForm, NewRevocationModalForm, \
|
||||
from intervention.forms.modalForms import ShareModalForm, NewRevocationModalForm, \
|
||||
CheckModalForm, NewDeductionModalForm, NewInterventionDocumentForm
|
||||
from intervention.models import Intervention, Revocation, InterventionDocument, RevocationDocument
|
||||
from intervention.tables import InterventionTable
|
||||
@ -402,7 +402,7 @@ def create_share_view(request: HttpRequest, id: str):
|
||||
|
||||
"""
|
||||
intervention = get_object_or_404(Intervention, id=id)
|
||||
form = ShareInterventionModalForm(request.POST or None, instance=intervention, request=request, user=request.user)
|
||||
form = ShareModalForm(request.POST or None, instance=intervention, request=request, user=request.user)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_success=_("Share settings updated")
|
||||
|
@ -396,3 +396,22 @@ class ShareableObjectMixin(models.Model):
|
||||
|
||||
"""
|
||||
self.users.set(user_list)
|
||||
|
||||
def update_sharing_user(self, form):
|
||||
""" Adds a new user with shared access to the object
|
||||
|
||||
Args:
|
||||
form (ShareModalForm): The form holding the data
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
form_data = form.cleaned_data
|
||||
|
||||
keep_accessing_users = form_data["users"]
|
||||
new_accessing_users = list(form_data["user_select"].values_list("id", flat=True))
|
||||
accessing_users = keep_accessing_users + new_accessing_users
|
||||
users = User.objects.filter(
|
||||
id__in=accessing_users
|
||||
)
|
||||
self.share_with_list(users)
|
||||
|
Loading…
Reference in New Issue
Block a user