diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 11:05:42 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 11:05:42 +0100 |
commit | eb8497dcd3758d20447d4de977780c2c78a38613 (patch) | |
tree | f5c188ad01ac8db9156db587c821706396671100 | |
parent | c0067e3dd35f56ad0cf9452f9ef1e8532b6378b4 (diff) |
Improvements to simple event form.
-rw-r--r-- | ctrack/register/forms.py | 2 | ||||
-rw-r--r-- | ctrack/register/models.py | 14 | ||||
-rw-r--r-- | ctrack/register/templates/single_datetime_event_create.html | 5 | ||||
-rw-r--r-- | ctrack/register/tests/test_forms.py | 16 | ||||
-rw-r--r-- | ctrack/register/tests/test_models.py (renamed from ctrack/register/tests/test_event_models.py) | 15 |
5 files changed, 51 insertions, 1 deletions
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index 85a450e..adb154f 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -21,8 +21,10 @@ class CreateSimpleDateTimeEventForm(forms.ModelForm): model = SingleDateTimeEvent fields = [ "type_descriptor", + "private", "short_description", "datetime", + "participants", "requested_response_date", "response_received_date", "url", diff --git a/ctrack/register/models.py b/ctrack/register/models.py index 3ab760e..11e4a6b 100644 --- a/ctrack/register/models.py +++ b/ctrack/register/models.py @@ -17,6 +17,7 @@ class EventType(Enum): PHONE_CALL = auto() VIDEO_CALL = auto() EMAIL = auto() + NOTE = auto() # single date caf events CAF_INITIAL_CAF_RECEIVED = auto() CAF_FEEDBACK_EMAILED_OES = auto() @@ -157,18 +158,31 @@ class ResponseRequiredMixin(models.Model): abstract = True +class PrivateEventMixin(models.Model): + 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." + ) + + class Meta: + abstract = True + + class SingleDateTimeEvent( EventBase, ResponseRequiredMixin, URLEventMixin, ThirdPartyEventMixin, SingleDateTimeEventMixin, + PrivateEventMixin, ): AVAILABLE_TYPES = [ (EventType.MEETING.name, "Meeting"), (EventType.PHONE_CALL.name, "Phone Call"), (EventType.VIDEO_CALL.name, "Video Call"), (EventType.EMAIL.name, "Email"), + (EventType.NOTE.name, "Note"), ] type_descriptor = models.CharField( blank=False, max_length=50, choices=AVAILABLE_TYPES diff --git a/ctrack/register/templates/single_datetime_event_create.html b/ctrack/register/templates/single_datetime_event_create.html index f663dac..6e607be 100644 --- a/ctrack/register/templates/single_datetime_event_create.html +++ b/ctrack/register/templates/single_datetime_event_create.html @@ -4,7 +4,10 @@ {% load crispy_forms_tags %} {% block form %} - <h3 class="mt-2">Create a new Simple Event (Meeting, Phone call, Email)</h3> + <h3 class="mt-2">Create a new simple event</h3> + <p>Simple events are emails, phone calls, basic meetings, notes, deadlines, etc. + If you arrived at this page from an organisation's page, you are able to select + participants in the event from that organisation.</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 ac21abb..2307a20 100644 --- a/ctrack/register/tests/test_forms.py +++ b/ctrack/register/tests/test_forms.py @@ -60,6 +60,22 @@ def test_create_simple_datetime_event(user): assert form.is_valid() +def test_create_private_note(user): + form = CreateSimpleDateTimeEventForm( + { + "type_descriptor": "NOTE", + "short_description": "Test Short Description", + "datetime": "2010-10-10 10:00", + "requested_response_date": "2020-12-24", + "response_received_date": "2020-12-25", + "url": "https://fake.url.com", + "private": True, + "comments": "Test Comments not needed" + }, user=user, + ) + assert form.is_valid() + + def test_response_date_cannot_be_before_date(user): form = CreateSimpleDateTimeEventForm( { diff --git a/ctrack/register/tests/test_event_models.py b/ctrack/register/tests/test_models.py index e92b282..1f8923b 100644 --- a/ctrack/register/tests/test_event_models.py +++ b/ctrack/register/tests/test_models.py @@ -150,6 +150,7 @@ def test_event_type_enum(): assert EventType.PHONE_CALL.name == "PHONE_CALL" assert EventType.VIDEO_CALL.name == "VIDEO_CALL" assert EventType.EMAIL.name == "EMAIL" + assert EventType.NOTE.name == "NOTE" assert EventType.CAF_INITIAL_CAF_RECEIVED.name == "CAF_INITIAL_CAF_RECEIVED" assert EventType.CAF_FEEDBACK_EMAILED_OES.name == "CAF_FEEDBACK_EMAILED_OES" assert EventType.CAF_RECEIVED.name == "CAF_RECEIVED" @@ -217,3 +218,17 @@ def test_meeting_event(user, person): assert e.user.name == uname assert e.created_date.day == now.day assert e.modified_date.day == now.day + + +@pytest.mark.parametrize("allowed_type", ["NOTE"]) +def test_note_event(user, allowed_type): + e = SingleDateTimeEvent.objects.create( + type_descriptor=allowed_type, + short_description="Test short description", + datetime="2020-10-10 10:30", + comments="The guy I deal with at X Co Ltd is made of cheese,", + url="https://evidenceofcheese.com", + private=True, + user=user + ) + assert e.type_descriptor == allowed_type |