From 36de1771ce3becba922a8c415ab978f4e318ec31 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:02:41 +0200 Subject: [PATCH 01/10] Extend abbreviation length --- LandingPage/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LandingPage/models.py b/LandingPage/models.py index 53bbc91..58ab57e 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -30,7 +30,7 @@ class Show(TimestampedModel): verbose_name="Full Name" ) abbr = models.SlugField( - max_length=5, + max_length=16, unique=True, help_text="A short abbreviation of the show, for use in urls", verbose_name="Abbreviation" From 307fdd4f7b84b427e378c65dc02c663ac82f2b58 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:03:16 +0200 Subject: [PATCH 02/10] Make custom CSS nullable --- LandingPage/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/LandingPage/models.py b/LandingPage/models.py index 58ab57e..b0f6a08 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -60,6 +60,7 @@ class Show(TimestampedModel): css = models.FileField( storage=show_static_storage, upload_to=name_css, + null=True, help_text="The CSS stylesheet applied to this show's page", verbose_name="Custom Style" ) From 845845bb2e1c674be59befd3329df23e8388a579 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:03:49 +0200 Subject: [PATCH 03/10] Remove show moderators model --- LandingPage/models.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/LandingPage/models.py b/LandingPage/models.py index b0f6a08..319b8fc 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -145,32 +145,6 @@ class Ban(TimestampedModel): def __str__(self): return ("Permanent" if self.permanent else "Temporary") + " ban of %s"%self.user -class ShowModerator(TimestampedModel): - show = models.ForeignKey( - Show, - on_delete=models.CASCADE, - help_text='The show this user moderates', - verbose_name='Moderated Show', - related_name='moderators', - ) - user = models.ForeignKey( - User, - on_delete=models.CASCADE, - help_text='The user who moderates this show', - verbose_name='Moderator', - related_name='moderated_shows' - ) - appointed_by = models.ForeignKey( - User, - on_delete=models.SET_NULL, - related_name='appointed_mods', - null=True, - help_text='The user who appointed this moderator', - verbose_name='Appointed by' - ) - def __str__(self): - return "%s on %s"%(self.user,self.show.abbr) - class Report(TimestampedModel): reporter = models.ForeignKey( User, From 702e11de124b629cf5faa58f64399955c9e4e601 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:09:39 +0200 Subject: [PATCH 04/10] Add extra fields to Submission --- LandingPage/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/LandingPage/models.py b/LandingPage/models.py index 319b8fc..71a3860 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -270,6 +270,18 @@ class Submission(TimestampedModel): url = models.URLField( help_text='The link that was submitted', ) + title = models.TextField( + help_text='Title of the page', + blank=True + ) + embed = models.URLField( + help_text='Embed player link for this episode', + blank=True, + verbose_name='Embed URL' + ) + pinned = models.BooleanField( + help_text='Whether or not this submission is pinned' + ) tags = models.CharField( help_text='Tags applied to this link submission', max_length=200 From 19f258d9fdd9f91dbcf5df815486c200e511b99a Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:10:33 +0200 Subject: [PATCH 05/10] Fix admin --- LandingPage/admin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/LandingPage/admin.py b/LandingPage/admin.py index b772b2c..08a07e4 100644 --- a/LandingPage/admin.py +++ b/LandingPage/admin.py @@ -19,7 +19,6 @@ class ShowAdmin(GuardedModelAdmin): admin.site.register(Show, ShowAdmin) admin.site.register(User, SpecialUserAdmin) admin.site.register(Ban) -admin.site.register(ShowModerator) admin.site.register(Report) admin.site.register(ShowSubmission) admin.site.register(Season) From 14498260821ca9f46aa2a0967cf1c166a62ea666 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:16:20 +0200 Subject: [PATCH 06/10] Add views and pinned to discussion board --- LandingPage/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/LandingPage/models.py b/LandingPage/models.py index 4fde594..bc3c64e 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -296,7 +296,8 @@ class Submission(TimestampedModel): verbose_name='Embed URL' ) pinned = models.BooleanField( - help_text='Whether or not this submission is pinned' + help_text='Whether or not this submission is pinned', + default=False ) tags = models.CharField( help_text='Tags applied to this link submission', @@ -370,6 +371,14 @@ class DiscussionBoard(TimestampedModel): help_text='The body of the post', verbose_name='Body' ) + views = models.IntegerField( + help_text='The amount of times this board has been viewed', + default=0 + ) + pinned = models.BooleanField( + help_text='Whether or not this board is pinned', + default=False + ) def __str__(self): return '[%s] "%s" by %s'%(self.show.abbr, self.title, self.user) From 971730f1cb48d76acfb778ebbce77e890e9544cc Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:20:22 +0200 Subject: [PATCH 07/10] Make CSS field actually nullable.. --- LandingPage/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/LandingPage/models.py b/LandingPage/models.py index bc3c64e..e84d98e 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -77,6 +77,7 @@ class Show(TimestampedModel): storage=show_static_storage, upload_to=name_css, null=True, + blank=True, help_text="The CSS stylesheet applied to this show's page", verbose_name="Custom Style" ) From 2bcf645461a9bd6b126f78fd351b857773f2457b Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:24:27 +0200 Subject: [PATCH 08/10] Make season description optional --- LandingPage/models.py | 3 ++- Show/templates/episode.html | 6 +++++- Show/templates/episode_add.html | 19 ++++++++++++++++--- Show/templates/submit.html | 6 +++++- Show/templates/submit_mod.html | 6 +++++- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/LandingPage/models.py b/LandingPage/models.py index e84d98e..8a434a4 100644 --- a/LandingPage/models.py +++ b/LandingPage/models.py @@ -225,7 +225,8 @@ class Season(models.Model): help_text='The number of this season, starting at 1; For example, the first season to be aired would be number 1, and the second would be number 2' ) description = models.TextField( - help_text='A description of this season\'s happenings' + help_text='A description of this season\'s happenings', + blank=True ) artwork = models.ImageField( storage=show_static_storage, diff --git a/Show/templates/episode.html b/Show/templates/episode.html index 92eed67..431fdcf 100644 --- a/Show/templates/episode.html +++ b/Show/templates/episode.html @@ -34,7 +34,11 @@

Season {{ episode.season.number }}

{% endif %}

- {{ episode.season.description }} + {% if episode.season.description %} + {{ episode.season.description }} + {% else %} + {{ show.description }} + {% endif %}

diff --git a/Show/templates/episode_add.html b/Show/templates/episode_add.html index 786c5f1..2c4eed7 100644 --- a/Show/templates/episode_add.html +++ b/Show/templates/episode_add.html @@ -7,12 +7,25 @@ diff --git a/Show/templates/submit_mod.html b/Show/templates/submit_mod.html index 5d83de9..d3ffc83 100644 --- a/Show/templates/submit_mod.html +++ b/Show/templates/submit_mod.html @@ -21,7 +21,11 @@

Season {{ episode.season.number }}

{% endif %}

- {{ episode.season.description }} + {% if episode.season.description %} + {{ episode.season.description }} + {% else %} + {{ show.description }} + {% endif %}

From 1883792c7fd4447e91719311b8fc78f38a40a315 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:34:58 +0200 Subject: [PATCH 09/10] Pinning of submissions --- Show/templates/episode.html | 7 +++++-- Show/views.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Show/templates/episode.html b/Show/templates/episode.html index 431fdcf..b0ff05a 100644 --- a/Show/templates/episode.html +++ b/Show/templates/episode.html @@ -57,8 +57,11 @@

Watch {{episode.name}} From

{% for sbm in submissions %} -
-  {{sbm.url}} +
+ + {% if sbm.pinned %}{% endif %} +  {{sbm.url}} +
{% csrf_token %} diff --git a/Show/views.py b/Show/views.py index 185f1f1..531fef8 100644 --- a/Show/views.py +++ b/Show/views.py @@ -76,7 +76,7 @@ class EpisodeView(TemplateView): ), negatives=Count('votes') - F('positives'), score=F('positives') - F('negatives') - ).order_by('-score') + ).order_by('-pinned', '-score') # Add fields to context ctx['show'] = show From fdd43208ea5cffd2bb2c5ff3e7123bfdbfdb16b1 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Dec 2017 17:41:02 +0200 Subject: [PATCH 10/10] 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():