diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 10:36:11 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 10:36:11 +0100 |
commit | c0067e3dd35f56ad0cf9452f9ef1e8532b6378b4 (patch) | |
tree | 9c834f6f194f0f38046975870c3504d4292ad8f5 | |
parent | 2b11d0e43378c27b250e93e91b9bdc10346af44e (diff) |
added URL field for a simple event
-rw-r--r-- | ctrack/register/forms.py | 3 | ||||
-rw-r--r-- | ctrack/register/models.py | 44 | ||||
-rw-r--r-- | ctrack/register/tests/test_event_models.py | 1 | ||||
-rw-r--r-- | ctrack/register/tests/test_forms.py | 1 |
4 files changed, 42 insertions, 7 deletions
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index 9f8aec5..85a450e 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -25,8 +25,9 @@ class CreateSimpleDateTimeEventForm(forms.ModelForm): "datetime", "requested_response_date", "response_received_date", - "comments", + "url", "location", + "comments", ] def __init__(self, *args, **kwargs): diff --git a/ctrack/register/models.py b/ctrack/register/models.py index 932dd69..3ab760e 100644 --- a/ctrack/register/models.py +++ b/ctrack/register/models.py @@ -88,14 +88,36 @@ class EventBase(AuditableEventBase): class ThirdPartyEventMixin(models.Model): participants = models.ManyToManyField(Person, blank=True) - location = models.CharField(max_length=100, blank=True) + location = models.CharField( + max_length=100, + blank=True, + help_text="If event involved a physical location, indicate here.", + ) + + class Meta: + abstract = True + + +class URLEventMixin(models.Model): + url = models.URLField( + max_length=400, + blank=True, + null=True, + verbose_name="URL", + help_text=( + "If recording an email, please link to it here. " + "Do not paste the text in the comments box." + ), + ) # these fuckers can get long with SharePoint class Meta: abstract = True class SingleDateTimeEventMixin(models.Model): - datetime = models.DateTimeField(blank=False, verbose_name="Date/Time", help_text="DD/MM/YY HH:MM format please!") + datetime = models.DateTimeField( + blank=False, verbose_name="Date/Time", help_text="DD/MM/YY HH:MM format please!" + ) class Meta: abstract = True @@ -124,19 +146,29 @@ class CAFMixin(models.Model): class ResponseRequiredMixin(models.Model): - requested_response_date = models.DateField(blank=True, null=True, help_text="DD/MM/YY format") - response_received_date = models.DateField(blank=True, null=True, help_text="DD/MM/YY format") + requested_response_date = models.DateField( + blank=True, null=True, help_text="DD/MM/YY format" + ) + response_received_date = models.DateField( + blank=True, null=True, help_text="DD/MM/YY format" + ) class Meta: abstract = True -class SingleDateTimeEvent(EventBase, ResponseRequiredMixin, ThirdPartyEventMixin, SingleDateTimeEventMixin): +class SingleDateTimeEvent( + EventBase, + ResponseRequiredMixin, + URLEventMixin, + ThirdPartyEventMixin, + SingleDateTimeEventMixin, +): AVAILABLE_TYPES = [ (EventType.MEETING.name, "Meeting"), (EventType.PHONE_CALL.name, "Phone Call"), (EventType.VIDEO_CALL.name, "Video Call"), - (EventType.EMAIL.name, "Email") + (EventType.EMAIL.name, "Email"), ] type_descriptor = models.CharField( blank=False, max_length=50, choices=AVAILABLE_TYPES diff --git a/ctrack/register/tests/test_event_models.py b/ctrack/register/tests/test_event_models.py index 6469ea7..e92b282 100644 --- a/ctrack/register/tests/test_event_models.py +++ b/ctrack/register/tests/test_event_models.py @@ -170,6 +170,7 @@ def test_single_datetime_event(person, user, allowed_type): event = SingleDateTimeEvent.objects.create( type_descriptor=allowed_type, short_description="Important event", + url = "http://fake.url.com", requested_response_date="2021-01-24", response_received_date=None, datetime="2020-10-10T15:00", diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py index 16d81ae..ac21abb 100644 --- a/ctrack/register/tests/test_forms.py +++ b/ctrack/register/tests/test_forms.py @@ -53,6 +53,7 @@ def test_create_simple_datetime_event(user): "datetime": "2010-10-10 10:00", "requested_response_date": "2020-12-24", "response_received_date": "2020-12-25", + "url": "https://fake.url.com", "comments": "Test Comments not needed" }, user=user, ) |