diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-12 20:33:04 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-12 20:33:04 +0100 |
commit | 29028b60b46693c2ad9e786a61bd5e94bf6c7fa6 (patch) | |
tree | 4c22a1ad582bd523e223a589eaab779a4e13a55a /ctrack | |
parent | 7bec7a48f26fb5671c5c05ea28f1a631c742728d (diff) |
first view test for events
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/register/tests/test_views.py | 18 | ||||
-rw-r--r-- | ctrack/register/urls.py | 6 | ||||
-rw-r--r-- | ctrack/register/views.py | 13 |
3 files changed, 35 insertions, 2 deletions
diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py new file mode 100644 index 0000000..51fceac --- /dev/null +++ b/ctrack/register/tests/test_views.py @@ -0,0 +1,18 @@ +import pytest + +from ctrack.register.views import SingleDateTimeEventCreate + +pytestmark = pytest.mark.django_db + + +class TestSingleDateFormView: + def test_single_datetime_event_form(self, user, request_factory): + view = SingleDateTimeEventCreate() + request = request_factory.get("/register/event/create-single-datetime/") + request.user = user + view.request = request + response = SingleDateTimeEventCreate.as_view()(request) + assert response.status_code == 200 + assert not response.context_data["form"].is_bound + for k in ["type_descriptor", "short_description", "datetime", "comments", "location"]: + assert k in response.context_data["form"].fields diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py index c5afb73..d5c21cb 100644 --- a/ctrack/register/urls.py +++ b/ctrack/register/urls.py @@ -1,6 +1,7 @@ from django.urls import path -from ctrack.register.views import EngagementEventCreate, EngagementEventDelete, EngagementEventCreateFromCaf +from ctrack.register.views import EngagementEventCreate, EngagementEventDelete, EngagementEventCreateFromCaf, \ + SingleDateTimeEventCreate app_name = "register" @@ -13,5 +14,8 @@ urlpatterns = [ ), path( "engagement-event/create/from-caf/<int:caf_id>", view=EngagementEventCreateFromCaf.as_view(), name="create_from_caf" + ), + path( + "event/create-single-datetime", view=SingleDateTimeEventCreate.as_view(), name="event_create_singledatetime" ) ] diff --git a/ctrack/register/views.py b/ctrack/register/views.py index eb2d748..b60d2be 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -6,7 +6,7 @@ from django.views.generic import FormView, DeleteView from ctrack.caf.models import CAF from ctrack.organisations.models import Organisation -from ctrack.register.forms import EngagementEventCreateForm +from ctrack.register.forms import EngagementEventCreateForm, AddMeetingForm from ctrack.register.models import EngagementEvent @@ -70,3 +70,14 @@ class EngagementEventCreateFromCaf(LoginRequiredMixin, FormView): def get_success_url(self): org_slug = CAF.objects.get(pk=self.kwargs["caf_id"]).organisation.slug return reverse_lazy("organisations:detail", args=[org_slug]) + + +class SingleDateTimeEventCreate(LoginRequiredMixin, FormView): + template_name = "single_datetime_event_create.html" + form_class = AddMeetingForm + success_url = "/" + + def get_form_kwargs(self): + kwargs = super().get_form_kwargs() + kwargs["user"] = self.request.user + return kwargs |