diff --git a/compensation/views/compensation_views.py b/compensation/views/compensation_views.py index 5b187501..c7221570 100644 --- a/compensation/views/compensation_views.py +++ b/compensation/views/compensation_views.py @@ -14,7 +14,7 @@ from konova.decorators import * from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm from konova.utils.documents import get_document, remove_document from konova.utils.generators import generate_qr_code -from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED +from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DATA_UNSHARED_EXPLANATION from konova.utils.user_checks import in_group @@ -173,6 +173,9 @@ def detail_view(request: HttpRequest, id: str): sum_after_states = after_states.aggregate(Sum("surface"))["surface__sum"] or 0 diff_states = abs(sum_before_states - sum_after_states) + if not is_data_shared: + messages.info(request, DATA_UNSHARED_EXPLANATION) + context = { "obj": comp, "geom_form": geom_form, @@ -268,6 +271,15 @@ def get_document_view(request: HttpRequest, doc_id: str): """ doc = get_object_or_404(CompensationDocument, id=doc_id) + user = request.user + instance = doc.instance + # File download only possible if related instance is shared with user + if not instance.users.filter(id=user.id): + messages.info( + request, + DATA_UNSHARED + ) + return redirect("compensation:detail", id=instance.id) return get_document(doc) diff --git a/compensation/views/eco_account_views.py b/compensation/views/eco_account_views.py index bb04facb..1ac355fe 100644 --- a/compensation/views/eco_account_views.py +++ b/compensation/views/eco_account_views.py @@ -25,7 +25,7 @@ from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, Recor 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 -from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID +from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION from konova.utils.user_checks import in_group @@ -197,6 +197,9 @@ def detail_view(request: HttpRequest, id: str): ) actions = acc.actions.all() + if not is_data_shared: + messages.info(request, DATA_UNSHARED_EXPLANATION) + context = { "obj": acc, "geom_form": geom_form, @@ -401,6 +404,15 @@ def get_document_view(request: HttpRequest, doc_id: str): """ doc = get_object_or_404(EcoAccountDocument, id=doc_id) + user = request.user + instance = doc.instance + # File download only possible if related instance is shared with user + if not instance.users.filter(id=user.id): + messages.info( + request, + DATA_UNSHARED + ) + return redirect("compensation:acc-detail", id=instance.id) return get_document(doc) diff --git a/ema/views.py b/ema/views.py index a9ad2bdb..1e72e096 100644 --- a/ema/views.py +++ b/ema/views.py @@ -17,7 +17,7 @@ from konova.forms import RemoveModalForm, NewDocumentForm, SimpleGeomForm, Recor 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 -from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID +from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION from konova.utils.user_checks import in_group @@ -136,6 +136,9 @@ def detail_view(request: HttpRequest, id: str): sum_after_states = after_states.aggregate(Sum("surface"))["surface__sum"] or 0 diff_states = abs(sum_before_states - sum_after_states) + if not is_data_shared: + messages.info(request, DATA_UNSHARED_EXPLANATION) + context = { "obj": ema, "geom_form": geom_form, @@ -343,6 +346,15 @@ def get_document_view(request: HttpRequest, doc_id: str): """ doc = get_object_or_404(EmaDocument, id=doc_id) + user = request.user + instance = doc.instance + # File download only possible if related instance is shared with user + if not instance.users.filter(id=user.id): + messages.info( + request, + DATA_UNSHARED + ) + return redirect("ema:detail", id=instance.id) return get_document(doc) diff --git a/intervention/views.py b/intervention/views.py index bd770ce2..c58b03ac 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -14,7 +14,8 @@ from konova.forms import SimpleGeomForm, NewDocumentForm, RemoveModalForm, Recor from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT from konova.utils.documents import remove_document, get_document from konova.utils.generators import generate_qr_code -from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED +from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED, \ + DATA_UNSHARED_EXPLANATION from konova.utils.user_checks import in_group @@ -158,6 +159,15 @@ def get_document_view(request: HttpRequest, doc_id: str): """ doc = get_object_or_404(InterventionDocument, id=doc_id) + user = request.user + instance = doc.instance + # File download only possible if related instance is shared with user + if not instance.users.filter(id=user.id): + messages.info( + request, + DATA_UNSHARED + ) + return redirect("intervention:detail", id=instance.id) return get_document(doc) @@ -234,7 +244,7 @@ def detail_view(request: HttpRequest, id: str): } if not is_data_shared: - messages.info(request, _("Remember: This data has not been shared with you, yet. This means you can only read but can not edit or perform any actions like running a check or recording.")) + messages.info(request, DATA_UNSHARED_EXPLANATION) context = BaseContext(request, context).context return render(request, template, context) diff --git a/konova/utils/message_templates.py b/konova/utils/message_templates.py index e28f39de..502030c4 100644 --- a/konova/utils/message_templates.py +++ b/konova/utils/message_templates.py @@ -13,4 +13,5 @@ PARAMS_INVALID = _("Invalid parameters") INTERVENTION_INVALID = _("There are errors in this intervention.") IDENTIFIER_REPLACED = _("The identifier '{}' had to be changed to '{}' since another entry has been added in the meanwhile, which uses this identifier") DATA_UNSHARED = _("This data is not shared with you") +DATA_UNSHARED_EXPLANATION = _("Remember: This data has not been shared with you, yet. This means you can only read but can not edit or perform any actions like running a check or recording.") MISSING_GROUP_PERMISSION = _("You need to be part of another user group.") \ No newline at end of file diff --git a/user/forms.py b/user/forms.py index aa475566..6d6accbc 100644 --- a/user/forms.py +++ b/user/forms.py @@ -79,7 +79,7 @@ class UserContactForm(BaseModalForm): widget=forms.TextInput( attrs={ "readonly": True, - "style": "width:100%", + "class": "form-control", } ), ) @@ -90,7 +90,7 @@ class UserContactForm(BaseModalForm): widget=forms.TextInput( attrs={ "readonly": True, - "style": "width:100%", + "class": "form-control", } ), ) @@ -101,7 +101,7 @@ class UserContactForm(BaseModalForm): widget=forms.TextInput( attrs={ "readonly": True, - "style": "width:100%", + "class": "form-control", } ), )