diff --git a/stories/writingtogether/templates/writingtogether/story_part.html b/stories/writingtogether/templates/writingtogether/story_part.html index 0dd732e..494d145 100644 --- a/stories/writingtogether/templates/writingtogether/story_part.html +++ b/stories/writingtogether/templates/writingtogether/story_part.html @@ -6,7 +6,7 @@ -
+ {% csrf_token %} {{ form.as_p }} diff --git a/stories/writingtogether/urls.py b/stories/writingtogether/urls.py index ccb2f63..ff29a68 100644 --- a/stories/writingtogether/urls.py +++ b/stories/writingtogether/urls.py @@ -8,6 +8,6 @@ urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('/', views.DetailView.as_view(), name='detail'), path('create/', views.StoryRoundCreate.as_view(), name='create_story_round'), - path('open////', views.StoryPartUpdate.as_view(), name='update_story_part'), + path('open////', views.StoryPartUpdate.as_view(), name='update_story_part'), path('open//', views.RedirectToNextOpenPart.as_view(), name='redirect_story_part'), ] diff --git a/stories/writingtogether/views.py b/stories/writingtogether/views.py index dbb3790..cc43727 100644 --- a/stories/writingtogether/views.py +++ b/stories/writingtogether/views.py @@ -63,6 +63,13 @@ class StoryPartUpdate(LoginRequiredMixin, UpdateView): model = StoryPart fields = ['text'] template_name = 'writingtogether/story_part.html' + success_url = reverse_lazy('writing:index') + + def get_context_data(self, **kwargs): + context = super(StoryPartUpdate, self).get_context_data(**kwargs) + context.update(self.kwargs) + return context + #def form_valid(self, form): # form.instance.created_by = self.request.user @@ -82,5 +89,5 @@ class RedirectToNextOpenPart(LoginRequiredMixin, RedirectView): story_part = story_round.get_next_story_part(user=self.request.user) kwargs['story_pk'] = story_part.part_of.pk - kwargs['story_part_pk'] = story_part.pk + kwargs['pk'] = story_part.pk return super().get_redirect_url(*args, **kwargs)