story part update now redirects back to index
This commit is contained in:
parent
1527f07fa3
commit
e09f17bdfb
|
@ -6,7 +6,7 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<form action="{% url 'writing:create_story_part' %}" method="post">
|
||||
<form action="{% url 'writing:update_story_part' story_round_pk=story_round_pk story_pk=story_pk pk=pk %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Submit">
|
||||
|
|
|
@ -8,6 +8,6 @@ urlpatterns = [
|
|||
path('', views.IndexView.as_view(), name='index'),
|
||||
path('<int:pk>/', views.DetailView.as_view(), name='detail'),
|
||||
path('create/', views.StoryRoundCreate.as_view(), name='create_story_round'),
|
||||
path('open/<int:story_round_pk>/<int:story_pk>/<int:story_part_pk>/', views.StoryPartUpdate.as_view(), name='update_story_part'),
|
||||
path('open/<int:story_round_pk>/<int:story_pk>/<int:pk>/', views.StoryPartUpdate.as_view(), name='update_story_part'),
|
||||
path('open/<int:story_round_pk>/', views.RedirectToNextOpenPart.as_view(), name='redirect_story_part'),
|
||||
]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue