aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/register/models.py16
-rw-r--r--ctrack/register/tests/test_engagement_events.py4
-rw-r--r--ctrack/register/tests/test_events.py44
3 files changed, 64 insertions, 0 deletions
diff --git a/ctrack/register/models.py b/ctrack/register/models.py
index 7e6d46e..8155fb7 100644
--- a/ctrack/register/models.py
+++ b/ctrack/register/models.py
@@ -1,5 +1,6 @@
import datetime
from datetime import date as std_date
+from enum import Enum, auto
from typing import Optional, Dict
from django.contrib.auth import get_user_model
@@ -9,6 +10,20 @@ from ctrack.organisations.models import Person
from ctrack.users.models import User
+class EventType(Enum):
+ MEETING = auto()
+ PHONE_CALL = auto()
+ VIDEO_CALL = auto()
+ CAF_INITIAL_CAF_RECEIVED = auto()
+ CAF_INITIAL_CAF_EMAILED_ROSA = auto()
+ CAF_FEEDBACK_EMAILED_OES = auto()
+ CAF_RECEIVED = auto()
+ CAF_EMAILED_ROSA = auto()
+ CAF_PEER_REVIEW_PERIOD = auto()
+ CAF_VALIDATION_PERIOD = auto()
+ CAF_VALIDATION_SIGN_OFF = auto()
+ CAF_VALIDATION_RECORD_EMAILED_TO_OES = auto()
+
def _style_descriptor(days: int) -> str:
if days < 1:
return "red"
@@ -34,6 +49,7 @@ class AuditableEventBase(models.Model):
abstract = True
def save(self, *args, **kwargs):
+ # TODO this also needs to include created_by and updated_by attributes
"""Overriding so we can save the dates in here."""
if not self.pk:
self.created_date = datetime.datetime.now()
diff --git a/ctrack/register/tests/test_engagement_events.py b/ctrack/register/tests/test_engagement_events.py
index ee44a9a..602d027 100644
--- a/ctrack/register/tests/test_engagement_events.py
+++ b/ctrack/register/tests/test_engagement_events.py
@@ -1,3 +1,7 @@
+"""LEGACY - SPIKE CODE _ TO BE DELETED"""
+
+# TODO - delete this code
+
import datetime
import pytest
diff --git a/ctrack/register/tests/test_events.py b/ctrack/register/tests/test_events.py
new file mode 100644
index 0000000..1cff086
--- /dev/null
+++ b/ctrack/register/tests/test_events.py
@@ -0,0 +1,44 @@
+import datetime
+
+import pytest
+
+from ctrack.register.models import MeetingEvent, EventType
+
+pytestmark = pytest.mark.django_db
+
+
+def test_event_type_enum():
+ assert EventType.MEETING.name == "MEETING"
+ assert EventType.PHONE_CALL.name == "PHONE_CALL"
+ assert EventType.VIDEO_CALL.name == "VIDEO_CALL"
+ assert EventType.CAF_INITIAL_CAF_RECEIVED.name == "CAF_INITIAL_CAF_RECEIVED"
+ assert EventType.CAF_INITIAL_CAF_EMAILED_ROSA.name == "CAF_INITIAL_CAF_EMAILED_ROSA"
+ assert EventType.CAF_FEEDBACK_EMAILED_OES.name == "CAF_FEEDBACK_EMAILED_OES"
+ assert EventType.CAF_RECEIVED.name == "CAF_RECEIVED"
+ assert EventType.CAF_EMAILED_ROSA.name == "CAF_EMAILED_ROSA"
+ assert EventType.CAF_PEER_REVIEW_PERIOD.name == "CAF_PEER_REVIEW_PERIOD"
+ assert EventType.CAF_VALIDATION_PERIOD.name == "CAF_VALIDATION_PERIOD"
+ assert EventType.CAF_VALIDATION_SIGN_OFF.name == "CAF_VALIDATION_SIGN_OFF"
+ assert EventType.CAF_VALIDATION_RECORD_EMAILED_TO_OES.name == "CAF_VALIDATION_RECORD_EMAILED_TO_OES"
+
+
+def test_meeting_event(person, user):
+ uname = user.name
+ now = datetime.datetime.now()
+ e = MeetingEvent.objects.create(
+ type_descriptor="Meeting",
+ short_description="Big Important Meeting",
+ datetime="2020-10-10T15:00",
+ comments="Nice comments",
+ location="Harvey's House",
+ user=user
+ )
+ e.participants.add(person)
+ assert len(e.participants.all()) == 1
+ assert e.type_descriptor == "Meeting"
+ assert person in e.participants.all()
+ assert e.user.name == uname
+ assert e.created_date.day == now.day
+ assert e.created_date.hour == now.hour
+ assert e.modified_date.day == now.day
+ assert e.modified_date.hour == now.hour