www.fgks.org   »   [go: up one dir, main page]

Skip to content

Commit

Permalink
Add account look-up by IA ID (#8550)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchamp committed Nov 21, 2023
1 parent 7569b11 commit baad3d8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
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

0 comments on commit baad3d8

Please sign in to comment.