Commit cad17f07 authored by fred's avatar fred

check emission slug url part

parent 815e8022
......@@ -200,7 +200,12 @@ class EpisodeCreateView(CreateView):
return self.object.get_absolute_url()
class EpisodeDetailView(DetailView):
class EmissionEpisodeMixin(object):
def get_queryset(self):
return self.model.objects.filter(emission__slug=self.kwargs['emission_slug'])
class EpisodeDetailView(EmissionEpisodeMixin, DetailView):
model = Episode
def get_context_data(self, **kwargs):
......@@ -216,7 +221,7 @@ class EpisodeDetailView(DetailView):
return context
class EpisodeUpdateView(UpdateView):
class EpisodeUpdateView(EmissionEpisodeMixin, UpdateView):
form_class = EpisodeForm
model = Episode
......@@ -230,7 +235,7 @@ class EpisodeUpdateView(UpdateView):
return super(EpisodeUpdateView, self).get_success_url()
class EpisodeDeleteView(DeleteView):
class EpisodeDeleteView(EmissionEpisodeMixin, DeleteView):
model = Episode
def get_form(self, *args, **kwargs):
......@@ -578,7 +583,7 @@ class EmissionCloseChatView(DetailView):
return redirect(self.object.get_absolute_url())
class EpisodeRegieView(DetailView):
class EpisodeRegieView(EmissionEpisodeMixin, DetailView):
model = Episode
template_name = 'emissions/episode_regie.html'
......@@ -628,6 +633,7 @@ class EpisodeRegieView(DetailView):
return context
class EpisodeRegieUpdateOrderView(View):
def get(self, request, *args, **kwargs):
new_order = request.GET.getlist('new-order[]')
......@@ -667,7 +673,7 @@ class EpisodeRegieMarks(EpisodeRegieView):
return JSONResponse(obj)
class EpisodeStartView(RedirectView):
class EpisodeStartView(EmissionEpisodeMixin, RedirectView):
def get_redirect_url(self, emission_slug, slug):
episode = Episode.objects.get(slug=slug, emission__slug=emission_slug)
episode.effective_start = datetime.datetime.now()
......@@ -677,7 +683,8 @@ class EpisodeStartView(RedirectView):
kwargs={'emission_slug': emission_slug,
'slug': slug})
class EpisodeStopView(RedirectView):
class EpisodeStopView(EmissionEpisodeMixin, RedirectView):
def get_redirect_url(self, emission_slug, slug):
episode = Episode.objects.get(slug=slug, emission__slug=emission_slug)
episode.effective_end = datetime.datetime.now()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment