#86 Edit deadlines EcoAccount
* adds support for editing of deadlines in EcoAccount * adds buttons and urls
This commit is contained in:
parent
e3c7a1a274
commit
fe29b7874e
@ -52,9 +52,12 @@
|
||||
{{ deadline.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 'compensation:acc:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal float-right" title="{% trans 'Remove deadline' %}">
|
||||
<button data-form-url="{% url 'compensation:acc: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:acc:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove deadline' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
@ -9,6 +9,7 @@ from django.urls import reverse
|
||||
from django.test import Client
|
||||
|
||||
from compensation.tests.compensation.test_views import CompensationViewTestCase
|
||||
from konova.models import DeadlineType, Deadline
|
||||
from konova.settings import DEFAULT_GROUP
|
||||
|
||||
|
||||
@ -53,7 +54,17 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.action_edit_url = reverse("compensation:acc:action-edit", args=(self.eco_account.id, self.comp_action.id))
|
||||
self.action_remove_url = reverse("compensation:acc:action-remove", args=(self.eco_account.id, self.comp_action.id,))
|
||||
|
||||
self.deadline = Deadline.objects.get_or_create(
|
||||
type=DeadlineType.FINISHED,
|
||||
date="2020-01-01",
|
||||
comment="DEADLINE COMMENT"
|
||||
)[0]
|
||||
self.eco_account.deadlines.add(self.deadline)
|
||||
|
||||
self.deadline_new_url = reverse("compensation:acc:new-deadline", args=(self.eco_account.id,))
|
||||
self.deadline_edit_url = reverse("compensation:acc:deadline-edit", args=(self.eco_account.id, self.deadline.id))
|
||||
self.deadline_remove_url = reverse("compensation:acc:deadline-remove", args=(self.eco_account.id, self.deadline.id))
|
||||
|
||||
self.new_doc_url = reverse("compensation:acc:new-doc", args=(self.eco_account.id,))
|
||||
|
||||
def test_logged_in_no_groups_shared(self):
|
||||
@ -89,6 +100,8 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.action_edit_url,
|
||||
self.action_remove_url,
|
||||
self.deadline_new_url,
|
||||
self.deadline_edit_url,
|
||||
self.deadline_remove_url,
|
||||
self.new_doc_url,
|
||||
]
|
||||
|
||||
@ -128,6 +141,8 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.action_edit_url,
|
||||
self.action_remove_url,
|
||||
self.deadline_new_url,
|
||||
self.deadline_edit_url,
|
||||
self.deadline_remove_url,
|
||||
self.new_doc_url,
|
||||
]
|
||||
|
||||
@ -165,6 +180,8 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.action_remove_url,
|
||||
self.new_doc_url,
|
||||
self.deadline_new_url,
|
||||
self.deadline_edit_url,
|
||||
self.deadline_remove_url,
|
||||
self.log_url,
|
||||
self.remove_url,
|
||||
]
|
||||
@ -204,6 +221,8 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.log_url,
|
||||
self.remove_url,
|
||||
self.deadline_new_url,
|
||||
self.deadline_edit_url,
|
||||
self.deadline_remove_url,
|
||||
]
|
||||
self.assert_url_fail(client, fail_urls)
|
||||
self.assert_url_success(client, success_urls)
|
||||
|
@ -28,8 +28,10 @@ urlpatterns = [
|
||||
path('<id>/action/<action_id>/edit', action_edit_view, name='action-edit'),
|
||||
path('<id>/action/<action_id>/remove', action_remove_view, name='action-remove'),
|
||||
|
||||
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
||||
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>/share/<token>', share_view, name='share'),
|
||||
path('<id>/share', create_share_view, name='share-create'),
|
||||
|
||||
|
@ -17,7 +17,7 @@ from django.shortcuts import render, get_object_or_404, redirect
|
||||
from compensation.forms.forms import NewEcoAccountForm, EditEcoAccountForm
|
||||
from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm, \
|
||||
NewEcoAccountDocumentModalForm, RemoveCompensationActionModalForm, RemoveCompensationStateModalForm, \
|
||||
EditCompensationStateModalForm, EditCompensationActionModalForm
|
||||
EditCompensationStateModalForm, EditCompensationActionModalForm, EditDeadlineModalForm
|
||||
from compensation.models import EcoAccount, EcoAccountDocument, CompensationState, CompensationAction
|
||||
from compensation.tables import EcoAccountTable
|
||||
from intervention.forms.modalForms import NewDeductionModalForm, ShareModalForm, RemoveEcoAccountDeductionModalForm, \
|
||||
@ -35,7 +35,7 @@ from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \
|
||||
CANCEL_ACC_RECORDED_OR_DEDUCTED, DEDUCTION_REMOVED, DEDUCTION_ADDED, DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, \
|
||||
COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED, \
|
||||
DEDUCTION_EDITED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED
|
||||
DEDUCTION_EDITED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED, DEADLINE_EDITED
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
|
||||
@ -515,6 +515,30 @@ def action_edit_view(request: HttpRequest, id: str, action_id: str):
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
@shared_access_required(EcoAccount, "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(EcoAccount, 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:acc:detail", args=(id,)) + "#related_data"
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
@shared_access_required(EcoAccount, "id")
|
||||
|
Loading…
Reference in New Issue
Block a user