From fdd43208ea5cffd2bb2c5ff3e7123bfdbfdb16b1 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:41:02 +0200 Subject: [PATCH] Allow show submission page titles to be displayed instead of the url, if available --- Show/forms.py | 5 +++++ Show/templates/episode.html | 6 +++++- Show/views.py | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Show/forms.py b/Show/forms.py index 37b907e..d809f21 100644 --- a/Show/forms.py +++ b/Show/forms.py @@ -26,6 +26,11 @@ class SubmissionForm(forms.ModelForm): 'tags': 'Describe your link. Comma-separated list of keywords' } +class SubmissionFormAdmin(forms.ModelForm): + class Meta(): + model = Submission + fields = ('title','url','embed','tags','pinned',) + class SeasonForm(forms.ModelForm): class Meta(): model = Season diff --git a/Show/templates/episode.html b/Show/templates/episode.html index b0ff05a..a4bca4e 100644 --- a/Show/templates/episode.html +++ b/Show/templates/episode.html @@ -60,7 +60,11 @@
{% if sbm.pinned %}{% endif %} -  {{sbm.url}} + {% if sbm.title %} + {{sbm.title}} + {% else %} +  {{sbm.url}} + {% endif %}
diff --git a/Show/views.py b/Show/views.py index 531fef8..04f4c78 100644 --- a/Show/views.py +++ b/Show/views.py @@ -145,7 +145,7 @@ def SubmissionModForm(req, abbr, submission): episode = submission.episode user = req.user - form = forms.SubmissionForm(instance=submission) + form = forms.SubmissionFormAdmin(instance=submission) # Request context ctx = { @@ -164,7 +164,7 @@ def SubmissionModForm(req, abbr, submission): submission.delete() return HttpResponseRedirect('/show/%s/create_ban?user=%s'%(abbr,submission.user.username)) - form = forms.SubmissionForm(req.POST, instance=submission) + form = forms.SubmissionFormAdmin(req.POST, instance=submission) ctx['form'] = form if form.is_valid():