From 8f4b09f346a0883fdbd3f964156aead59953cd84 Mon Sep 17 00:00:00 2001 From: meeb Date: Fri, 18 Dec 2020 21:02:06 +1100 Subject: [PATCH] add {mm} and {dd} media format support, resolves #12 --- tubesync/sync/models.py | 4 ++++ .../templates/sync/_mediaformatvars.html} | 14 ++++++++++++-- tubesync/sync/templates/sync/source-add.html | 2 +- tubesync/sync/templates/sync/source-update.html | 2 +- tubesync/sync/tests.py | 6 ++++++ 5 files changed, 24 insertions(+), 4 deletions(-) rename tubesync/{common/templates/mediaformatvars.html => sync/templates/sync/_mediaformatvars.html} (88%) diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 671600b..874bc7f 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -370,6 +370,8 @@ class Source(models.Model): 'yyyymmdd': timezone.now().strftime('%Y%m%d'), 'yyyy_mm_dd': timezone.now().strftime('%Y-%m-%d'), 'yyyy': timezone.now().strftime('%Y'), + 'mm': timezone.now().strftime('%m'), + 'dd': timezone.now().strftime('%d'), 'source': self.slugname, 'source_full': self.name, 'title': 'some-media-title-name', @@ -805,6 +807,8 @@ class Media(models.Model): 'yyyymmdd': dateobj.strftime('%Y%m%d'), 'yyyy_mm_dd': dateobj.strftime('%Y-%m-%d'), 'yyyy': dateobj.strftime('%Y'), + 'mm': dateobj.strftime('%m'), + 'dd': dateobj.strftime('%d'), 'source': self.source.slugname, 'source_full': self.source.name, 'title': self.slugtitle, diff --git a/tubesync/common/templates/mediaformatvars.html b/tubesync/sync/templates/sync/_mediaformatvars.html similarity index 88% rename from tubesync/common/templates/mediaformatvars.html rename to tubesync/sync/templates/sync/_mediaformatvars.html index bbad0b4..71c1770 100644 --- a/tubesync/common/templates/mediaformatvars.html +++ b/tubesync/sync/templates/sync/_mediaformatvars.html @@ -11,18 +11,28 @@ {yyyymmdd} Media publish date in YYYYMMDD - 20210101 + 20210131 {yyyy_mm_dd} Media publish date in YYYY-MM-DD - 2021-01-01 + 2021-01-31 {yyyy} Media publish year in YYYY 2021 + + {mm} + Media publish year in MM + 01 + + + {dd} + Media publish year in DD + 31 + {source} Lower case source name, max 80 chars diff --git a/tubesync/sync/templates/sync/source-add.html b/tubesync/sync/templates/sync/source-add.html index d0e7a7a..fd3b1fb 100644 --- a/tubesync/sync/templates/sync/source-add.html +++ b/tubesync/sync/templates/sync/source-add.html @@ -25,7 +25,7 @@
-{% include 'mediaformatvars.html' %} +{% include 'sync/_mediaformatvars.html' %}
{% endblock %} diff --git a/tubesync/sync/templates/sync/source-update.html b/tubesync/sync/templates/sync/source-update.html index ed0136f..1adf652 100644 --- a/tubesync/sync/templates/sync/source-update.html +++ b/tubesync/sync/templates/sync/source-update.html @@ -27,7 +27,7 @@
-{% include 'mediaformatvars.html' %} +{% include 'sync/_mediaformatvars.html' %}
{% endblock %} diff --git a/tubesync/sync/tests.py b/tubesync/sync/tests.py index f3f4d99..c2a725e 100644 --- a/tubesync/sync/tests.py +++ b/tubesync/sync/tests.py @@ -507,6 +507,12 @@ class FilepathTestCase(TestCase): self.source.media_format = 'test-{yyyy}' self.assertEqual(self.source.get_example_media_format(), 'test-' + timezone.now().strftime('%Y')) + self.source.media_format = 'test-{mm}' + self.assertEqual(self.source.get_example_media_format(), + 'test-' + timezone.now().strftime('%m')) + self.source.media_format = 'test-{dd}' + self.assertEqual(self.source.get_example_media_format(), + 'test-' + timezone.now().strftime('%d')) self.source.media_format = 'test-{source}' self.assertEqual(self.source.get_example_media_format(), 'test-' + self.source.slugname)