#86 Edit deadline Compensation
* adds support for editing of deadlines * adds buttons and urls * adds w-10 as base css-class for all action columns
This commit is contained in:
parent
8d396c3e2b
commit
afb0cabec4
@ -35,7 +35,7 @@
|
|||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
{% if is_default_member and has_access %}
|
{% if is_default_member and has_access %}
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -54,9 +54,12 @@
|
|||||||
{{ deadline.comment }}
|
{{ deadline.comment }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<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 'compensation:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal float-right" title="{% trans 'Remove deadline' %}">
|
<button data-form-url="{% url 'compensation:deadline-edit' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit deadline' %}">
|
||||||
|
{% fa5_icon 'edit' %}
|
||||||
|
</button>
|
||||||
|
<button data-form-url="{% url 'compensation:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove deadline' %}">
|
||||||
{% fa5_icon 'trash' %}
|
{% fa5_icon 'trash' %}
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{% trans 'Surface' %}
|
{% trans 'Surface' %}
|
||||||
</th>
|
</th>
|
||||||
{% if is_default_member and has_access %}
|
{% if is_default_member and has_access %}
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{% trans 'Surface' %}
|
{% trans 'Surface' %}
|
||||||
</th>
|
</th>
|
||||||
{% if is_default_member and has_access %}
|
{% if is_default_member and has_access %}
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Created' %}
|
{% trans 'Created' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{% trans 'Surface' %}
|
{% trans 'Surface' %}
|
||||||
</th>
|
</th>
|
||||||
{% if is_default_member and has_access %}
|
{% if is_default_member and has_access %}
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{% trans 'Surface' %}
|
{% trans 'Surface' %}
|
||||||
</th>
|
</th>
|
||||||
{% if is_default_member and has_access %}
|
{% if is_default_member and has_access %}
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -8,6 +8,7 @@ Created on: 07.02.22
|
|||||||
from django.test.client import Client
|
from django.test.client import Client
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from konova.models import Deadline, DeadlineType
|
||||||
from konova.settings import DEFAULT_GROUP
|
from konova.settings import DEFAULT_GROUP
|
||||||
from konova.tests.test_views import BaseViewTestCase
|
from konova.tests.test_views import BaseViewTestCase
|
||||||
|
|
||||||
@ -31,6 +32,13 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
action = self.create_dummy_action()
|
action = self.create_dummy_action()
|
||||||
self.compensation.actions.set([action])
|
self.compensation.actions.set([action])
|
||||||
|
|
||||||
|
self.deadline = Deadline.objects.get_or_create(
|
||||||
|
type=DeadlineType.FINISHED,
|
||||||
|
date="2020-01-01",
|
||||||
|
comment="TESTDEADDLINECOMMENT"
|
||||||
|
)[0]
|
||||||
|
self.compensation.deadlines.add(self.deadline)
|
||||||
|
|
||||||
# Prepare urls
|
# Prepare urls
|
||||||
self.index_url = reverse("compensation:index", args=())
|
self.index_url = reverse("compensation:index", args=())
|
||||||
self.new_url = reverse("compensation:new", args=(self.intervention.id,))
|
self.new_url = reverse("compensation:new", args=(self.intervention.id,))
|
||||||
@ -43,6 +51,8 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
self.state_new_url = reverse("compensation:new-state", args=(self.compensation.id,))
|
self.state_new_url = reverse("compensation:new-state", args=(self.compensation.id,))
|
||||||
self.action_new_url = reverse("compensation:new-action", args=(self.compensation.id,))
|
self.action_new_url = reverse("compensation:new-action", args=(self.compensation.id,))
|
||||||
self.deadline_new_url = reverse("compensation:new-deadline", args=(self.compensation.id,))
|
self.deadline_new_url = reverse("compensation:new-deadline", args=(self.compensation.id,))
|
||||||
|
self.deadline_edit_url = reverse("compensation:deadline-edit", args=(self.compensation.id, self.deadline.id))
|
||||||
|
self.deadline_remove_url = reverse("compensation:deadline-remove", args=(self.compensation.id, self.deadline.id))
|
||||||
self.new_doc_url = reverse("compensation:new-doc", args=(self.compensation.id,))
|
self.new_doc_url = reverse("compensation:new-doc", args=(self.compensation.id,))
|
||||||
|
|
||||||
self.state_remove_url = reverse("compensation:state-remove", args=(self.compensation.id, self.comp_state.id,))
|
self.state_remove_url = reverse("compensation:state-remove", args=(self.compensation.id, self.comp_state.id,))
|
||||||
@ -72,6 +82,8 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
self.state_new_url,
|
self.state_new_url,
|
||||||
self.action_new_url,
|
self.action_new_url,
|
||||||
self.deadline_new_url,
|
self.deadline_new_url,
|
||||||
|
self.deadline_edit_url,
|
||||||
|
self.deadline_remove_url,
|
||||||
self.state_remove_url,
|
self.state_remove_url,
|
||||||
self.action_remove_url,
|
self.action_remove_url,
|
||||||
self.new_doc_url,
|
self.new_doc_url,
|
||||||
@ -109,6 +121,8 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
self.state_new_url,
|
self.state_new_url,
|
||||||
self.action_new_url,
|
self.action_new_url,
|
||||||
self.deadline_new_url,
|
self.deadline_new_url,
|
||||||
|
self.deadline_edit_url,
|
||||||
|
self.deadline_remove_url,
|
||||||
self.state_remove_url,
|
self.state_remove_url,
|
||||||
self.action_remove_url,
|
self.action_remove_url,
|
||||||
self.new_doc_url,
|
self.new_doc_url,
|
||||||
@ -147,6 +161,8 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
self.state_new_url,
|
self.state_new_url,
|
||||||
self.action_new_url,
|
self.action_new_url,
|
||||||
self.deadline_new_url,
|
self.deadline_new_url,
|
||||||
|
self.deadline_edit_url,
|
||||||
|
self.deadline_remove_url,
|
||||||
self.state_remove_url,
|
self.state_remove_url,
|
||||||
self.action_remove_url,
|
self.action_remove_url,
|
||||||
self.new_doc_url,
|
self.new_doc_url,
|
||||||
@ -181,6 +197,8 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
self.state_new_url,
|
self.state_new_url,
|
||||||
self.action_new_url,
|
self.action_new_url,
|
||||||
self.deadline_new_url,
|
self.deadline_new_url,
|
||||||
|
self.deadline_edit_url,
|
||||||
|
self.deadline_remove_url,
|
||||||
self.state_remove_url,
|
self.state_remove_url,
|
||||||
self.action_remove_url,
|
self.action_remove_url,
|
||||||
self.new_doc_url,
|
self.new_doc_url,
|
||||||
@ -217,6 +235,8 @@ class CompensationViewTestCase(BaseViewTestCase):
|
|||||||
self.state_new_url,
|
self.state_new_url,
|
||||||
self.action_new_url,
|
self.action_new_url,
|
||||||
self.deadline_new_url,
|
self.deadline_new_url,
|
||||||
|
self.deadline_edit_url,
|
||||||
|
self.deadline_remove_url,
|
||||||
self.state_remove_url,
|
self.state_remove_url,
|
||||||
self.action_remove_url,
|
self.action_remove_url,
|
||||||
self.new_doc_url,
|
self.new_doc_url,
|
||||||
|
@ -28,6 +28,7 @@ urlpatterns = [
|
|||||||
path('<id>/action/<action_id>/remove', action_remove_view, name='action-remove'),
|
path('<id>/action/<action_id>/remove', action_remove_view, name='action-remove'),
|
||||||
|
|
||||||
path('<id>/deadline/new', deadline_new_view, name="new-deadline"),
|
path('<id>/deadline/new', deadline_new_view, name="new-deadline"),
|
||||||
|
path('<id>/deadline/<deadline_id>/edit', deadline_edit_view, name='deadline-edit'),
|
||||||
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from compensation.forms.forms import NewCompensationForm, EditCompensationForm
|
from compensation.forms.forms import NewCompensationForm, EditCompensationForm
|
||||||
from compensation.forms.modalForms import NewStateModalForm, NewDeadlineModalForm, NewActionModalForm, \
|
from compensation.forms.modalForms import NewStateModalForm, NewDeadlineModalForm, NewActionModalForm, \
|
||||||
NewCompensationDocumentModalForm, RemoveCompensationActionModalForm, RemoveCompensationStateModalForm, \
|
NewCompensationDocumentModalForm, RemoveCompensationActionModalForm, RemoveCompensationStateModalForm, \
|
||||||
EditCompensationStateModalForm, EditCompensationActionModalForm
|
EditCompensationStateModalForm, EditCompensationActionModalForm, EditDeadlineModalForm
|
||||||
from compensation.models import Compensation, CompensationState, CompensationAction, CompensationDocument
|
from compensation.models import Compensation, CompensationState, CompensationAction, CompensationDocument
|
||||||
from compensation.tables import CompensationTable
|
from compensation.tables import CompensationTable
|
||||||
from intervention.models import Intervention
|
from intervention.models import Intervention
|
||||||
@ -21,7 +21,8 @@ from konova.utils.generators import generate_qr_code
|
|||||||
from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DATA_UNSHARED_EXPLANATION, \
|
from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DATA_UNSHARED_EXPLANATION, \
|
||||||
CHECKED_RECORDED_RESET, COMPENSATION_ADDED_TEMPLATE, COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED, \
|
CHECKED_RECORDED_RESET, COMPENSATION_ADDED_TEMPLATE, COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED, \
|
||||||
COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, \
|
COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, \
|
||||||
DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED
|
DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED, \
|
||||||
|
DEADLINE_EDITED
|
||||||
from konova.utils.user_checks import in_group
|
from konova.utils.user_checks import in_group
|
||||||
|
|
||||||
|
|
||||||
@ -446,6 +447,30 @@ def deadline_new_view(request: HttpRequest, id: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@default_group_required
|
||||||
|
@shared_access_required(Compensation, "id")
|
||||||
|
def deadline_edit_view(request: HttpRequest, id: str, deadline_id: str):
|
||||||
|
""" Renders a form for editing deadlines from a compensation
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): The compensation's id
|
||||||
|
deadline_id (str): The deadline's id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
comp = get_object_or_404(Compensation, id=id)
|
||||||
|
deadline = get_object_or_404(Deadline, id=deadline_id)
|
||||||
|
form = EditDeadlineModalForm(request.POST or None, instance=comp, deadline=deadline, request=request)
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
msg_success=DEADLINE_EDITED,
|
||||||
|
redirect_url=reverse("compensation:detail", args=(id,)) + "#related_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@default_group_required
|
@default_group_required
|
||||||
@shared_access_required(Compensation, "id")
|
@shared_access_required(Compensation, "id")
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Comment' %}
|
{% trans 'Comment' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Surface' %}
|
{% trans 'Surface' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<th scope="col">
|
<th scope="col">
|
||||||
{% trans 'Surface' %}
|
{% trans 'Surface' %}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
<th class="w-10" scope="col">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{% trans 'Action' %}
|
{% trans 'Action' %}
|
||||||
</span>
|
</span>
|
||||||
|
@ -63,11 +63,11 @@ class EmaViewTestCase(CompensationViewTestCase):
|
|||||||
self.action_edit_url = reverse("ema:action-edit", args=(self.ema.id, action.id))
|
self.action_edit_url = reverse("ema:action-edit", args=(self.ema.id, action.id))
|
||||||
self.action_remove_url = reverse("ema:action-remove", args=(self.ema.id, action.id,))
|
self.action_remove_url = reverse("ema:action-remove", args=(self.ema.id, action.id,))
|
||||||
|
|
||||||
self.deadline = Deadline.objects.create(
|
self.deadline = Deadline.objects.get_or_create(
|
||||||
type=DeadlineType.FINISHED,
|
type=DeadlineType.FINISHED,
|
||||||
date="2020-01-01",
|
date="2020-01-01",
|
||||||
comment="TESTCOMMENT",
|
comment="TESTCOMMENT",
|
||||||
)
|
)[0]
|
||||||
self.ema.deadlines.add(self.deadline)
|
self.ema.deadlines.add(self.deadline)
|
||||||
|
|
||||||
self.deadline_new_url = reverse("ema:new-deadline", args=(self.ema.id,))
|
self.deadline_new_url = reverse("ema:new-deadline", args=(self.ema.id,))
|
||||||
|
Loading…
Reference in New Issue
Block a user