add wait for others view
This commit is contained in:
parent
e5275db8e8
commit
0d0cc2eeb5
|
@ -65,4 +65,4 @@ class StoryPart(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def finished(self):
|
def finished(self):
|
||||||
return self.text
|
return bool(self.text)
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Die nächste Runde ist noch nicht bereit.</div>
|
||||||
|
<div>Klick hier um zu prüfen, ob die anderen fertig sind:
|
||||||
|
<a href="{% url 'writing:redirect_story_part' story_round_pk=object.pk %}">nächste Runde</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -9,5 +9,6 @@ urlpatterns = [
|
||||||
path('<int:pk>/', views.DetailView.as_view(), name='detail'),
|
path('<int:pk>/', views.DetailView.as_view(), name='detail'),
|
||||||
path('create/', views.StoryRoundCreate.as_view(), name='create_story_round'),
|
path('create/', views.StoryRoundCreate.as_view(), name='create_story_round'),
|
||||||
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>/<int:story_pk>/<int:pk>/', views.StoryPartUpdate.as_view(), name='update_story_part'),
|
||||||
|
path('open/<int:pk>/waiting/', views.WaitForOthersView.as_view(), name='wait_for_others'),
|
||||||
path('open/<int:story_round_pk>/', views.RedirectToNextOpenPart.as_view(), name='redirect_story_part'),
|
path('open/<int:story_round_pk>/', views.RedirectToNextOpenPart.as_view(), name='redirect_story_part'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,13 +5,11 @@ from django.shortcuts import render, get_object_or_404
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy, reverse
|
||||||
from django.views import generic
|
from django.views.generic import CreateView, UpdateView, RedirectView, DetailView, ListView
|
||||||
from django.views.generic import CreateView, UpdateView, RedirectView
|
|
||||||
|
|
||||||
from writingtogether.models import Story, StoryPart, StoryRound
|
from writingtogether.models import Story, StoryPart, StoryRound
|
||||||
|
|
||||||
|
|
||||||
class IndexView(LoginRequiredMixin, generic.ListView):
|
class IndexView(LoginRequiredMixin, ListView):
|
||||||
template_name = 'writingtogether/index.html'
|
template_name = 'writingtogether/index.html'
|
||||||
context_object_name = 'open_story_round_list'
|
context_object_name = 'open_story_round_list'
|
||||||
|
|
||||||
|
@ -20,7 +18,7 @@ class IndexView(LoginRequiredMixin, generic.ListView):
|
||||||
return StoryRound.objects.order_by('-created')[:5]
|
return StoryRound.objects.order_by('-created')[:5]
|
||||||
|
|
||||||
|
|
||||||
class DetailView(LoginRequiredMixin, generic.DetailView):
|
class StoryRoundDetailView(LoginRequiredMixin, DetailView):
|
||||||
model = StoryRound
|
model = StoryRound
|
||||||
template_name = 'writingtogether/detail.html'
|
template_name = 'writingtogether/detail.html'
|
||||||
|
|
||||||
|
@ -92,6 +90,15 @@ class RedirectToNextOpenPart(LoginRequiredMixin, RedirectView):
|
||||||
|
|
||||||
story_part = story_round.get_next_story_part(user=self.request.user)
|
story_part = story_round.get_next_story_part(user=self.request.user)
|
||||||
|
|
||||||
|
if story_part.finished:
|
||||||
|
self.pattern_name = 'writing:wait_for_others'
|
||||||
|
kwargs['pk'] = kwargs.pop('story_round_pk')
|
||||||
|
else:
|
||||||
kwargs['story_pk'] = story_part.part_of.pk
|
kwargs['story_pk'] = story_part.part_of.pk
|
||||||
kwargs['pk'] = story_part.pk
|
kwargs['pk'] = story_part.pk
|
||||||
return super().get_redirect_url(*args, **kwargs)
|
return super().get_redirect_url(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class WaitForOthersView(LoginRequiredMixin, DetailView):
|
||||||
|
model = StoryRound
|
||||||
|
template_name = 'writingtogether/wait_for_others.html'
|
||||||
|
|
Loading…
Reference in New Issue