86_User_suggestions_and_feedback #111
@ -27,6 +27,9 @@
|
||||
<th scope="col">
|
||||
{% trans 'Title' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Created on' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
@ -41,18 +44,24 @@
|
||||
{% for doc in obj.documents.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'ema:get-doc' doc.id %}">
|
||||
<a href="{% url 'ema:get-doc' obj.id doc.id %}">
|
||||
{{ doc.title }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ doc.date_of_creation }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<div class="scroll-150">
|
||||
{{ doc.comment }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<td class="align-middle float-right">
|
||||
{% 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' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
@ -30,7 +30,8 @@ urlpatterns = [
|
||||
|
||||
# Documents
|
||||
path('<id>/document/new/', document_new_view, name='new-doc'),
|
||||
path('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>', get_document_view, name='get-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.decorators import conservation_office_group_required, shared_access_required
|
||||
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.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
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.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \
|
||||
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
|
||||
|
||||
|
||||
@ -366,18 +367,21 @@ def document_new_view(request: HttpRequest, id: str):
|
||||
|
||||
@login_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
|
||||
|
||||
Wraps the generic document fetcher function 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)
|
||||
user = request.user
|
||||
instance = doc.instance
|
||||
@ -393,18 +397,47 @@ def get_document_view(request: HttpRequest, doc_id: str):
|
||||
|
||||
@login_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
|
||||
|
||||
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)
|
||||
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)
|
||||
return remove_document(
|
||||
request,
|
||||
|
Loading…
Reference in New Issue
Block a user