Make Photo.bytestring a @property.
This is the kind of thing that should be a @property, because it's very low processing power and doesn't hit the database.
This commit is contained in:
		
							parent
							
								
									bbe392ac09
								
							
						
					
					
						commit
						b4a28f5034
					
				
					 4 changed files with 5 additions and 4 deletions
				
			
		|  | @ -48,7 +48,7 @@ def photo(p, include_albums=True, include_tags=True): | |||
|         'bytes': p.bytes, | ||||
|         'duration_str': p.duration_string, | ||||
|         'duration': p.duration, | ||||
|         'bytes_str': p.bytestring(), | ||||
|         'bytes_str': p.bytestring, | ||||
|         'has_thumbnail': bool(p.thumbnail), | ||||
|         'created': p.created, | ||||
|         'filename': p.basename, | ||||
|  |  | |||
|  | @ -635,6 +635,7 @@ class Photo(ObjectBase): | |||
|             self.photodb.commit() | ||||
|         return tag | ||||
| 
 | ||||
|     @property | ||||
|     def bytestring(self): | ||||
|         if self.bytes is not None: | ||||
|             return bytestring.bytestring(self.bytes) | ||||
|  |  | |||
|  | @ -192,7 +192,7 @@ | |||
|             <li>Dimensions: {{photo.width}}x{{photo.height}} px</li> | ||||
|             <li>Aspect ratio: {{photo.ratio}}</li> | ||||
|         {% endif %} | ||||
|         <li>Size: {{photo.bytestring()}}</li> | ||||
|         <li>Size: {{photo.bytestring}}</li> | ||||
|         {% if photo.duration %} | ||||
|             <li>Duration: {{photo.duration_string}}</li> | ||||
|             <li>Overall Bitrate: {{photo.bitrate|int}} kbps</li> | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ | |||
| <div class="photo_card photo_card_list" data-id="{{photo.id}}"> | ||||
|     <input type="checkbox" class="photo_card_selector_checkbox" onclick="on_photo_select(event)"/> | ||||
|     <span class="photo_card_filename"><a target="_blank" href="/photo/{{photo.id}}">{{photo.basename}}</a></span> | ||||
|     <a class="photo_card_metadata" target="_blank" href="/file/{{photo.id}}.{{photo.extension}}">{{photo.bytestring()}}</a> | ||||
|     <a class="photo_card_metadata" target="_blank" href="/file/{{photo.id}}.{{photo.extension}}">{{photo.bytestring}}</a> | ||||
| </div> | ||||
| {% else %} | ||||
| 
 | ||||
|  | @ -69,7 +69,7 @@ | |||
| 
 | ||||
|     <span class="photo_card_metadata"> | ||||
|     {{- metadata_inner|safe -}} | ||||
|     <a target="_blank" href="/file/{{photo.id}}.{{photo.extension}}">{{photo.bytestring()}}</a> | ||||
|     <a target="_blank" href="/file/{{photo.id}}.{{photo.extension}}">{{photo.bytestring}}</a> | ||||
|     </span> | ||||
| 
 | ||||
|     <input type="checkbox" class="photo_card_selector_checkbox" onclick="on_photo_select(event)"/> | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue