aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/organisations/templates/organisations/organisation_detail.html19
-rw-r--r--ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_confirm_delete.html34
-rw-r--r--ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_form.html64
-rw-r--r--ctrack/register/singledatetimeevent_update_form.html/single_datetime_event_create.html21
-rw-r--r--ctrack/register/templates/register/singledatetimeevent_update_form.html17
-rw-r--r--ctrack/register/tests/test_views.py20
-rw-r--r--ctrack/register/urls.py7
-rw-r--r--ctrack/register/views.py40
8 files changed, 207 insertions, 15 deletions
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html
index f1da2cb..b0b1a79 100644
--- a/ctrack/organisations/templates/organisations/organisation_detail.html
+++ b/ctrack/organisations/templates/organisations/organisation_detail.html
@@ -272,16 +272,17 @@
{% for event in single_datetime_events %}
<div class="card" style="width: 100%">
<div class="card-body">
- <h5 class="card-title">{{ event.short_description }}</h5>
- <div class="card-subtitle mb-2">
- <span class="badge badge-info">{{ event.type_descriptor }}</span>
- <span class="badge badge-light">{{ event.datetime|date:"l j F Y" }}, {{ event.datetime|date:"G:i" }}</span></h5>
- </div>
+ <h5 class="card-title">{{ event.short_description }} | <a
+ href="{% url "register:event_update_simple_event_from_org" event.pk object.slug %}">Edit</a></h5>
+ <div class="card-subtitle mb-2">
+ <span class="badge badge-info">{{ event.type_descriptor }}</span>
+ <span class="badge badge-light">{{ event.datetime|date:"l j F Y" }}, {{ event.datetime|date:"G:i" }}</span></h5>
+ </div>
<p class="card-text">{{ event.comments }}</p>
- Participants:
- {% for person in event.participants.all %}
- <a href="{% url "organisations:person-detail" person.id %}">{{ person }}</a> &nbsp;
- {% endfor %}
+ Participants:
+ {% for person in event.participants.all %}
+ <a href="{% url "organisations:person-detail" person.id %}">{{ person }}</a> &nbsp;
+ {% endfor %}
</div>
</div>
{% endfor %}
diff --git a/ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_confirm_delete.html b/ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_confirm_delete.html
new file mode 100644
index 0000000..ec61949
--- /dev/null
+++ b/ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_confirm_delete.html
@@ -0,0 +1,34 @@
+{% extends "base.html" %}
+
+{% block title %}
+ Confirm Deletion
+{% endblock title %}
+
+{% load crispy_forms_tags %}
+
+{% block content %}
+ <div class="container mt-3">
+ <div class="row">
+ <div class="col-6 offset-md-2 pt-3">
+ <div class="card">
+ <div class="card-body">
+ <h5 class="card-title">Confirm deletion</h5>
+ <div class="card-text">Are you sure you want to delete the event <strong>{{ object.type.descriptor }} | {{ object.short_description }}</strong>?</div>
+ <div class="card-text">
+ <p>This event was created by <strong>{{ object.user }}</strong> - ensure you have their permission.</p>
+ </div>
+ <div class="col p-2">
+ <form method="post">
+ {% csrf_token %}
+ <div class="form-row">
+ <button type="submit" class="btn btn-danger m-1" value="Confirm" id="submit-button">Delete</button>
+ <a href="{{ view.get_success_url }}" class="btn btn-primary m-1">Cancel</a>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endblock content %}
diff --git a/ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_form.html b/ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_form.html
new file mode 100644
index 0000000..014f9b3
--- /dev/null
+++ b/ctrack/register/singledatetimeevent_update_form.html/register/engagementevent_form.html
@@ -0,0 +1,64 @@
+{% extends "base.html" %}
+
+{% block title %}
+ Register a new OES event
+{% endblock title %}
+
+{% load crispy_forms_tags %}
+
+{% block content %}
+
+ <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
+ <script>
+ $(document).ready(function () {
+
+ $("#id_type").change(function () {
+ const selected = $("#id_type option:selected").text();
+ if (selected.includes("CAF")) {
+ $("#caf_alert").removeAttr('hidden');
+ $("#div_id_related_caf").addClass("border rounded p-3 border-danger");
+ $("select[name=related_caf] option:eq(1)").attr("selected", "selected");
+ } else {
+ $("#caf_alert").prop("hidden", true);
+ $("#div_id_related_caf").removeClass("border rounded p-3 border-danger");
+ $("select[name=related_caf] option:eq(0)").attr("selected", "selected");
+ }
+ });
+ });
+ </script>
+
+
+ <div class="container mt-3">
+ <div class="row">
+ <div class="col-md-12 pl-0 my-2">
+ <h4>Register a new event</h4>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-12 pl-0 my-2 bg-light">
+ <h3 class="text-secondary">{{ org.name }}</h3>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-7 py-2 mb-3 border bg-light">
+ <div hidden id="caf_alert" class="alert alert-danger" role="alert">
+ If selecting a CAF type here, you must select the CAF this event applies to in
+ the "Related CAFs" field below.
+ </div>
+ {% crispy form %}
+ </div>
+ <div class="col-md-5">
+ <div class="card">
+ <div class="card-body">
+ <h5 class="card-title">Help on Engagement Events</h5>
+ <p class="card-text">All key events in the compliance lifecycle need to be registered.</p>
+ <p class="card-text">Events can be <em>singular</em> (such as an email) or <em>periodic</em> (such as a CAF
+ analysis period).</p>
+ <p class="card-text">All events should be registered here.</p>
+ <a href="#" class="btn btn-primary">Go somewhere</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endblock content %}
diff --git a/ctrack/register/singledatetimeevent_update_form.html/single_datetime_event_create.html b/ctrack/register/singledatetimeevent_update_form.html/single_datetime_event_create.html
new file mode 100644
index 0000000..d88d19a
--- /dev/null
+++ b/ctrack/register/singledatetimeevent_update_form.html/single_datetime_event_create.html
@@ -0,0 +1,21 @@
+{% extends "snippets/event_form_base.html" %}
+
+{% load static %}
+{% load crispy_forms_tags %}
+
+{% block form %}
+ {% if org %}
+ <h3 class="mt-2">Create a new simple event involving {{ org }}</h3>
+ {% else %}
+ <h3 class="mt-2">Create a new simple event</h3>
+ {% endif %}
+ <p>Simple events are emails, phone calls, basic meetings, notes, deadlines, etc.
+ If you arrived at this page from an organisation's page, you are able to select
+ participants in the event from that organisation.</p>
+ <form method="post">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <button type="submit" class="btn btn-success">Submit</button>
+ <a href="{{ org.get_absolute_url }}" class="btn btn-danger" type="button">Cancel</a>
+ </form>
+{% endblock form %}
diff --git a/ctrack/register/templates/register/singledatetimeevent_update_form.html b/ctrack/register/templates/register/singledatetimeevent_update_form.html
new file mode 100644
index 0000000..646ea3b
--- /dev/null
+++ b/ctrack/register/templates/register/singledatetimeevent_update_form.html
@@ -0,0 +1,17 @@
+{% extends "snippets/event_form_base.html" %}
+
+{% load static %}
+{% load crispy_forms_tags %}
+
+{% block form %}
+ <h3 class="mt-2">Edit event {{ object }}</h3>
+ <p>Simple events are emails, phone calls, basic meetings, notes, deadlines, etc.
+ If you arrived at this page from an organisation's page, you are able to select
+ participants in the event from that organisation.</p>
+ <form method="post">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <button type="submit" class="btn btn-success">Submit</button>
+ <a href="{{ org.get_absolute_url }}" class="btn btn-danger" type="button">Cancel</a>
+ </form>
+{% endblock form %}
diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py
index 306cec5..148ddfe 100644
--- a/ctrack/register/tests/test_views.py
+++ b/ctrack/register/tests/test_views.py
@@ -2,6 +2,7 @@ import pytest
from django.test import TestCase
from django.urls import reverse
+from ctrack.organisations.tests.factories import SingleDateTimeEventFactory
from ctrack.register.views import SingleDateTimeEventCreate
# Doing this allows us to use TestCase assertions (assertIn, etc)
@@ -120,8 +121,8 @@ class TestSingleDateTimeEvent:
url = reverse("register:event_create_simple_event_from_org", args=[slug])
client.force_login(user)
response = client.get(url)
- html = response.content.decode("utf-8")
assert response.status_code == 200
+ html = response.content.decode("utf-8")
test_case.assertInHTML(f"Create a new simple event involving {org.name}", html)
def test_org_passed_as_kwarg(self, user, org, request_factory):
@@ -147,6 +148,23 @@ class TestSingleDateTimeEvent:
view.setup(request)
assert "event_type" in view.get_form_kwargs()
+ def test_can_update_single_datetime_event_from_org(self, user, org_with_people, client):
+ org_slug = org_with_people.slug
+ people = org_with_people.person_set.all()
+ e1 = SingleDateTimeEventFactory(type_descriptor="MEETING")
+ _collected_p = []
+ for p in people:
+ e1.participants.add(p)
+ _collected_p.append((p.first_name, p.last_name))
+ e1.save()
+ pk = e1.pk
+ url = reverse("register:event_update_simple_event_from_org", args=[pk, org_slug])
+ client.force_login(user)
+ response = client.get(url)
+ assert response.status_code == 200
+ html = response.content.decode("utf-8")
+ test_case.assertInHTML(" ".join(_collected_p[0]), html)
+
class TestSingleDateCAFEventViews:
def test_initial_caf_received(self, client):
diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py
index 14c9798..9d2b102 100644
--- a/ctrack/register/urls.py
+++ b/ctrack/register/urls.py
@@ -4,7 +4,7 @@ from ctrack.register.views import (
EngagementEventCreate,
EngagementEventCreateFromCaf,
EngagementEventDelete,
- SingleDateTimeEventCreate,
+ SingleDateTimeEventCreate, SingleDateTimeEventUpdate,
)
app_name = "register"
@@ -31,6 +31,11 @@ urlpatterns = [
name="event_create_simple_event",
),
path(
+ "event/update-simple-event/<int:pk>/<slug:org_slug>",
+ view=SingleDateTimeEventUpdate.as_view(),
+ name="event_update_simple_event_from_org",
+ ),
+ path(
"event/create-simple-event-from-org/<slug:org_slug>",
view=SingleDateTimeEventCreate.as_view(),
name="event_create_simple_event_from_org",
diff --git a/ctrack/register/views.py b/ctrack/register/views.py
index b601c49..d2dca72 100644
--- a/ctrack/register/views.py
+++ b/ctrack/register/views.py
@@ -2,12 +2,15 @@ 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_lazy
-from django.views.generic import DeleteView, FormView
+from django.views.generic import DeleteView, FormView, UpdateView
from ctrack.caf.models import CAF
from ctrack.organisations.models import Organisation
-from ctrack.register.forms import CreateSimpleDateTimeEventForm, EngagementEventCreateForm
-from ctrack.register.models import EngagementEvent
+from ctrack.register.forms import (
+ CreateSimpleDateTimeEventForm,
+ EngagementEventCreateForm,
+)
+from ctrack.register.models import EngagementEvent, SingleDateTimeEvent
class EngagementEventDelete(DeleteView):
@@ -72,6 +75,33 @@ class EngagementEventCreateFromCaf(FormView):
return reverse_lazy("organisations:detail", args=[org_slug])
+class SingleDateTimeEventUpdate(UpdateView):
+ model = SingleDateTimeEvent
+ fields = [
+ "type_descriptor",
+ "short_description",
+ "datetime",
+ "private",
+ "document_link",
+ "comments",
+ "participants",
+ "requested_response_date",
+ "response_received_date",
+ ]
+ template_name_suffix = "_update_form"
+ success_url = reverse_lazy("organisations:list")
+
+ def get_success_url(self):
+ # We might not have org_slug if we are not setting this from an org detail page
+ try:
+ self.success_url = reverse_lazy(
+ "organisations:detail", args=[self.kwargs["org_slug"]]
+ )
+ return super().get_success_url()
+ except KeyError:
+ return super().get_success_url()
+
+
class SingleDateTimeEventCreate(FormView):
template_name = "single_datetime_event_create.html"
form_class = CreateSimpleDateTimeEventForm
@@ -80,7 +110,9 @@ class SingleDateTimeEventCreate(FormView):
def get_success_url(self):
# We might not have org_slug if we are not setting this from an org detail page
try:
- self.success_url = reverse_lazy("organisations:detail", args=[self.kwargs["org_slug"]])
+ self.success_url = reverse_lazy(
+ "organisations:detail", args=[self.kwargs["org_slug"]]
+ )
return super().get_success_url()
except KeyError:
return super().get_success_url()