Add Album.@display_name to remove duplicate logic elsewhere
This commit is contained in:
		
							parent
							
								
									f797e3fb55
								
							
						
					
					
						commit
						defa23eff3
					
				
					 5 changed files with 13 additions and 15 deletions
				
			
		|  | @ -260,6 +260,13 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|             self.photodb.log.debug('Committing - delete album') |             self.photodb.log.debug('Committing - delete album') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @property | ||||||
|  |     def display_name(self): | ||||||
|  |         if self.title: | ||||||
|  |             return self.title | ||||||
|  |         else: | ||||||
|  |             return self.id | ||||||
|  | 
 | ||||||
|     def edit(self, title=None, description=None, *, commit=True): |     def edit(self, title=None, description=None, *, commit=True): | ||||||
|         ''' |         ''' | ||||||
|         Change the title or description. Leave None to keep current value. |         Change the title or description. Leave None to keep current value. | ||||||
|  |  | ||||||
|  | @ -350,6 +350,7 @@ def get_album_zip(albumid): | ||||||
| def get_albums_core(): | def get_albums_core(): | ||||||
|     albums = P.get_albums() |     albums = P.get_albums() | ||||||
|     albums = [a for a in albums if a.parent() is None] |     albums = [a for a in albums if a.parent() is None] | ||||||
|  |     albums.sort(key=lambda x: x.display_name.lower()) | ||||||
|     return albums |     return albums | ||||||
| 
 | 
 | ||||||
| @site.route('/albums') | @site.route('/albums') | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
| <head> | <head> | ||||||
|     {% import "photo_card.html" as photo_card %} |     {% import "photo_card.html" as photo_card %} | ||||||
|     {% import "header.html" as header %} |     {% import "header.html" as header %} | ||||||
|     <title>Album {{album.title}}</title> |     <title>Album {{album.display_name}}</title> | ||||||
|     <meta charset="UTF-8"> |     <meta charset="UTF-8"> | ||||||
|     <link rel="stylesheet" href="/static/common.css"> |     <link rel="stylesheet" href="/static/common.css"> | ||||||
| 
 | 
 | ||||||
|  | @ -28,7 +28,7 @@ p | ||||||
|     <p>{{album.description}}</p> |     <p>{{album.description}}</p> | ||||||
|     {% set parent=album.parent() %} |     {% set parent=album.parent() %} | ||||||
|     {% if parent %} |     {% if parent %} | ||||||
|     <h3>Parent: <a href="/album/{{parent.id}}">{{parent.id + " " + parent.title}}</a></h3> |     <h3>Parent: <a href="/album/{{parent.id}}">{{parent.display_name}}</a></h3> | ||||||
|     {% else %} |     {% else %} | ||||||
|     <h3>Parent: <a href="/albums">Albums</a></h3> |     <h3>Parent: <a href="/albums">Albums</a></h3> | ||||||
|     {% endif %} |     {% endif %} | ||||||
|  | @ -37,12 +37,7 @@ p | ||||||
|     <h3>Sub-albums</h3> |     <h3>Sub-albums</h3> | ||||||
|     <ul> |     <ul> | ||||||
|         {% for sub_album in sub_albums|sort(attribute='title') %} |         {% for sub_album in sub_albums|sort(attribute='title') %} | ||||||
|         <li><a href="/album/{{sub_album.id}}"> |         <li><a href="/album/{{sub_album.id}}">{{sub_album.display_name}}</a> | ||||||
|             {% if sub_album.title %} |  | ||||||
|             {{sub_album.title}} |  | ||||||
|             {% else %} |  | ||||||
|             {{sub_album.id}} |  | ||||||
|             {% endif %}</a> |  | ||||||
|         </li> |         </li> | ||||||
|         {% endfor %} |         {% endfor %} | ||||||
|     </ul> |     </ul> | ||||||
|  |  | ||||||
|  | @ -19,12 +19,7 @@ | ||||||
| {{header.make_header(session=session)}} | {{header.make_header(session=session)}} | ||||||
| <div id="content_body"> | <div id="content_body"> | ||||||
|     {% for album in albums %} |     {% for album in albums %} | ||||||
|     {% if album.title %} |     <div><a href="/album/{{album.id}}">{{album.display_name}}</a></div> | ||||||
|     {% set title=album.id + " " + album.title %} |  | ||||||
|     {% else %} |  | ||||||
|     {% set title=album.id %} |  | ||||||
|     {% endif %} |  | ||||||
|     <div><a href="/album/{{album.id}}">{{album.id + " " + album.title}}</a></div> |  | ||||||
|     {% endfor %} |     {% endfor %} | ||||||
| </div> | </div> | ||||||
| </body> | </body> | ||||||
|  |  | ||||||
|  | @ -181,7 +181,7 @@ | ||||||
|         <h4>Albums containing this photo</h4> |         <h4>Albums containing this photo</h4> | ||||||
|         <ul id="containing albums"> |         <ul id="containing albums"> | ||||||
|             {% for album in albums %} |             {% for album in albums %} | ||||||
|             <li><a href="/album/{{album.id}}">{{album.title}}</a></li> |             <li><a href="/album/{{album.id}}">{{album.display_name}}</a></li> | ||||||
|             {% endfor %} |             {% endfor %} | ||||||
|         {% endif %} |         {% endif %} | ||||||
|         </ul> |         </ul> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue