Add URL to find episode by submission ID

This commit is contained in:
Evert Prants 2017-12-29 16:27:26 +02:00
parent 7481f245fd
commit da82bddd05
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 9 additions and 0 deletions

View File

@ -41,6 +41,7 @@ urlpatterns = [
url(r'^season/(?P<season>\d{1,4})/append$', views.EpisodeSubmitForm),
url(r'^submission/(?P<submission>\d{1,4})/moderate$', views.SubmissionModForm),
url(r'^submission/(?P<submission>\d{1,4})/report$', views.ReportSubmission),
url(r'^episode/by-submission/(?P<submission>\d{1,4})$', views.EpisodeFindSubmission),
url(r'^episode/(?P<season>\d{1,4})/(?P<episode>\d{1,4})(-[\w-]+)?/?$', views.EpisodeView.as_view()),
url(r'^episode/(?P<season>\d{1,4})/(?P<episode>\d{1,4})(-[\w-]+)?/submit$', views.SubmissionForm),
url(r'^vote/(?P<subid>\d+)/(?P<positive>[0-1])/?$', views.SubmissionVoteSubmit.as_view())

View File

@ -90,6 +90,14 @@ class EpisodeView(TemplateView):
return ctx
def EpisodeFindSubmission(req, abbr, submission):
show = get_object_or_404(Show, abbr=abbr)
submission = int(submission)
episode = get_object_or_404(Episode, submissions__id=submission)
return HttpResponseRedirect('/show/%s/episode/%d/%d?submission=%d'%(abbr, episode.season.number, episode.episode, submission))
# Submission form GET and POST
@login_required
def SubmissionForm(req, abbr, season, episode):