Rename Groupable.parent -> get_parent.
After making the "if x.parent is None" mistake too many times, forgetting that it was not a @property, I've decided that the verby name is better.
This commit is contained in:
parent
db92951ad6
commit
75effafaf5
5 changed files with 12 additions and 12 deletions
|
@ -11,7 +11,7 @@ def album(a, minimal=False):
|
||||||
}
|
}
|
||||||
if not minimal:
|
if not minimal:
|
||||||
j['photos'] = [photo(p) for p in a.photos()]
|
j['photos'] = [photo(p) for p in a.photos()]
|
||||||
parent = a.parent()
|
parent = a.get_parent()
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
j['parent'] = album(parent, minimal=True)
|
j['parent'] = album(parent, minimal=True)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -131,7 +131,7 @@ class GroupableMixin:
|
||||||
child.delete(delete_children=delete_children, commit=False)
|
child.delete(delete_children=delete_children, commit=False)
|
||||||
else:
|
else:
|
||||||
# Lift children
|
# Lift children
|
||||||
parent = self.parent()
|
parent = self.get_parent()
|
||||||
if parent is None:
|
if parent is None:
|
||||||
# Since this group was a root, children become roots by removing
|
# Since this group was a root, children become roots by removing
|
||||||
# the row.
|
# the row.
|
||||||
|
@ -156,7 +156,7 @@ class GroupableMixin:
|
||||||
self.photodb.log.debug('Committing - delete tag')
|
self.photodb.log.debug('Committing - delete tag')
|
||||||
self.photodb.commit()
|
self.photodb.commit()
|
||||||
|
|
||||||
def parent(self):
|
def get_parent(self):
|
||||||
'''
|
'''
|
||||||
Return the group of which this is a member, or None.
|
Return the group of which this is a member, or None.
|
||||||
Returned object will be of the same type as calling object.
|
Returned object will be of the same type as calling object.
|
||||||
|
@ -208,10 +208,10 @@ class GroupableMixin:
|
||||||
yield from child.walk_children()
|
yield from child.walk_children()
|
||||||
|
|
||||||
def walk_parents(self):
|
def walk_parents(self):
|
||||||
parent = self.parent()
|
parent = self.get_parent()
|
||||||
while parent is not None:
|
while parent is not None:
|
||||||
yield parent
|
yield parent
|
||||||
parent = parent.parent()
|
parent = parent.get_parent()
|
||||||
|
|
||||||
|
|
||||||
class Album(ObjectBase, GroupableMixin):
|
class Album(ObjectBase, GroupableMixin):
|
||||||
|
@ -247,7 +247,7 @@ class Album(ObjectBase, GroupableMixin):
|
||||||
self._sum_photos_recursive = None
|
self._sum_photos_recursive = None
|
||||||
self._sum_bytes_local = None
|
self._sum_bytes_local = None
|
||||||
self._sum_bytes_recursive = None
|
self._sum_bytes_recursive = None
|
||||||
parent = self.parent()
|
parent = self.get_parent()
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
parent._uncache_sums()
|
parent._uncache_sums()
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ class Album(ObjectBase, GroupableMixin):
|
||||||
|
|
||||||
@decorators.required_feature('album.edit')
|
@decorators.required_feature('album.edit')
|
||||||
def leave_group(self, *args, **kwargs):
|
def leave_group(self, *args, **kwargs):
|
||||||
parent = self.parent()
|
parent = self.get_parent()
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
parent._uncache_sums()
|
parent._uncache_sums()
|
||||||
result = super().leave_group(*args, **kwargs)
|
result = super().leave_group(*args, **kwargs)
|
||||||
|
|
|
@ -96,7 +96,7 @@ class PDBAlbumMixin:
|
||||||
|
|
||||||
def get_root_albums(self):
|
def get_root_albums(self):
|
||||||
for album in self.get_albums():
|
for album in self.get_albums():
|
||||||
if album.parent() is None:
|
if album.get_parent() is None:
|
||||||
yield album
|
yield album
|
||||||
|
|
||||||
@decorators.required_feature('album.new')
|
@decorators.required_feature('album.new')
|
||||||
|
@ -722,7 +722,7 @@ class PDBTagMixin:
|
||||||
Yield all Tags that have no parent.
|
Yield all Tags that have no parent.
|
||||||
'''
|
'''
|
||||||
for tag in self.get_tags():
|
for tag in self.get_tags():
|
||||||
if tag.parent() is None:
|
if tag.get_parent() is None:
|
||||||
yield tag
|
yield tag
|
||||||
|
|
||||||
@decorators.required_feature('tag.new')
|
@decorators.required_feature('tag.new')
|
||||||
|
@ -1109,7 +1109,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs
|
||||||
return current_album
|
return current_album
|
||||||
|
|
||||||
def orphan_join_parent_album(albums_by_path, current_album, current_directory):
|
def orphan_join_parent_album(albums_by_path, current_album, current_directory):
|
||||||
if current_album.parent() is None:
|
if current_album.get_parent() is None:
|
||||||
parent = albums_by_path.get(current_directory.parent.absolute_path, None)
|
parent = albums_by_path.get(current_directory.parent.absolute_path, None)
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
parent.add_child(current_album, commit=False)
|
parent.add_child(current_album, commit=False)
|
||||||
|
|
|
@ -99,5 +99,5 @@ def stdout(tags, depth=0):
|
||||||
|
|
||||||
stdout(children, depth=depth+1)
|
stdout(children, depth=depth+1)
|
||||||
|
|
||||||
if tag.parent() is None:
|
if tag.get_parent() is None:
|
||||||
print()
|
print()
|
||||||
|
|
|
@ -64,7 +64,7 @@ p
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% set viewparam = "?view=list" if view == "list" else "" %}
|
{% set viewparam = "?view=list" if view == "list" else "" %}
|
||||||
{% set parent = album.parent() %}
|
{% set parent = album.get_parent() %}
|
||||||
{% if parent %}
|
{% if parent %}
|
||||||
<li><a href="/album/{{parent.id}}{{viewparam}}">{{parent.display_name}}</a></li>
|
<li><a href="/album/{{parent.id}}{{viewparam}}">{{parent.display_name}}</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in a new issue