diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-11 15:17:35 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-11 15:17:35 +0100 |
commit | abd1b4926bc3aa1d0daba5bc5594a385898dd753 (patch) | |
tree | 85b2e6e511765e5419035f03ecada0955c6620d0 /ctrack | |
parent | d4f1bdfadb39ed966c2aeddba1b7fff898042fe6 (diff) |
added CAFSingleDateEvent event
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/caf/models.py | 7 | ||||
-rw-r--r-- | ctrack/register/models.py | 19 | ||||
-rw-r--r-- | ctrack/register/tests/test_event_models.py | 16 |
3 files changed, 38 insertions, 4 deletions
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py index 5e3e2e2..a2015eb 100644 --- a/ctrack/caf/models.py +++ b/ctrack/caf/models.py @@ -4,7 +4,7 @@ from ctrack.caf.managers import ApplicableSystemManager from ctrack.organisations.models import Organisation, Person from django.urls.base import reverse -from ctrack.register.models import EngagementEvent +# from ctrack.register.models import EngagementEvent class Grading(models.Model): @@ -160,8 +160,9 @@ class CAF(models.Model): def get_assessments(self): return self.cafassessment_set.all() - def get_events(self): - return EngagementEvent.objects.filter(related_caf=self).all().order_by("-date") + # REMOVED UNTIL FIXED EVENT SYSTEM + # def get_events(self): + # return EngagementEvent.objects.filter(related_caf=self).all().order_by("-date") def __str__(self): # Get the organisation and applicable system diff --git a/ctrack/register/models.py b/ctrack/register/models.py index c0467b0..12247e8 100644 --- a/ctrack/register/models.py +++ b/ctrack/register/models.py @@ -6,6 +6,7 @@ from typing import Optional, Dict from django.contrib.auth import get_user_model from django.db import models +from ctrack.caf.models import CAF from ctrack.organisations.models import Person from ctrack.users.models import User @@ -92,6 +93,17 @@ class SingleDateTimeEventMixin(models.Model): abstract = True +class SingleDateMixin(models.Model): + date = models.DateField() + + class Meta: + abstract = True + + +class CAFMixin(models.Model): + related_caf = models.ForeignKey(CAF, on_delete=models.CASCADE) + + class SingleDateTimeEvent(EventBase, ThirdPartyEventMixin, SingleDateTimeEventMixin): AVAILABLE_TYPES = [ (EventType.PHONE_CALL.name, "Phone Call"), @@ -110,6 +122,13 @@ class MeetingEvent(EventBase, ThirdPartyEventMixin, SingleDateTimeEventMixin): type_descriptor = models.CharField(max_length=50, choices=AVAILABLE_TYPES) +class CAFSingleDateEvent(EventBase, CAFMixin, SingleDateMixin): + AVAILABLE_TYPES = [ + (EventType.CAF_INITIAL_CAF_RECEIVED.name, "CAF - Initial CAF Received") + ] + type_descriptor = models.CharField(max_length=50, choices=AVAILABLE_TYPES) + + # OLD CODE BELOW class EngagementType(models.Model): diff --git a/ctrack/register/tests/test_event_models.py b/ctrack/register/tests/test_event_models.py index 1871eb8..d00744b 100644 --- a/ctrack/register/tests/test_event_models.py +++ b/ctrack/register/tests/test_event_models.py @@ -2,11 +2,25 @@ import datetime import pytest -from ctrack.register.models import MeetingEvent, EventType, SingleDateTimeEvent +from ctrack.register.models import MeetingEvent, EventType, SingleDateTimeEvent, CAFSingleDateEvent pytestmark = pytest.mark.django_db +def test_caf_initial_caf_received(user, caf): + uname = user.name + now = datetime.datetime.now() + e = CAFSingleDateEvent.objects.create( + type_descriptor="CAF_INITIAL_CAF_RECEIVED", + related_caf=caf, + short_description="CAF received for X Company", + date="2020-10-10", + comments="Nice comments for this event", + user=user + ) + assert e.created_date.day == now.day + + def test_event_type_enum(): assert EventType.MEETING.name == "MEETING" assert EventType.PHONE_CALL.name == "PHONE_CALL" |