aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/core/utils.py5
-rw-r--r--ctrack/organisations/templates/organisations/organisation_detail.html12
-rw-r--r--ctrack/organisations/views.py7
-rw-r--r--ctrack/register/forms.py1
-rw-r--r--utility/truncate_script.sql2
5 files changed, 17 insertions, 10 deletions
diff --git a/ctrack/core/utils.py b/ctrack/core/utils.py
index fb49235..0612c52 100644
--- a/ctrack/core/utils.py
+++ b/ctrack/core/utils.py
@@ -197,6 +197,11 @@ def populate_db(**kwargs):
etf3 = EngagementTypeFactory(
descriptor="CAF - Initial Submission", enforcement_instrument=False
)
+ etf4 = EngagementTypeFactory(descriptor="Phone Call", enforcement_instrument=False)
+ etf5 = EngagementTypeFactory(
+ descriptor="Video Conference", enforcement_instrument=False
+ )
+ etf6 = EngagementTypeFactory(descriptor="Email", enforcement_instrument=False)
EngagementEventFactory.create(type=etf1, user=user, participants=[p1, p2])
EngagementEventFactory.create(type=etf2, user=user, participants=[p3])
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html
index 29d188c..bf16c87 100644
--- a/ctrack/organisations/templates/organisations/organisation_detail.html
+++ b/ctrack/organisations/templates/organisations/organisation_detail.html
@@ -99,23 +99,19 @@
<div class="col-md-12 my-2">
<div class="card bg-light">
<div class="card-body">
- <div class="card-title">OES Engagements<a href="#" class="btn btn-primary btn-sm float-right">Add
+ <div class="card-title">OES Engagements<a href="{% url "register:create" %}" class="btn btn-primary btn-sm float-right">Add
new...</a></div>
<div class="table table-responsive">
<table class="table">
{% if engagement_events|length > 0 %}
{% for event in engagement_events %}
<tr>
- <td><a href="{% url "caf:ass_detail" ass.id %}">{{ ass.name }}</a></td>
- <td>{{ ass.description }}<br>
- <a href="{% url "caf:detail" ass.caf.pk %}" class="small">
- {{ ass.caf }}
- </a> <span class="text-muted"> | <a href="#" class="small">Edit System</a></span>
- </td>
+ <td><a href="#">{{ event.type}}</a></td>
+ <td>{{ event.short_description }}</td>
</tr>
{% endfor %}
{% else %}
- <a class="btn btn-primary" href="{% url "caf:create_from_org" object.slug %}" role="button">Add
+ <a class="btn btn-primary" href="{% url "register:create" %}" role="button">Add
new...</a>
{% endif %}
</table>
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 0dfe21d..394966a 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -6,6 +6,8 @@ from django.http import HttpResponseRedirect
from django.urls import reverse, reverse_lazy
from django.views.generic import CreateView, DetailView, FormView, ListView
+from ctrack.register.models import EngagementEvent
+
from .forms import AddressInlineFormSet, IncidentReportForm, OrganisationCreateForm
from .models import IncidentReport, Organisation, Person
@@ -59,9 +61,11 @@ class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detail
model = Organisation
permission_required = "organisations.view_organisation"
- def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
+ def get_context_data(self, **kwargs: Any):
context = super().get_context_data()
org = kwargs["object"]
+ peoples = org.person_set.all()
+ engagement_events = EngagementEvent.objects.filter(participants__in=peoples)
no_addr = org.addresses.count()
if no_addr > 1:
context["no_addr"] = no_addr
@@ -75,6 +79,7 @@ class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detail
context["people"] = people
applicable_systems = org.applicablesystem_set.all()
context["applicable_systems"] = applicable_systems
+ context["engagement_events"] = engagement_events
return context
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py
index 021414d..0335149 100644
--- a/ctrack/register/forms.py
+++ b/ctrack/register/forms.py
@@ -38,6 +38,7 @@ class EngagementEventCreateForm(forms.ModelForm):
ee = super().save(commit=False)
if commit:
ee.save()
+ self.save_m2m() # so that we also save the peoples!
return ee
class Meta:
diff --git a/utility/truncate_script.sql b/utility/truncate_script.sql
index 18aa47b..d20a095 100644
--- a/utility/truncate_script.sql
+++ b/utility/truncate_script.sql
@@ -1,3 +1,4 @@
+DELETE FROM auth_group WHERE name='cct_users';
TRUNCATE TABLE organisations_organisation RESTART IDENTITY CASCADE;
TRUNCATE TABLE organisations_person RESTART IDENTITY CASCADE;
TRUNCATE TABLE organisations_person_role RESTART IDENTITY CASCADE;
@@ -27,4 +28,3 @@ TRUNCATE TABLE assessments_achievementlevel RESTART IDENTITY CASCADE;
TRUNCATE TABLE assessments_igp RESTART IDENTITY CASCADE;
DELETE FROM users_user WHERE username != 'mlemon';
DELETE FROM users_user WHERE username = 'inspector1';
-DELETE FROM auth_group WHERE name='cct_users';