Reviewed-on: SGD-Nord/konova#34
This commit is contained in:
		
						commit
						e2409fdbde
					
				@ -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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								ema/views.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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.")
 | 
			
		||||
@ -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",
 | 
			
		||||
            }
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user