aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/organisations/templates/organisations/organisation_detail.html2
-rw-r--r--ctrack/organisations/views.py2
-rw-r--r--ctrack/register/forms.py3
-rw-r--r--ctrack/register/templates/register/create_note_event_form.html11
-rw-r--r--ctrack/register/tests/test_forms.py5
-rw-r--r--ctrack/register/views.py17
6 files changed, 19 insertions, 21 deletions
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html
index 8a3d644..d981479 100644
--- a/ctrack/organisations/templates/organisations/organisation_detail.html
+++ b/ctrack/organisations/templates/organisations/organisation_detail.html
@@ -133,7 +133,7 @@
<path fill-rule="evenodd"
d="M5 10.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/>
</svg>
- <a href="{% url "register:event_create_simple_event_from_org_with_type" object.slug 'NOTE' %}">New
+ <a href="{% url "register:event_create_note" %}">New
note</a>
</div>
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index b688fea..fa811eb 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -13,10 +13,10 @@ from ctrack.caf.models import CAF, EssentialService
from ctrack.register.models import EngagementEvent
from .forms import AddressInlineFormSet, IncidentReportForm, OrganisationCreateForm
from .models import IncidentReport, Organisation, Person
-# TODO - needs a permission on this view
from .utils import filter_private_events
+# TODO - needs a permission on this view
def essential_service_detail(request, pk):
es = EssentialService.objects.get(pk=pk)
org = es.organisation
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py
index 65c954b..8b0452f 100644
--- a/ctrack/register/forms.py
+++ b/ctrack/register/forms.py
@@ -22,8 +22,8 @@ class CreateNoteEventForm(forms.ModelForm):
class Meta:
model = NoteEvent
fields = [
- "type_descriptor",
"short_description",
+ "organisation",
"comments",
"private",
"url",
@@ -34,6 +34,7 @@ class CreateNoteEventForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user")
super().__init__(*args, **kwargs)
+ self.fields["organisation"].queryset = Organisation.objects.all().order_by('name')
def save(self, commit=True, **kwargs):
new_note = super().save(commit=False)
diff --git a/ctrack/register/templates/register/create_note_event_form.html b/ctrack/register/templates/register/create_note_event_form.html
index d6b83eb..eea336c 100644
--- a/ctrack/register/templates/register/create_note_event_form.html
+++ b/ctrack/register/templates/register/create_note_event_form.html
@@ -4,10 +4,15 @@
{% load crispy_forms_tags %}
{% block form %}
- <h3 class="mt-2">Create a Note</h3>
+ <h3 class="mt-2">Create a Note</h3>
<p>Notes are associated with an organisation and are not intended to be
- formal records of events should not involve any interaction with a person
- from that organisation. Use them to record observations, notes, reminders, etc</p>
+ formal records of events. They should not formally record any interaction with a person
+ from that organisation. Use them to record observations, notes, reminders, etc.</p>
+
+ <p>Mark the note as <strong>private</strong> if you wish it only to be available to you.</p>
+
+ <p>Formal records such as emails, phone calls and meetings can be recorded from that
+ organisations detail page.</p>
<form method="post">
{% csrf_token %}
{{ form|crispy }}
diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py
index b9c8b0b..1ba1cf9 100644
--- a/ctrack/register/tests/test_forms.py
+++ b/ctrack/register/tests/test_forms.py
@@ -6,10 +6,6 @@ from ..forms import CreateSimpleDateTimeEventForm, CAFSingleDateEventForm, CAFTw
pytestmark = pytest.mark.django_db
-# TODO this test and the form code needs to be amended to save created_by and update_by
-# on the model
-
-
def test_init(user, org_with_people):
"""Here we test that we can pass in the user value from the view.
We don't want that to be field in the form.
@@ -114,7 +110,6 @@ def test_meeting_blank_data(user, org_with_people):
assert form.errors == {"datetime": ["This field is required."]}
-# TODO - write the template and test the view for this and link from org detail page
def test_create_note(user, org_with_people):
"""
A note is related to an organisation rather than to persons in that organisation.
diff --git a/ctrack/register/views.py b/ctrack/register/views.py
index f8da4f1..935bbed 100644
--- a/ctrack/register/views.py
+++ b/ctrack/register/views.py
@@ -7,7 +7,7 @@ from ctrack.caf.models import CAF
from ctrack.organisations.models import Organisation
from ctrack.register.forms import (
CreateSimpleDateTimeEventForm,
- EngagementEventCreateForm,
+ EngagementEventCreateForm, CreateNoteEventForm,
)
from ctrack.register.models import EngagementEvent, SingleDateTimeEvent, NoteEvent
@@ -75,18 +75,15 @@ class EngagementEventCreateFromCaf(FormView):
class CreateNoteEvent(CreateView):
+ form_class = CreateNoteEventForm
model = NoteEvent
- fields = [
- "short_description",
- "organisation",
- "comments",
- "private",
- "url",
- "requested_response_date",
- "response_received_date",
- ]
template_name = "register/create_note_event_form.html"
+ def get_form_kwargs(self):
+ kwargs = super().get_form_kwargs()
+ kwargs["user"] = self.request.user
+ return kwargs
+
def form_valid(self, form):
note = form.save(commit=False)
note.user = self.request.user