Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add account look-up by IA ID #8550

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions openlibrary/plugins/admin/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import openlibrary

from openlibrary import accounts

from openlibrary.accounts.model import OpenLibraryAccount
from openlibrary.core import admin as admin_stats, helpers as h, imports, cache
from openlibrary.core.waitinglist import Stats as WLStats
from openlibrary.core.sponsorships import summary, sync_completed_sponsored_books
Expand Down Expand Up @@ -174,13 +174,16 @@ def GET(self):

class people:
def GET(self):
i = web.input(email=None)
i = web.input(email=None, ia_id=None)

account = None
if i.email:
account = accounts.find(email=i.email)
if account:
raise web.seeother("/admin/people/" + account.username)
return render_template("admin/people/index", email=i.email)
if i.ia_id:
account = OpenLibraryAccount.get_by_link(i.ia_id)
if account:
raise web.seeother(f"/admin/people/{account.username}")
return render_template("admin/people/index", email=i.email, ia_id=i.ia_id)


class add_work_to_staff_picks:
Expand Down
18 changes: 16 additions & 2 deletions openlibrary/templates/admin/people/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$def with (email=None)
$def with (email=None, ia_id=None)

$var title: [Admin Center] People

Expand All @@ -16,7 +16,8 @@ <h2>$_("Find Account")</h2>
.user-search td {
font-size: 1.0em !important;
}
input#email {
input#email,
input#ia-id {
padding: 3px;
width: 400px;
}
Expand All @@ -37,6 +38,19 @@ <h2>$_("Find Account")</h2>
</form>
</td>
</tr>
<tr>
<td>$_("IA ID:")</td>
<td>
<form method="GET" name="form-ia-id">
<input type="text" name="ia_id" id="ia-id" pattern="^@.*$" placeholder="e.g. @foobar">
<button type="submit">$_("Find")</button>
<span class="invalid">
$if ia_id:
$_("No account found with this ID.")
</span>
</form>
</td>
</tr>
</tbody>
</table>

Expand Down