diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 14:29:01 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 14:29:01 +0100 |
commit | 59592232da815f4e8c6f61cb9042e738990c1b6e (patch) | |
tree | 37f078cc978731f79fdda7a3fbf25473294857fd /ctrack/register | |
parent | 404981d748efc345fa7edfc8538306ce61ce81ad (diff) |
better handling of simple event form and participants
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/forms.py | 4 | ||||
-rw-r--r-- | ctrack/register/templates/single_datetime_event_create.html | 10 | ||||
-rw-r--r-- | ctrack/register/tests/test_views.py | 9 |
3 files changed, 18 insertions, 5 deletions
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index d658c9d..1549f75 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -39,7 +39,9 @@ class CreateSimpleDateTimeEventForm(forms.ModelForm): if self.org_slug: org = Organisation.objects.get(slug=self.org_slug) self.fields["participants"].queryset = org.get_people() - self.fields["participants"].help_text = f"Click to select participants from {org}" + self.fields["participants"].help_text = f"Click to select participants from {org}." + else: + self.fields["participants"].widget = forms.HiddenInput() def clean(self): cleaned_data = super().clean() diff --git a/ctrack/register/templates/single_datetime_event_create.html b/ctrack/register/templates/single_datetime_event_create.html index 6e607be..34ff22c 100644 --- a/ctrack/register/templates/single_datetime_event_create.html +++ b/ctrack/register/templates/single_datetime_event_create.html @@ -4,10 +4,14 @@ {% load crispy_forms_tags %} {% block form %} - <h3 class="mt-2">Create a new simple event</h3> + {% if org %} + <h3 class="mt-2">Create a new simple event involving {{ org }}</h3> + {% else %} + <h3 class="mt-2">Create a new simple event</h3> + {% endif %} <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> + 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_views.py b/ctrack/register/tests/test_views.py index 94edc4f..5f7ca35 100644 --- a/ctrack/register/tests/test_views.py +++ b/ctrack/register/tests/test_views.py @@ -108,9 +108,16 @@ class TestSingleDateTimeEvent: view.setup(request) assert "user" in view.get_form_kwargs() + def test_create_simple_event_without_org_means_no_participants(self, user, client): + client.force_login(user) + url = reverse("register:event_create_simple_event") + response = client.get(url) + html = response.content.decode("utf-8") + assert '<input type="hidden" name="participants" id="id_participants">' in html + def test_can_create_simple_event_with_org_slug(self, user, org, client): slug = org.slug - url = f"/register/event/create-simple-event-from-org/{slug}" + url = reverse("register:event_create_simple_event_from_org", args=[slug]) client.force_login(user) response = client.get(url) html = response.content.decode("utf-8") |