diff --git a/apps/activity/forms.py b/apps/activity/forms.py index 6ef8a278..1602eb63 100644 --- a/apps/activity/forms.py +++ b/apps/activity/forms.py @@ -29,13 +29,6 @@ class ActivityForm(forms.ModelForm): class GuestForm(forms.ModelForm): - def clean(self, **kwargs): - cleaned_data = super().clean() - - self.instance.activity = cleaned_data["activity"] = Activity.objects.get(pk=1) - - return cleaned_data - class Meta: model = Guest fields = ('last_name', 'first_name', 'inviter', ) diff --git a/apps/activity/urls.py b/apps/activity/urls.py index 006dcce3..f074e8f7 100644 --- a/apps/activity/urls.py +++ b/apps/activity/urls.py @@ -10,7 +10,7 @@ app_name = 'activity' urlpatterns = [ path('', views.ActivityListView.as_view(), name='activity_list'), path('/', views.ActivityDetailView.as_view(), name='activity_detail'), - path('/invite/', views.ActivityInviteView.as_view(), name='activity_invite'), + path('/invite/', views.ActivityInviteView.as_view(), name='activity_invite'), path('/entry/', views.ActivityEntryView.as_view(), name='activity_entry'), path('/update/', views.ActivityUpdateView.as_view(), name='activity_update'), path('new/', views.ActivityCreateView.as_view(), name='activity_create'), diff --git a/apps/activity/views.py b/apps/activity/views.py index 03fa793f..10e073f0 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -43,9 +43,15 @@ class ActivityUpdateView(LoginRequiredMixin, UpdateView): class ActivityInviteView(LoginRequiredMixin, CreateView): model = Guest form_class = GuestForm - success_url = reverse_lazy('activity:activity_list') template_name = "activity/activity_invite.html" + def form_valid(self, form): + form.instance.activity = Activity.objects.get(pk=self.kwargs["pk"]) + return super().form_valid(form) + + def get_success_url(self, **kwargs): + return reverse_lazy('activity:activity_detail', kwargs={"pk": self.kwargs["pk"]}) + class ActivityEntryView(LoginRequiredMixin, TemplateView): pass