searchhelpers.normalize_author use un only, not IDs.

I don't like the idea of a user setting their username to be
someone else's ID.
This commit is contained in:
voussoir 2018-03-21 13:21:25 -07:00
parent afc5f38a8d
commit 6c77ddd1c3

View file

@ -84,16 +84,7 @@ def build_query(
query = ' '.join(query) query = ' '.join(query)
return query return query
def get_user(photodb, username_or_id):
try:
user = photodb.get_user(username=username_or_id)
except exceptions.NoSuchUser:
try:
user = photodb.get_user(id=username_or_id)
except exceptions.NoSuchUser:
raise
return user
def minmax(key, value, minimums, maximums, warning_bag=None): def minmax(key, value, minimums, maximums, warning_bag=None):
''' '''
@ -217,7 +208,7 @@ def normalize_authors(authors, photodb, warning_bag=None):
requested_author = requested_author.username requested_author = requested_author.username
try: try:
user = get_user(photodb, username_or_id=requested_author) user = photodb.get_user(username=requested_author)
except exceptions.NoSuchUser as e: except exceptions.NoSuchUser as e:
if warning_bag: if warning_bag:
warning_bag.add(e.error_message) warning_bag.add(e.error_message)