add {mm} and {dd} media format support, resolves #12
This commit is contained in:
parent
cda021cbbf
commit
8f4b09f346
|
@ -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,
|
||||
|
|
|
@ -11,18 +11,28 @@
|
|||
<tr>
|
||||
<td>{yyyymmdd}</td>
|
||||
<td>Media publish date in YYYYMMDD</td>
|
||||
<td>20210101</td>
|
||||
<td>20210131</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{yyyy_mm_dd}</td>
|
||||
<td>Media publish date in YYYY-MM-DD</td>
|
||||
<td>2021-01-01</td>
|
||||
<td>2021-01-31</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{yyyy}</td>
|
||||
<td>Media publish year in YYYY</td>
|
||||
<td>2021</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{mm}</td>
|
||||
<td>Media publish year in MM</td>
|
||||
<td>01</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{dd}</td>
|
||||
<td>Media publish year in DD</td>
|
||||
<td>31</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{source}</td>
|
||||
<td>Lower case source name, max 80 chars</td>
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
{% include 'mediaformatvars.html' %}
|
||||
{% include 'sync/_mediaformatvars.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
{% include 'mediaformatvars.html' %}
|
||||
{% include 'sync/_mediaformatvars.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue