aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-19 21:00:49 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-19 21:00:49 +0100
commit990807fa2fcdea85c20e42359a00fbe0fa3a21d0 (patch)
treeac492733270ffe6c32fc2b64eda9b46ea41a8e36 /ctrack/register
parentc07178fb19f55ea8354b2de153a2d41c66d58f32 (diff)
can now add a note to the system for an organisation but not listed on detail page yet
Diffstat (limited to 'ctrack/register')
-rw-r--r--ctrack/register/admin.py8
-rw-r--r--ctrack/register/migrations/0006_auto_20201019_1935.py43
-rw-r--r--ctrack/register/models.py3
-rw-r--r--ctrack/register/templates/register/create_note_event_form.html17
-rw-r--r--ctrack/register/tests/test_views.py7
-rw-r--r--ctrack/register/urls.py7
-rw-r--r--ctrack/register/views.py28
7 files changed, 108 insertions, 5 deletions
diff --git a/ctrack/register/admin.py b/ctrack/register/admin.py
index bcd27da..c4e071d 100644
--- a/ctrack/register/admin.py
+++ b/ctrack/register/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
-from ctrack.register.models import EngagementEvent, SingleDateTimeEvent
+from ctrack.register.models import EngagementEvent, SingleDateTimeEvent, NoteEvent
from ctrack.register.models import EngagementType
@@ -19,6 +19,12 @@ class SingleDateTimeEventAdmin(admin.ModelAdmin):
list_display = ("type_descriptor", "short_description", "datetime", "user", "created_date")
+class NoteEventAdmin(admin.ModelAdmin):
+ model = NoteEvent
+ list_display = ("short_description", "organisation", "user")
+
+
admin.site.register(EngagementEvent, EngagementEventAdmin)
admin.site.register(EngagementType, EngagementEventTypeAdmin)
admin.site.register(SingleDateTimeEvent, SingleDateTimeEventAdmin)
+admin.site.register(NoteEvent, NoteEventAdmin)
diff --git a/ctrack/register/migrations/0006_auto_20201019_1935.py b/ctrack/register/migrations/0006_auto_20201019_1935.py
new file mode 100644
index 0000000..291b594
--- /dev/null
+++ b/ctrack/register/migrations/0006_auto_20201019_1935.py
@@ -0,0 +1,43 @@
+# Generated by Django 3.1.2 on 2020-10-19 19:35
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('organisations', '0002_auto_20201015_1955'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('register', '0005_auto_20201019_0928'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='singledatetimeevent',
+ name='type_descriptor',
+ field=models.CharField(choices=[('MEETING', 'Meeting'), ('PHONE_CALL', 'Phone Call'), ('VIDEO_CALL', 'Video Call'), ('EMAIL', 'Email')], max_length=50, verbose_name='Event Type'),
+ ),
+ migrations.CreateModel(
+ name='NoteEvent',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('created_date', models.DateTimeField()),
+ ('modified_date', models.DateTimeField()),
+ ('short_description', models.CharField(help_text='Short description of the event. Use Comments field for full detail.', max_length=50)),
+ ('document_link', models.URLField(blank=True, help_text='URL only - do not try to drag a file here.', max_length=1000, null=True)),
+ ('comments', models.TextField(blank=True, help_text='Use this to provide further detail about the event.', max_length=1000, null=True)),
+ ('url', models.URLField(blank=True, help_text='If recording an email, please link to it here. Do not paste the text in the comments box.', max_length=400, null=True, verbose_name='URL')),
+ ('requested_response_date', models.DateField(blank=True, help_text='DD/MM/YY format', null=True)),
+ ('response_received_date', models.DateField(blank=True, help_text='DD/MM/YY format', null=True)),
+ ('private', models.BooleanField(default=False, help_text='Private events can only be seen by you. Official records should not be private, but you can use private events to track your own work.')),
+ ('type_descriptor', models.CharField(default='NOTE', max_length=50)),
+ ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.organisation')),
+ ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ ]
diff --git a/ctrack/register/models.py b/ctrack/register/models.py
index 0c88a54..8080302 100644
--- a/ctrack/register/models.py
+++ b/ctrack/register/models.py
@@ -182,6 +182,9 @@ class NoteEvent(
"organisations.Organisation", on_delete=models.CASCADE, blank=False
)
+ def __str__(self):
+ return " ".join(["Note: ", self.short_description])
+
class SingleDateTimeEvent(
EventBase,
diff --git a/ctrack/register/templates/register/create_note_event_form.html b/ctrack/register/templates/register/create_note_event_form.html
new file mode 100644
index 0000000..d6b83eb
--- /dev/null
+++ b/ctrack/register/templates/register/create_note_event_form.html
@@ -0,0 +1,17 @@
+{% extends "snippets/event_form_base.html" %}
+
+{% load static %}
+{% load crispy_forms_tags %}
+
+{% block form %}
+ <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>
+ <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 b37fa91..9887942 100644
--- a/ctrack/register/tests/test_views.py
+++ b/ctrack/register/tests/test_views.py
@@ -127,6 +127,13 @@ class TestSingleDateTimeEvent:
html = response.content.decode("utf-8")
test_case.assertInHTML(f"Create a new simple event involving {org.name}", html)
+ def test_create_note_view(self, user, org, client):
+ client.force_login(user)
+ response = client.get(reverse("register:event_create_note"))
+ assert response.status_code == 200
+ html = response.content.decode("utf-8")
+ assert "Create a Note" in html
+
def test_org_passed_as_kwarg(self, user, org, request_factory):
slug = org.slug
view = SingleDateTimeEventCreate()
diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py
index 9d2b102..3f3c4f8 100644
--- a/ctrack/register/urls.py
+++ b/ctrack/register/urls.py
@@ -4,7 +4,7 @@ from ctrack.register.views import (
EngagementEventCreate,
EngagementEventCreateFromCaf,
EngagementEventDelete,
- SingleDateTimeEventCreate, SingleDateTimeEventUpdate,
+ SingleDateTimeEventCreate, SingleDateTimeEventUpdate, CreateNoteEvent,
)
app_name = "register"
@@ -44,6 +44,11 @@ urlpatterns = [
"event/create-simple-event-from-org/<slug:org_slug>/<str:event_type>",
view=SingleDateTimeEventCreate.as_view(),
name="event_create_simple_event_from_org_with_type",
+ ),
+ path(
+ "event/create-note",
+ view=CreateNoteEvent.as_view(),
+ name="event_create_note"
)
# path(
# "event/create-caf-single-date-event",
diff --git a/ctrack/register/views.py b/ctrack/register/views.py
index d2dca72..f8da4f1 100644
--- a/ctrack/register/views.py
+++ b/ctrack/register/views.py
@@ -1,8 +1,7 @@
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, UpdateView
+from django.views.generic import DeleteView, FormView, UpdateView, CreateView
from ctrack.caf.models import CAF
from ctrack.organisations.models import Organisation
@@ -10,7 +9,7 @@ from ctrack.register.forms import (
CreateSimpleDateTimeEventForm,
EngagementEventCreateForm,
)
-from ctrack.register.models import EngagementEvent, SingleDateTimeEvent
+from ctrack.register.models import EngagementEvent, SingleDateTimeEvent, NoteEvent
class EngagementEventDelete(DeleteView):
@@ -75,6 +74,29 @@ class EngagementEventCreateFromCaf(FormView):
return reverse_lazy("organisations:detail", args=[org_slug])
+class CreateNoteEvent(CreateView):
+ model = NoteEvent
+ fields = [
+ "short_description",
+ "organisation",
+ "comments",
+ "private",
+ "url",
+ "requested_response_date",
+ "response_received_date",
+ ]
+ template_name = "register/create_note_event_form.html"
+
+ def form_valid(self, form):
+ note = form.save(commit=False)
+ note.user = self.request.user
+ note.save()
+ return super().form_valid(form)
+
+ def get_success_url(self):
+ return reverse_lazy("organisations:detail", args=[self.object.organisation.slug])
+
+
class SingleDateTimeEventUpdate(UpdateView):
model = SingleDateTimeEvent
fields = [