add {HH} for hour and {min} for minutes to output media format path formats, part of #133
This commit is contained in:
		
							parent
							
								
									00fbd53b11
								
							
						
					
					
						commit
						3c1d64a089
					
				|  | @ -428,12 +428,15 @@ class Source(models.Model): | ||||||
|             fmt.append('60fps') |             fmt.append('60fps') | ||||||
|         if self.prefer_hdr: |         if self.prefer_hdr: | ||||||
|             fmt.append('hdr') |             fmt.append('hdr') | ||||||
|  |         now = timezone.now() | ||||||
|         return { |         return { | ||||||
|             'yyyymmdd': timezone.now().strftime('%Y%m%d'), |             'yyyymmdd': now.strftime('%Y%m%d'), | ||||||
|             'yyyy_mm_dd': timezone.now().strftime('%Y-%m-%d'), |             'yyyy_mm_dd': now.strftime('%Y-%m-%d'), | ||||||
|             'yyyy': timezone.now().strftime('%Y'), |             'yyyy': now.strftime('%Y'), | ||||||
|             'mm': timezone.now().strftime('%m'), |             'mm': now.strftime('%m'), | ||||||
|             'dd': timezone.now().strftime('%d'), |             'dd': now.strftime('%d'), | ||||||
|  |             'hh': now.strftime('%H'), | ||||||
|  |             'min': now.strftime('%M'), | ||||||
|             'source': self.slugname, |             'source': self.slugname, | ||||||
|             'source_full': self.name, |             'source_full': self.name, | ||||||
|             'title': 'some-media-title-name', |             'title': 'some-media-title-name', | ||||||
|  | @ -917,6 +920,8 @@ class Media(models.Model): | ||||||
|             'yyyy': dateobj.strftime('%Y'), |             'yyyy': dateobj.strftime('%Y'), | ||||||
|             'mm': dateobj.strftime('%m'), |             'mm': dateobj.strftime('%m'), | ||||||
|             'dd': dateobj.strftime('%d'), |             'dd': dateobj.strftime('%d'), | ||||||
|  |             'hh': dateobj.strftime('%H'), | ||||||
|  |             'min': dateobj.strftime('%M'), | ||||||
|             'source': self.source.slugname, |             'source': self.source.slugname, | ||||||
|             'source_full': self.source.name, |             'source_full': self.source.name, | ||||||
|             'title': self.slugtitle, |             'title': self.slugtitle, | ||||||
|  |  | ||||||
|  | @ -25,14 +25,24 @@ | ||||||
|     </tr> |     </tr> | ||||||
|     <tr> |     <tr> | ||||||
|       <td>{mm}</td> |       <td>{mm}</td> | ||||||
|       <td>Media publish year in MM</td> |       <td>Media publish month in MM</td> | ||||||
|       <td>01</td> |       <td>01</td> | ||||||
|     </tr> |     </tr> | ||||||
|     <tr> |     <tr> | ||||||
|       <td>{dd}</td> |       <td>{dd}</td> | ||||||
|       <td>Media publish year in DD</td> |       <td>Media publish day in DD</td> | ||||||
|       <td>31</td> |       <td>31</td> | ||||||
|     </tr> |     </tr> | ||||||
|  |     <tr> | ||||||
|  |       <td>{hh}</td> | ||||||
|  |       <td>Media publish hour in HH</td> | ||||||
|  |       <td>12</td> | ||||||
|  |     </tr> | ||||||
|  |     <tr> | ||||||
|  |       <td>{min}</td> | ||||||
|  |       <td>Media publish minutes in MM</td> | ||||||
|  |       <td>46</td> | ||||||
|  |     </tr> | ||||||
|     <tr> |     <tr> | ||||||
|       <td>{source}</td> |       <td>{source}</td> | ||||||
|       <td>Lower case source name, max 80 chars</td> |       <td>Lower case source name, max 80 chars</td> | ||||||
|  |  | ||||||
|  | @ -491,7 +491,7 @@ class FilepathTestCase(TestCase): | ||||||
|             metadata=metadata, |             metadata=metadata, | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|     def test_source_dirname(self): |     def test_source_media_format(self): | ||||||
|         # Check media format validation is working |         # Check media format validation is working | ||||||
|         # Empty |         # Empty | ||||||
|         self.source.media_format = '' |         self.source.media_format = '' | ||||||
|  | @ -521,6 +521,12 @@ class FilepathTestCase(TestCase): | ||||||
|         self.source.media_format = 'test-{dd}' |         self.source.media_format = 'test-{dd}' | ||||||
|         self.assertEqual(self.source.get_example_media_format(), |         self.assertEqual(self.source.get_example_media_format(), | ||||||
|                          'test-' + timezone.now().strftime('%d')) |                          'test-' + timezone.now().strftime('%d')) | ||||||
|  |         self.source.media_format = 'test-{hh}' | ||||||
|  |         self.assertEqual(self.source.get_example_media_format(), | ||||||
|  |                          'test-' + timezone.now().strftime('%H')) | ||||||
|  |         self.source.media_format = 'test-{min}' | ||||||
|  |         self.assertEqual(self.source.get_example_media_format(), | ||||||
|  |                          'test-' + timezone.now().strftime('%M')) | ||||||
|         self.source.media_format = 'test-{source}' |         self.source.media_format = 'test-{source}' | ||||||
|         self.assertEqual(self.source.get_example_media_format(), |         self.assertEqual(self.source.get_example_media_format(), | ||||||
|                          'test-' + self.source.slugname) |                          'test-' + self.source.slugname) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue