Cleanup: More minor dusting, commenting, clarity renaming.
This commit is contained in:
parent
bb5fa816d8
commit
96856e9361
4 changed files with 43 additions and 31 deletions
|
@ -5,8 +5,8 @@ import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ffmpeg = converter.Converter(
|
ffmpeg = converter.Converter(
|
||||||
ffmpeg_path='C:\\software\\ffmpeg\\bin\\ffmpeg.exe',
|
ffmpeg_path='D:\\software\\ffmpeg\\bin\\ffmpeg.exe',
|
||||||
ffprobe_path='C:\\software\\ffmpeg\\bin\\ffprobe.exe',
|
ffprobe_path='D:\\software\\ffmpeg\\bin\\ffprobe.exe',
|
||||||
)
|
)
|
||||||
except converter.ffmpeg.FFMpegError:
|
except converter.ffmpeg.FFMpegError:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
|
@ -249,6 +249,11 @@ class Album(ObjectBase, GroupableMixin):
|
||||||
@decorators.required_feature('album.edit')
|
@decorators.required_feature('album.edit')
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
def add_associated_directory(self, filepath, *, commit=True):
|
def add_associated_directory(self, filepath, *, commit=True):
|
||||||
|
'''
|
||||||
|
Add a directory from which this album will pull files during rescans.
|
||||||
|
These relationships are not unique and multiple albums
|
||||||
|
can associate with the same directory if desired.
|
||||||
|
'''
|
||||||
filepath = pathclass.Path(filepath)
|
filepath = pathclass.Path(filepath)
|
||||||
if not filepath.is_dir:
|
if not filepath.is_dir:
|
||||||
raise ValueError('%s is not a directory' % filepath)
|
raise ValueError('%s is not a directory' % filepath)
|
||||||
|
|
|
@ -811,8 +811,7 @@ class PDBPhotoMixin:
|
||||||
#print('Failed tag expression')
|
#print('Failed tag expression')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif is_must_may_forbid:
|
# elif is_must_may_forbid:
|
||||||
pass
|
|
||||||
# if photo.id not in mmf_results:
|
# if photo.id not in mmf_results:
|
||||||
# #print('Failed tag mmf')
|
# #print('Failed tag mmf')
|
||||||
# continue
|
# continue
|
||||||
|
@ -991,21 +990,27 @@ class PDBUserMixin:
|
||||||
else:
|
else:
|
||||||
raise exceptions.NoSuchUser(username or id)
|
raise exceptions.NoSuchUser(username or id)
|
||||||
|
|
||||||
def get_user_id_or_none(self, user):
|
def get_user_id_or_none(self, user_obj_or_id):
|
||||||
'''
|
'''
|
||||||
For methods that create photos, albums, etc., we sometimes associate
|
For methods that create photos, albums, etc., we sometimes associate
|
||||||
them with an author but sometimes not. This method hides validation
|
them with an author but sometimes not. The callers of those methods
|
||||||
that those methods would otherwise have to duplicate.
|
might be trying to use a User object, or a user's ID, or maybe they
|
||||||
|
left it None.
|
||||||
|
This method hides validation that those methods would otherwise
|
||||||
|
have to duplicate.
|
||||||
'''
|
'''
|
||||||
if isinstance(user, objects.User):
|
if user_obj_or_id is None:
|
||||||
if user.photodb != self:
|
|
||||||
raise ValueError('That user does not belong to this photodb')
|
|
||||||
author_id = user.id
|
|
||||||
elif user is not None:
|
|
||||||
# Confirm that this string is an ID and not junk.
|
|
||||||
author_id = self.get_user(id=user).id
|
|
||||||
else:
|
|
||||||
author_id = None
|
author_id = None
|
||||||
|
|
||||||
|
elif isinstance(user_obj_or_id, objects.User):
|
||||||
|
if user_obj_or_id.photodb != self:
|
||||||
|
raise ValueError('That user does not belong to this photodb')
|
||||||
|
author_id = user_obj_or_id.id
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Confirm that this string is a valid ID and not junk.
|
||||||
|
author_id = self.get_user(id=user_obj_or_id).id
|
||||||
|
|
||||||
return author_id
|
return author_id
|
||||||
|
|
||||||
@decorators.required_feature('user.login')
|
@decorators.required_feature('user.login')
|
||||||
|
@ -1017,11 +1022,11 @@ class PDBUserMixin:
|
||||||
if fetch is None:
|
if fetch is None:
|
||||||
raise exceptions.WrongLogin()
|
raise exceptions.WrongLogin()
|
||||||
|
|
||||||
stored_password = fetch[constants.SQL_USER['password']]
|
|
||||||
|
|
||||||
if not isinstance(password, bytes):
|
if not isinstance(password, bytes):
|
||||||
password = password.encode('utf-8')
|
password = password.encode('utf-8')
|
||||||
|
|
||||||
|
stored_password = fetch[constants.SQL_USER['password']]
|
||||||
|
|
||||||
success = bcrypt.checkpw(password, stored_password)
|
success = bcrypt.checkpw(password, stored_password)
|
||||||
if not success:
|
if not success:
|
||||||
raise exceptions.WrongLogin()
|
raise exceptions.WrongLogin()
|
||||||
|
|
|
@ -27,7 +27,9 @@ def build_query(
|
||||||
|
|
||||||
if mmf_results:
|
if mmf_results:
|
||||||
# "id IN/NOT IN (1, 2, 3)"
|
# "id IN/NOT IN (1, 2, 3)"
|
||||||
wheres.add('id %s %s' % (mmf_results['operator'], helpers.sql_listify(mmf_results['photoids'])))
|
operator = mmf_results['operator']
|
||||||
|
photo_ids = helpers.sql_listify(mmf_results['photo_ids'])
|
||||||
|
wheres.add('id %s %s' % (operator, photo_ids))
|
||||||
|
|
||||||
if orderby:
|
if orderby:
|
||||||
orderby = [o.split('-') for o in orderby]
|
orderby = [o.split('-') for o in orderby]
|
||||||
|
|
Loading…
Reference in a new issue