diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/templates/organisations/organisation_detail.html | 21 | ||||
-rw-r--r-- | ctrack/register/forms.py | 2 | ||||
-rw-r--r-- | ctrack/register/templates/register/engagementevent_confirm_delete.html | 14 | ||||
-rw-r--r-- | ctrack/register/urls.py | 7 | ||||
-rw-r--r-- | ctrack/register/views.py | 18 |
5 files changed, 45 insertions, 17 deletions
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html index 97f7429..d1dbd2c 100644 --- a/ctrack/organisations/templates/organisations/organisation_detail.html +++ b/ctrack/organisations/templates/organisations/organisation_detail.html @@ -134,9 +134,7 @@ <div class="col-md-12 my-2"> <div class="card bg-light"> <div class="card-body"> - <div class="card-title" style="font-size: 1.1rem;">CAFs <a href="#" - class="btn btn-outline-primary btn-sm float-right">Add - new...</a></div> + <div class="card-title" style="font-size: 1.1rem;">CAFs <a href="#" class="btn btn-outline-primary btn-sm float-right">Add new...</a></div> <div class="table-responsive"> <table class="table table-sm table-bordered"> <thead> @@ -200,9 +198,9 @@ <div class="col-md-12 my-2"> <div class="card bg-light"> <div class="card-body"> - <div class="card-title" style="font-size: 1.1rem;">Engagements & Compliance Events<a href="{% url "register:create" object.slug %}" - class="btn btn-outline-primary btn-sm float-right">Add - new...</a></div> + <div class="card-title" style="font-size: 1.1rem;"> + Engagements & Compliance Events + <a href="{% url "register:create" object.slug %}" class="btn btn-outline-primary btn-sm float-right">Add new...</a></div> <div class="table table-responsive"> <table class="table table-sm table-bordered"> <thead> @@ -213,14 +211,15 @@ <th>CAF</th> <th>Response Requested</th> <th>Response Due</th> + <th>Actions</th> </tr> </thead> {% if engagement_events|length > 0 %} {% for event in engagement_events %} <tr> - <td>{{ event.date |date:"D d M Y H:i" }}</td> - <td><a href="#">{{ event.type }}</a></td> - <td>{{ event.short_description }}</td> + <td>{{ event.date |date:"d M Y H:i" }}</td> + <td>{{ event.type }}</td> + <td><a href="#">{{ event.short_description }}</a></td> {% if event.related_caf %} <td><a href="{% url "caf:detail" event.related_caf.id %}">{{ event.related_caf }}</a></td> {% else %} @@ -240,11 +239,9 @@ <td>NA</td> {% endif %} {% endif %} + <td><a class="btn btn-sm btn-outline-primary" href="#" role="button">Edit</a> <a href="{% url "register:ee_delete" event.pk object.slug %}" class="btn btn-sm btn-outline-danger" role="button">Delete</a></td> </tr> {% endfor %} - {% else %} - <a class="btn btn-outline-primary btn-sm" href="{% url "register:create" object.slug %}" role="button">Add - new...</a> {% endif %} </table> </div> diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index 308a7e0..ee50a71 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -54,5 +54,7 @@ class EngagementEventCreateForm(forms.ModelForm): exclude = ["user"] widgets = { "date": forms.DateTimeInput(attrs={"type": "date"}), + "response_date_requested": forms.DateTimeInput(attrs={"type": "date"}), + "response_received": forms.DateTimeInput(attrs={"type": "date"}), "end_date": forms.DateTimeInput(attrs={"type": "date"}), } diff --git a/ctrack/register/templates/register/engagementevent_confirm_delete.html b/ctrack/register/templates/register/engagementevent_confirm_delete.html new file mode 100644 index 0000000..20aec9e --- /dev/null +++ b/ctrack/register/templates/register/engagementevent_confirm_delete.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %} + Confirm Deletion +{% endblock title %} + +{% load crispy_forms_tags %} + +{% block content %} + <form method="post">{% csrf_token %} + <p>Are you sure you want to delete "{{ object }}"?</p> + <input type="submit" value="Confirm"> +</form> +{% endblock content %} diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py index ce8c9fd..b650402 100644 --- a/ctrack/register/urls.py +++ b/ctrack/register/urls.py @@ -1,11 +1,14 @@ from django.urls import path -from ctrack.register.views import EngagementEventCreate +from ctrack.register.views import EngagementEventCreate, EngagementEventDelete app_name = "register" urlpatterns = [ path( - "engagement-event/create/from-org/<slug:slug>", view=EngagementEventCreate.as_view(), name="create" + "engagement-event/create/from-org/<slug:slug>", view=EngagementEventCreate.as_view(), name="create", ), + path( + "engagement-event/delete/<int:pk>/for-org/<slug:slug>", view=EngagementEventDelete.as_view(), name="ee_delete" + ) ] diff --git a/ctrack/register/views.py b/ctrack/register/views.py index 3daabd7..32faf4d 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -2,23 +2,32 @@ from django.contrib.auth import get_user_model from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponseRedirect from django.urls import reverse, reverse_lazy -from django.views.generic import FormView +from django.views.generic import FormView, DeleteView from ctrack.organisations.models import Organisation from ctrack.register.forms import EngagementEventCreateForm +from ctrack.register.models import EngagementEvent + + +class EngagementEventDelete(DeleteView): + model = EngagementEvent + + def get_success_url(self): + return reverse_lazy("organisations:detail", args=[self.kwargs["slug"]]) + class EngagementEventCreate(LoginRequiredMixin, FormView): fields = "__all__" form_class = EngagementEventCreateForm template_name = "register/engagementevent_form.html" - success_url = reverse_lazy("organisations:list") + # success_url = reverse_lazy("organisations:list") def form_valid(self, form): ee = form.save(commit=False) ee.user = self.request.user form.save() - return HttpResponseRedirect(reverse("organisations:list")) + return HttpResponseRedirect(self.get_success_url()) def get_form_kwargs(self): kwargs = super().get_form_kwargs() @@ -30,3 +39,6 @@ class EngagementEventCreate(LoginRequiredMixin, FormView): context = super().get_context_data() context["org"] = Organisation.objects.get(slug=self.kwargs["slug"]) return context + + def get_success_url(self): + return reverse_lazy("organisations:detail", args=[self.kwargs["slug"]]) |