From 87587f8ff93964451e89692f86447fb40db0b610 Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Sat, 25 Jan 2020 05:57:15 -0500 Subject: [PATCH 1/3] Fix failing emded_code test --- .gitignore | 1 + hth/templates/embed_video/embed_code.html | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e3e94b2..9edef07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__/ +.pytest_cache/ *.py[cod] venv/ htmlcov/ diff --git a/hth/templates/embed_video/embed_code.html b/hth/templates/embed_video/embed_code.html index d5eaaaa..733dce5 100644 --- a/hth/templates/embed_video/embed_code.html +++ b/hth/templates/embed_video/embed_code.html @@ -1,5 +1 @@ - + From aa3bb7b742c00fa9983e4371fb68d7183cc36694 Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Sat, 25 Jan 2020 06:29:40 -0500 Subject: [PATCH 2/3] Add Video.priority --- hth/music/migrations/0013_video_priority.py | 20 ++++++++++ hth/music/models.py | 5 ++- hth/music/tests/test_models.py | 41 +++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 hth/music/migrations/0013_video_priority.py diff --git a/hth/music/migrations/0013_video_priority.py b/hth/music/migrations/0013_video_priority.py new file mode 100644 index 0000000..7c7ba86 --- /dev/null +++ b/hth/music/migrations/0013_video_priority.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.27 on 2020-01-25 11:27 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('music', '0012_auto_20160704_1559'), + ] + + operations = [ + migrations.AddField( + model_name='video', + name='priority', + field=models.PositiveIntegerField(blank=True, help_text='Site-wide sort order (higher numbers first)', null=True), + ), + ] diff --git a/hth/music/models.py b/hth/music/models.py index d3464f6..da3f8d3 100644 --- a/hth/music/models.py +++ b/hth/music/models.py @@ -102,9 +102,12 @@ class Video(PublishedModel, TitledModel): description = models.TextField(blank=True) credits = models.TextField(blank=True) release = models.ForeignKey(Release, blank=True, null=True) + priority = models.PositiveIntegerField( + help_text='Site-wide sort order (higher numbers first)', + blank=True, null=True) class Meta: - ordering = ['publish', '-publish_on'] + ordering = ['-priority', 'publish', '-publish_on'] def save(self, *args, **kwargs): if self.source_url and not (self.preview_url and self.embed_code): diff --git a/hth/music/tests/test_models.py b/hth/music/tests/test_models.py index f4f54f6..88f1a1a 100644 --- a/hth/music/tests/test_models.py +++ b/hth/music/tests/test_models.py @@ -112,6 +112,25 @@ def test_ordered_by_date(self): self.assertEqual(list(Video.objects.all()), [draft, new, first, old]) + def test_ordered_by_priority(self): + third = PublishedVideoFactory.create( + publish_on=datetime(2014, 8, 1, tzinfo=timezone.utc), + priority=1) + + first = PublishedVideoFactory.create( + publish_on=datetime(2014, 7, 31, tzinfo=timezone.utc), + priority=10) + + fourth = PublishedVideoFactory.create( + publish_on=datetime(2014, 7, 1, tzinfo=timezone.utc)) + + second = PublishedVideoFactory.create( + publish_on=datetime(2014, 8, 31, tzinfo=timezone.utc), + priority=1) + + self.assertEqual(list(Video.objects.all()), + [first, second, third, fourth]) + def test_can_be_added_to_release(self): r = PublishedReleaseFactory.create() @@ -138,6 +157,28 @@ def test_release_videos_ordered_by_date(self): self.assertEqual(list(r.videos.all()), [new, first, old]) + def test_release_videos_ordered_by_priority(self): + r = PublishedReleaseFactory.create() + + third = PublishedVideoFactory.create( + publish_on=datetime(2014, 8, 1, tzinfo=timezone.utc), + priority=1, release=r) + + first = PublishedVideoFactory.create( + publish_on=datetime(2014, 7, 31, tzinfo=timezone.utc), + priority=10, release=r) + + fourth = PublishedVideoFactory.create( + publish_on=datetime(2014, 7, 1, tzinfo=timezone.utc), + release=r) + + second = PublishedVideoFactory.create( + publish_on=datetime(2014, 8, 31, tzinfo=timezone.utc), + priority=1, release=r) + + self.assertEqual(list(r.videos.all()), + [first, second, third, fourth]) + class VideoAutofillTestCase(TestCase): From bb3cb6200870aa5c9b0bd8dc617f1ded1c770c8a Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Sat, 25 Jan 2020 06:42:44 -0500 Subject: [PATCH 3/3] Add priority to admin --- hth/jahhills.json | 111 ++++++++++++++++++++++++++++++--------------- hth/music/admin.py | 6 ++- 2 files changed, 78 insertions(+), 39 deletions(-) diff --git a/hth/jahhills.json b/hth/jahhills.json index 5e42500..18aebfe 100644 --- a/hth/jahhills.json +++ b/hth/jahhills.json @@ -1788,7 +1788,8 @@ "preview_url": "https://img.youtube.com/vi/v0wsVdRvKP8/hqdefault.jpg", "description": "", "credits": "", - "release": 1 + "release": 1, + "priority": null } }, { @@ -1804,7 +1805,8 @@ "preview_url": "https://img.youtube.com/vi/nOfHnxgtuB0/hqdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -1820,7 +1822,8 @@ "preview_url": "https://img.youtube.com/vi/Tmh1zmIpZKI/hqdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -1836,7 +1839,8 @@ "preview_url": "https://img.youtube.com/vi/Sl3_u51Jw8k/hqdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -1852,7 +1856,8 @@ "preview_url": "https://img.youtube.com/vi/59cbFQnBLsg/hqdefault.jpg", "description": "", "credits": "", - "release": 3 + "release": 3, + "priority": null } }, { @@ -1868,7 +1873,8 @@ "preview_url": "https://i.vimeocdn.com/video/33474406_640.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -1884,7 +1890,8 @@ "preview_url": "https://i.vimeocdn.com/video/26930319_640.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -1900,7 +1907,8 @@ "preview_url": "https://img.youtube.com/vi/P_WLB3VsrIM/hqdefault.jpg", "description": "", "credits": "", - "release": 3 + "release": 3, + "priority": null } }, { @@ -1916,7 +1924,8 @@ "preview_url": "https://img.youtube.com/vi/tAMliN9QcP0/hqdefault.jpg", "description": "", "credits": "", - "release": 9 + "release": 9, + "priority": null } }, { @@ -1932,7 +1941,8 @@ "preview_url": "https://img.youtube.com/vi/jGPDc-R0wcE/hqdefault.jpg", "description": "", "credits": "", - "release": 3 + "release": 3, + "priority": null } }, { @@ -1948,7 +1958,8 @@ "preview_url": "https://img.youtube.com/vi/zLKaes54BPM/maxresdefault.jpg", "description": "", "credits": "", - "release": 7 + "release": 7, + "priority": null } }, { @@ -1964,7 +1975,8 @@ "preview_url": "https://img.youtube.com/vi/lPvL_n_z1S4/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -1980,7 +1992,8 @@ "preview_url": "https://i.vimeocdn.com/video/302578255_640.jpg", "description": "", "credits": "", - "release": 7 + "release": 7, + "priority": null } }, { @@ -1996,7 +2009,8 @@ "preview_url": "https://i.vimeocdn.com/video/304545540_640.jpg", "description": "", "credits": "", - "release": 7 + "release": 7, + "priority": null } }, { @@ -2012,7 +2026,8 @@ "preview_url": "https://img.youtube.com/vi/2VtZF_MNk7o/maxresdefault.jpg", "description": "", "credits": "", - "release": 7 + "release": 7, + "priority": null } }, { @@ -2028,7 +2043,8 @@ "preview_url": "https://img.youtube.com/vi/_MpoV3nN5ZM/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2044,7 +2060,8 @@ "preview_url": "https://img.youtube.com/vi/QXgTDyatfvE/maxresdefault.jpg", "description": "", "credits": "", - "release": 9 + "release": 9, + "priority": null } }, { @@ -2060,7 +2077,8 @@ "preview_url": "https://img.youtube.com/vi/Y_bu8VG8R1U/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2076,7 +2094,8 @@ "preview_url": "https://img.youtube.com/vi/kEe0RD1Mr7s/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2092,7 +2111,8 @@ "preview_url": "https://img.youtube.com/vi/2GAxATJ74_A/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2108,7 +2128,8 @@ "preview_url": "https://img.youtube.com/vi/8XK-vkOZh_c/maxresdefault.jpg", "description": "", "credits": "", - "release": 10 + "release": 10, + "priority": null } }, { @@ -2124,7 +2145,8 @@ "preview_url": "https://img.youtube.com/vi/zW2Msqaclls/maxresdefault.jpg", "description": "", "credits": "", - "release": 10 + "release": 10, + "priority": null } }, { @@ -2140,7 +2162,8 @@ "preview_url": "https://img.youtube.com/vi/SeMhvXc5W-I/maxresdefault.jpg", "description": "", "credits": "", - "release": 10 + "release": 10, + "priority": null } }, { @@ -2156,7 +2179,8 @@ "preview_url": "https://img.youtube.com/vi/Bu0q0v84Xds/maxresdefault.jpg", "description": "", "credits": "", - "release": 10 + "release": 10, + "priority": null } }, { @@ -2172,7 +2196,8 @@ "preview_url": "https://img.youtube.com/vi/YuY1EZXq2eQ/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2188,7 +2213,8 @@ "preview_url": "https://img.youtube.com/vi/SKrQtNpixtI/maxresdefault.jpg", "description": "", "credits": "", - "release": 10 + "release": 10, + "priority": null } }, { @@ -2204,7 +2230,8 @@ "preview_url": "https://img.youtube.com/vi/TZU2mWTwTeY/sddefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2220,7 +2247,8 @@ "preview_url": "https://img.youtube.com/vi/SqwdsgOPMOM/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2236,7 +2264,8 @@ "preview_url": "https://i.vimeocdn.com/video/517362144_640.jpg", "description": "", "credits": "

Directed/Edited by Ryan Hamilton Walsh

\r\n\r\n

Cast

\r\n\r\n

Ryan Connelly as Bear Boy
\r\nBrian Rutledge
\r\nJoseph Marrett
\r\nNicholas Giandone Ward
\r\nRyan Hamilton Walsh
\r\nColleen Matthews
\r\nKelly Teer
\r\nPete Schluter
\r\nNick Stanisha
\r\nChristine Fernsebner Eslao
\r\nJeff Walsh
\r\nMike O\u2019Brien
\r\nJohn Benda
\r\nDean Ward
\r\nKathleen Giadone

\r\n\r\n

Mask Design by Wintercroft

\r\n\r\n

Mask Assembly

\r\n\r\n

Nicholas Giadone Ward
\r\nRyan Hamilton Walsh
\r\nBrian Rutledge
\r\nRyan Connelly

\r\n\r\n

Special Thanks

\r\n\r\n

Crystal Ren\u00e9 Burney
\r\nCharles Morton
\r\nThe Tavern at the End of the World

", - "release": 10 + "release": 10, + "priority": null } }, { @@ -2252,7 +2281,8 @@ "preview_url": "https://img.youtube.com/vi/3lkVl3hyBXE/maxresdefault.jpg", "description": "

Some are calling this the best video of all time. I can't speak to that but I can say this video does contain actual footage from the recording studio where the real album title was revealed to the band. And it was...tense.

", "credits": "", - "release": 12 + "release": 12, + "priority": null } }, { @@ -2268,7 +2298,8 @@ "preview_url": "https://img.youtube.com/vi/2I0FQFGqcCc/maxresdefault.jpg", "description": "", "credits": "", - "release": 12 + "release": 12, + "priority": null } }, { @@ -2284,7 +2315,8 @@ "preview_url": "https://img.youtube.com/vi/C7uDxqn7dtY/maxresdefault.jpg", "description": "", "credits": "

Candle Eradicators: Mark Walsh, Mona Walsh, Julia Papps, Billy Kanellopoulos, Maura Johnston, Brad Nelson, Hatcher Bentley, Jessica Grimsby, Erik Szyska, Kevin Hoskins, Boog Dumphy, Katie Connors, Danielle Blasczak, Clara & Connor, Jenna Sicuranza, Evan Sicuranza, Linda Sicuranza, Kevin Becerra, Ramona Rose, Mouhcine Karrouim, Marisa Young, Jeff Prohaska, Anthony Puopolo, Jim Kavanaugh, Francine Mroczek, Allyson Laredo, Katelyn Guerin, Michael Ruggerio, Trina Ruggerio, Matthew Scott, Ed Park, Leeore Schnairsohn, Alexandria Ellison, Jim Mahoney, Ryan Walsh, Joseph Marrett, Brian Rutledge, Ryan Connelly

", - "release": 12 + "release": 12, + "priority": null } }, { @@ -2300,7 +2332,8 @@ "preview_url": "https://img.youtube.com/vi/Amz8lS4uB7I/maxresdefault.jpg", "description": "", "credits": "", - "release": 15 + "release": 15, + "priority": null } }, { @@ -2316,7 +2349,8 @@ "preview_url": "https://img.youtube.com/vi/1JOs37FojZ0/maxresdefault.jpg", "description": "", "credits": "

Special thanks to Joe Yoga and Neal Block for filming.

", - "release": 15 + "release": 15, + "priority": 1 } }, { @@ -2332,7 +2366,8 @@ "preview_url": "https://img.youtube.com/vi/CrT-bkNCXTI/maxresdefault.jpg", "description": "

Much like the song, the video for \u201cRunning Hot With Fate\u201d is a collection of miniature short stories about a group of people. But whereas these stories were conveyed in the recording by way of the lyrics, here in the video, volumes are telegraphed via peoples\u2019 stares, subtle expressions, and the contours of their faces. 27 Boston musicians were cast in \u2018Fate\u2019 from a pool of artists whose careers collectively cover six decades of music.

\r\n\r\n

You can read more about the video, meet the Fates, and own a piece of Fate at runninghotwithfate.com.

", "credits": "

Directed & edited by Tyler Hollis Derryberry\r\n
Concept/Produced by: Tyler Hollis Derryberry & Ryan H. Walsh

", - "release": 15 + "release": 15, + "priority": 1 } }, { @@ -2348,7 +2383,8 @@ "preview_url": "https://img.youtube.com/vi/cXzCCUVUih8/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { @@ -2364,7 +2400,8 @@ "preview_url": "https://img.youtube.com/vi/qUDQwLrYuCY/maxresdefault.jpg", "description": "", "credits": "", - "release": null + "release": null, + "priority": null } }, { diff --git a/hth/music/admin.py b/hth/music/admin.py index 87ffab3..795d6ca 100644 --- a/hth/music/admin.py +++ b/hth/music/admin.py @@ -28,9 +28,11 @@ class SongAdmin(admin.ModelAdmin): class VideoAdmin(admin.ModelAdmin): save_on_top = True fields = ('title', 'slug', 'source_url', 'embed_code', 'preview_url', - 'release', 'description', 'credits', 'publish', 'publish_on',) + 'release', 'description', 'credits', 'publish', 'publish_on', + 'priority',) prepopulated_fields = {'slug': ('title',)} - list_display = ('title', 'source_url', 'release', 'publish', 'publish_on',) + list_display = ('title', 'source_url', 'release', 'publish', 'publish_on', + 'priority',) admin.site.register(Video, VideoAdmin)