parent
a385420c57
commit
fce85690b7
@ -27,6 +27,9 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Title' %}
|
{% trans 'Title' %}
|
||||||
</th>
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
{% trans 'Created on' %}
|
||||||
|
</th>
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
@ -41,18 +44,24 @@
|
|||||||
{% for doc in obj.documents.all %}
|
{% for doc in obj.documents.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<a href="{% url 'ema:get-doc' doc.id %}">
|
<a href="{% url 'ema:get-doc' obj.id doc.id %}">
|
||||||
{{ doc.title }}
|
{{ doc.title }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
{{ doc.date_of_creation }}
|
||||||
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<div class="scroll-150">
|
<div class="scroll-150">
|
||||||
{{ doc.comment }}
|
{{ doc.comment }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle float-right">
|
||||||
{% if is_default_member and has_access %}
|
{% if is_default_member and has_access %}
|
||||||
<button data-form-url="{% url 'ema:remove-doc' doc.id %}" class="btn btn-default btn-modal float-right" title="{% trans 'Remove document' %}">
|
<button data-form-url="{% url 'ema:edit-doc' obj.id doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit document' %}">
|
||||||
|
{% fa5_icon 'edit' %}
|
||||||
|
</button>
|
||||||
|
<button data-form-url="{% url 'ema:remove-doc' obj.id doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
|
||||||
{% fa5_icon 'trash' %}
|
{% fa5_icon 'trash' %}
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -30,7 +30,8 @@ urlpatterns = [
|
|||||||
|
|
||||||
# Documents
|
# Documents
|
||||||
path('<id>/document/new/', document_new_view, name='new-doc'),
|
path('<id>/document/new/', document_new_view, name='new-doc'),
|
||||||
path('document/<doc_id>', get_document_view, name='get-doc'),
|
path('<id>/document/<doc_id>', get_document_view, name='get-doc'),
|
||||||
path('document/<doc_id>/remove/', remove_document_view, name='remove-doc'),
|
path('<id>/document/<doc_id>/edit/', edit_document_view, name='edit-doc'),
|
||||||
|
path('<id>/document/<doc_id>/remove/', remove_document_view, name='remove-doc'),
|
||||||
|
|
||||||
]
|
]
|
41
ema/views.py
41
ema/views.py
@ -15,7 +15,8 @@ from intervention.forms.modalForms import ShareModalForm
|
|||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.decorators import conservation_office_group_required, shared_access_required
|
from konova.decorators import conservation_office_group_required, shared_access_required
|
||||||
from ema.models import Ema, EmaDocument
|
from ema.models import Ema, EmaDocument
|
||||||
from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm, RemoveDeadlineModalForm
|
from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm, RemoveDeadlineModalForm, \
|
||||||
|
EditDocumentModalForm
|
||||||
from konova.models import Deadline
|
from konova.models import Deadline
|
||||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||||
@ -23,7 +24,7 @@ from konova.utils.documents import get_document, remove_document
|
|||||||
from konova.utils.generators import generate_qr_code
|
from konova.utils.generators import generate_qr_code
|
||||||
from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \
|
from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \
|
||||||
DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, \
|
DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, \
|
||||||
COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED
|
COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED
|
||||||
from konova.utils.user_checks import in_group
|
from konova.utils.user_checks import in_group
|
||||||
|
|
||||||
|
|
||||||
@ -366,18 +367,21 @@ def document_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@conservation_office_group_required
|
@conservation_office_group_required
|
||||||
def get_document_view(request: HttpRequest, doc_id: str):
|
@shared_access_required(Ema, "id")
|
||||||
|
def get_document_view(request: HttpRequest, id: str, doc_id: str):
|
||||||
""" Returns the document as downloadable file
|
""" Returns the document as downloadable file
|
||||||
|
|
||||||
Wraps the generic document fetcher function from konova.utils.
|
Wraps the generic document fetcher function from konova.utils.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request (HttpRequest): The incoming request
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): The EMA id
|
||||||
doc_id (str): The document id
|
doc_id (str): The document id
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
ema = get_object_or_404(Ema, id=id)
|
||||||
doc = get_object_or_404(EmaDocument, id=doc_id)
|
doc = get_object_or_404(EmaDocument, id=doc_id)
|
||||||
user = request.user
|
user = request.user
|
||||||
instance = doc.instance
|
instance = doc.instance
|
||||||
@ -393,18 +397,47 @@ def get_document_view(request: HttpRequest, doc_id: str):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@conservation_office_group_required
|
@conservation_office_group_required
|
||||||
def remove_document_view(request: HttpRequest, doc_id: str):
|
@shared_access_required(Ema, "id")
|
||||||
|
def edit_document_view(request: HttpRequest, id: str, doc_id: str):
|
||||||
""" Removes the document from the database and file system
|
""" Removes the document from the database and file system
|
||||||
|
|
||||||
Wraps the generic functionality from konova.utils.
|
Wraps the generic functionality from konova.utils.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request (HttpRequest): The incoming request
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): The EMA id
|
||||||
doc_id (str): The document id
|
doc_id (str): The document id
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
ema = get_object_or_404(Ema, id=id)
|
||||||
|
doc = get_object_or_404(EmaDocument, id=doc_id)
|
||||||
|
form = EditDocumentModalForm(request.POST or None, request.FILES or None, instance=ema, document=doc, request=request)
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
DOCUMENT_EDITED,
|
||||||
|
reverse("ema:detail", args=(id,)) + "#related_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@conservation_office_group_required
|
||||||
|
@shared_access_required(Ema, "id")
|
||||||
|
def remove_document_view(request: HttpRequest, id:str, doc_id: str):
|
||||||
|
""" Removes the document from the database and file system
|
||||||
|
|
||||||
|
Wraps the generic functionality from konova.utils.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): The EMA id
|
||||||
|
doc_id (str): The document id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
ema = get_object_or_404(Ema, id=id)
|
||||||
doc = get_object_or_404(EmaDocument, id=doc_id)
|
doc = get_object_or_404(EmaDocument, id=doc_id)
|
||||||
return remove_document(
|
return remove_document(
|
||||||
request,
|
request,
|
||||||
|
Loading…
Reference in New Issue
Block a user