diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-18 14:50:00 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-18 14:50:00 +0100 |
commit | fed4b3157f25f65ccdaa5fd41463995a080d4673 (patch) | |
tree | 9ad2cea4a1076663f18ed27e738da979dfe7e128 | |
parent | bc10c9df7b9d3678e4efd9d05055f41ccd8a763f (diff) |
nice links from org detail page to specific types of simple event
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/templates/organisations/organisation_detail.html | 10 | ||||
-rw-r--r-- | ctrack/register/forms.py | 3 | ||||
-rw-r--r-- | ctrack/register/tests/test_views.py | 15 | ||||
-rw-r--r-- | ctrack/register/urls.py | 13 | ||||
-rw-r--r-- | ctrack/register/views.py | 2 |
5 files changed, 33 insertions, 10 deletions
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html index 862bff4..5a510ee 100644 --- a/ctrack/organisations/templates/organisations/organisation_detail.html +++ b/ctrack/organisations/templates/organisations/organisation_detail.html @@ -230,14 +230,14 @@ d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/> <path d="M2.56 11.332L3.1 9.73h1.984l.54 1.602h.718L4.444 6h-.696L1.85 11.332h.71zm1.544-4.527L4.9 9.18H3.284l.8-2.375h.02zm5.746.422h-.676V9.77c0 .652-.414 1.023-1.004 1.023-.539 0-.98-.246-.98-1.012V7.227h-.676v2.746c0 .941.606 1.425 1.453 1.425.656 0 1.043-.28 1.188-.605h.027v.539h.668V7.227zm2.258 5.046c-.563 0-.91-.304-.985-.636h-.687c.094.683.625 1.199 1.668 1.199.93 0 1.746-.527 1.746-1.578V7.227h-.649v.578h-.019c-.191-.348-.637-.64-1.195-.64-.965 0-1.64.679-1.64 1.886v.34c0 1.23.683 1.902 1.64 1.902.558 0 1.008-.293 1.172-.648h.02v.605c0 .645-.423 1.023-1.071 1.023zm.008-4.53c.648 0 1.062.527 1.062 1.359v.253c0 .848-.39 1.364-1.062 1.364-.692 0-1.098-.512-1.098-1.364v-.253c0-.868.406-1.36 1.098-1.36z"/> </svg> - <a href="#">New meeting</a> | + <a href="{% url "register:event_create_simple_event_from_org_with_type" object.slug 'MEETING' %}">New meeting</a> | <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-telephone-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M2.267.98a1.636 1.636 0 0 1 2.448.152l1.681 2.162c.309.396.418.913.296 1.4l-.513 2.053a.636.636 0 0 0 .167.604L8.65 9.654a.636.636 0 0 0 .604.167l2.052-.513a1.636 1.636 0 0 1 1.401.296l2.162 1.681c.777.604.849 1.753.153 2.448l-.97.97c-.693.693-1.73.998-2.697.658a17.47 17.47 0 0 1-6.571-4.144A17.47 17.47 0 0 1 .639 4.646c-.34-.967-.035-2.004.658-2.698l.97-.969z"/> </svg> - <a href="#">New phone call</a> | + <a href="{% url "register:event_create_simple_event_from_org_with_type" object.slug 'PHONE_CALL' %}">New phone call</a> | <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-camera-video" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> @@ -245,7 +245,7 @@ d="M0 5a2 2 0 0 1 2-2h7.5a2 2 0 0 1 1.983 1.738l3.11-1.382A1 1 0 0 1 16 4.269v7.462a1 1 0 0 1-1.406.913l-3.111-1.382A2 2 0 0 1 9.5 13H2a2 2 0 0 1-2-2V5zm11.5 5.175l3.5 1.556V4.269l-3.5 1.556v4.35zM2 4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1H2z"/> </svg> - <a href="#">New video call</a> | + <a href="{% url "register:event_create_simple_event_from_org_with_type" object.slug 'VIDEO_CALL' %}">New video call</a> | <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-envelope" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> @@ -253,7 +253,7 @@ d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2zm13 2.383l-4.758 2.855L15 11.114v-5.73zm-.034 6.878L9.271 8.82 8 9.583 6.728 8.82l-5.694 3.44A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.739zM1 11.114l4.758-2.876L1 5.383v5.73z"/> </svg> - <a href="#">New email</a> | + <a href="{% url "register:event_create_simple_event_from_org_with_type" object.slug 'EMAIL' %}">New email</a> | <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-journal-text" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> @@ -262,7 +262,7 @@ <path fill-rule="evenodd" d="M5 10.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/> </svg> - <a href="#">New note</a> + <a href="{% url "register:event_create_simple_event_from_org_with_type" object.slug 'NOTE' %}">New note</a> </div> diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index 1549f75..b061ec3 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -35,11 +35,14 @@ class CreateSimpleDateTimeEventForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.user = kwargs.pop("user") self.org_slug = kwargs.pop("org_slug") + self.event_type = kwargs.pop("event_type") super().__init__(*args, **kwargs) 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}." + if self.event_type: + self.fields["type_descriptor"].initial = self.event_type else: self.fields["participants"].widget = forms.HiddenInput() diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py index 5f7ca35..0f5575d 100644 --- a/ctrack/register/tests/test_views.py +++ b/ctrack/register/tests/test_views.py @@ -127,13 +127,26 @@ class TestSingleDateTimeEvent: def test_org_passed_as_kwarg(self, user, org, request_factory): slug = org.slug view = SingleDateTimeEventCreate() - url = f"/register/event/create-simple-event-from-org/{slug}" + url = reverse("register:event_create_simple_event_from_org", args=[slug]) request = request_factory.get(url) request.user = user view.request = request view.setup(request) assert "org_slug" in view.get_form_kwargs() + def test_meeting_type_and_org_passed_as_kwarg( + self, user, org, request_factory + ): + event_type = "PHONE_CALL" + slug = org.slug + view = SingleDateTimeEventCreate() + url = reverse("register:event_create_simple_event_from_org_with_type", args=[slug, event_type]) + request = request_factory.get(url) + request.user = user + view.request = request + view.setup(request) + assert "event_type" in view.get_form_kwargs() + class TestSingleDateCAFEventViews: def test_initial_caf_received(self, client): diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py index 3e85243..14c9798 100644 --- a/ctrack/register/urls.py +++ b/ctrack/register/urls.py @@ -30,9 +30,16 @@ urlpatterns = [ view=SingleDateTimeEventCreate.as_view(), name="event_create_simple_event", ), - path("event/create-simple-event-from-org/<slug:org_slug>", - view=SingleDateTimeEventCreate.as_view(), - name="event_create_simple_event_from_org") + path( + "event/create-simple-event-from-org/<slug:org_slug>", + view=SingleDateTimeEventCreate.as_view(), + name="event_create_simple_event_from_org", + ), + path( + "event/create-simple-event-from-org/<slug:org_slug>/<str:event_type>", + view=SingleDateTimeEventCreate.as_view(), + name="event_create_simple_event_from_org_with_type", + ) # path( # "event/create-caf-single-date-event", # view=CAFSingleDateEventView.as_view(), diff --git a/ctrack/register/views.py b/ctrack/register/views.py index 0ab71c3..07673b9 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -84,11 +84,11 @@ class SingleDateTimeEventCreate(FormView): return context return context - def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs["user"] = self.request.user kwargs["org_slug"] = self.kwargs.get("org_slug") + kwargs["event_type"] = self.kwargs.get("event_type") return kwargs def form_valid(self, form): |