Use user ids for author search instead of usernames.

master
voussoir 2022-11-09 19:41:16 -08:00
parent 9fb45403df
commit fb2a5e9d56
3 changed files with 10 additions and 9 deletions

View File

@ -178,7 +178,6 @@ Here is a brief overview of the project to help you learn your way around:
- Make the wording between "new", "create", "add"; and "remove", "delete" more consistent. - Make the wording between "new", "create", "add"; and "remove", "delete" more consistent.
- User account system, permission levels, private pages. - User account system, permission levels, private pages.
- Ability to access user photos by user's ID, not just username.
- Replace columns like area, ratio, bitrate by using expression indices or views (`width * height` etc). - Replace columns like area, ratio, bitrate by using expression indices or views (`width * height` etc).
- Add a `Photo.merge` to combine duplicate entries. - Add a `Photo.merge` to combine duplicate entries.
- Generate thumbnails for vector files without falling victim to bombs. - Generate thumbnails for vector files without falling victim to bombs.

View File

@ -122,12 +122,10 @@ def minmax(key, value, minimums, maximums, warning_bag=None):
def normalize_author(authors, photodb, warning_bag=None): def normalize_author(authors, photodb, warning_bag=None):
''' '''
Either: Either:
- A string, where the usernames are separated by commas - A string, where the user IDs are separated by commas
- An iterable containing - An iterable containing IDs or User objects
- Usernames as strings
- User objects
Returns: A set of user IDs. Returns: A set of User objects.
''' '''
if authors is None: if authors is None:
authors = [] authors = []
@ -140,11 +138,12 @@ def normalize_author(authors, photodb, warning_bag=None):
if isinstance(requested_author, objects.User): if isinstance(requested_author, objects.User):
if requested_author.photodb == photodb: if requested_author.photodb == photodb:
users.add(requested_author) users.add(requested_author)
continue
else: else:
requested_author = requested_author.username requested_author = requested_author.id
try: try:
user = photodb.get_user(username=requested_author) user = photodb.get_user_by_id(requested_author)
except exceptions.NoSuchUser as exc: except exceptions.NoSuchUser as exc:
if warning_bag: if warning_bag:
warning_bag.add(exc) warning_bag.add(exc)

View File

@ -31,6 +31,9 @@
<div id="content_body"> <div id="content_body">
<div id="hierarchy_self" class="panel"> <div id="hierarchy_self" class="panel">
<h1 id="display_name">{{user.display_name}}</h1> <h1 id="display_name">{{user.display_name}}</h1>
{% if user.display_name != user.username %}
<p>Username: {{user.username}}</p>
{% endif %}
<p>ID: <a href="/userid/{{user.id}}"><code>{{user.id}}</code></a></p> <p>ID: <a href="/userid/{{user.id}}"><code>{{user.id}}</code></a></p>
<p>User since <span title="{{user.created|timestamp_to_8601}}">{{user.created|timestamp_to_naturaldate}}.</span></p> <p>User since <span title="{{user.created|timestamp_to_8601}}">{{user.created|timestamp_to_naturaldate}}.</span></p>
</div> </div>
@ -38,7 +41,7 @@
{% set photos = user.get_photos(direction='desc')|islice(0, 15)|list %} {% set photos = user.get_photos(direction='desc')|islice(0, 15)|list %}
{% if photos %} {% if photos %}
<div id="hierarchy_photos" class="panel"> <div id="hierarchy_photos" class="panel">
<h2><a href="/search?author={{user.username}}">Photos by <span class="dynamic_user_display_name">{{user.display_name}}</span></a></h2> <h2><a href="/search?author={{user.id}}">Photos by <span class="dynamic_user_display_name">{{user.display_name}}</span></a></h2>
{% for photo in photos %} {% for photo in photos %}
{{cards.create_photo_card(photo)}} {{cards.create_photo_card(photo)}}
{% endfor %} {% endfor %}