-
Notifications
You must be signed in to change notification settings - Fork 2
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
Register, admin, mod views #8
Open
willyao99
wants to merge
62
commits into
develop
Choose a base branch
from
tapir-dev
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
4700204
local-configs
willyao99 daa6557
fix broken pwd validation
willyao99 ccedde0
register step 2 template
willyao99 fa5399d
registration-wip
willyao99 5685bdd
fix-register-templates
willyao99 860c929
reg-flow-operational
willyao99 a8b505a
reg-redirect
willyao99 d362b21
tapir navbar wip
willyao99 27bf236
tapir styles and tapir landing wip
willyao99 da927e8
approved blocked list tooltip et al
willyao99 81ce5de
user-profile-etc
willyao99 25250d2
mod-model-fix
willyao99 d9834ed
moderators-table
willyao99 4b02e93
clean
willyao99 1eb62b9
audit log and mods features
willyao99 8c1baad
endorsement controller
willyao99 a33d0a1
endorsement wip
willyao99 f50b043
email-template-mgmt-wip
willyao99 594ee0f
search route and more email temps
willyao99 69d060e
search wip
willyao99 8206087
wip profile
willyao99 1e639a6
paper detail
willyao99 9b45552
profile updates
willyao99 19d1f89
suspects join fix
willyao99 d4e0096
htmx requests
willyao99 71705cb
emails-wip
willyao99 683a73e
tapir sessions wireframing
willyao99 97b0dce
end html wireframe wip
willyao99 dd88072
approved and blocked list wip
willyao99 773ebeb
email templ index link
willyao99 076c11f
susp link fix
willyao99 75d9fc8
index page links
willyao99 62fe2e3
flag placeholders wip
willyao99 67ce1f0
search function char
willyao99 9796891
flask gitignore
willyao99 985b1ea
endorsement controllers
willyao99 af16749
tapir interactive features merge
willyao99 03eacdb
endorsement listing feature fix
willyao99 2c6afab
landing links
willyao99 1d02a7e
redirect links
willyao99 64bcb4e
confirm pages wip
willyao99 954e6f8
confirm screen wip
willyao99 773b75f
Update README.md
willyao99 7e46f30
Update README.md
willyao99 1021232
Update README.md
willyao99 d1db1f6
Update README.md
willyao99 0f75aed
email temp misc
willyao99 410a37c
Webapp runs with new base including auth, no arxiv_db, and no flask_s…
mnazzaro 86fc58a
Refactor config, and now pages are actually working
mnazzaro 8ffcff5
A few tests still failing due to db weirdness
mnazzaro a95e5f3
Just weird domain thing remaining
mnazzaro d98651b
Switch domain to arxiv.org from .arxiv.org in Domain cookie
mnazzaro a7b30be
Leaving off for today
mnazzaro fead199
In cloud run with all routes admin scoped
mnazzaro bffba2c
One still failing
mnazzaro a9d6367
Fix @anonymous to add cookies manually
mnazzaro 5dfbdd8
Add some creature comfort for get things going.
ntai-arxiv 4a0a1f0
Add some creature comfort for get things going.
ntai-arxiv f62b553
Better (and json) logging.
ntai-arxiv 66b05ab
just a doc update
ntai-arxiv 9bf4f26
merge doc
ntai-arxiv 9ff5344
The test password should be string, not bytes.
ntai-arxiv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""arXiv endorsements controllers.""" | ||
from collections import defaultdict | ||
from datetime import datetime, timedelta | ||
import logging | ||
from admin_webapp.routes import endorsement | ||
|
||
from flask import Blueprint, render_template, request, \ | ||
make_response, current_app, Response, abort | ||
|
||
from flask_sqlalchemy import Pagination | ||
|
||
from sqlalchemy import select, func, case, text, insert, update, desc | ||
from sqlalchemy.dialects.mysql import JSON | ||
from sqlalchemy.orm import joinedload, selectinload, aliased | ||
from arxiv.base import logging | ||
|
||
from arxiv_auth.auth.decorators import scoped | ||
|
||
from arxiv_db.models import Endorsements, EndorsementsAudit, TapirUsers | ||
from arxiv_db.models.associative_tables import t_arXiv_paper_owners | ||
|
||
from admin_webapp.extensions import get_csrf, get_db | ||
from admin_webapp.admin_log import audit_admin | ||
logger = logging.getLogger(__file__) | ||
|
||
# blueprint = Blueprint('ownership', __name__, url_prefix='/ownership') | ||
""" | ||
All endorsements listing | ||
""" | ||
def endorsement_listing(per_page:int, page: int) -> dict: | ||
session = get_db(current_app).session | ||
report_stmt = (select(Endorsements) | ||
# TODO: do I need a joinedload to prevent N+1 queries | ||
# .options(joinedload(TapirUsers.tapir_nicknames)) | ||
.limit(per_page).offset((page -1) * per_page)).join(EndorsementsAudit, isouter=True) | ||
|
||
count_stmt = (select(func.count(Endorsements.endorsement_id))) | ||
|
||
endorsements = session.scalars(report_stmt) | ||
count = session.execute(count_stmt).scalar_one() | ||
pagination = Pagination(query=None, page=page, per_page=per_page, total=count, items=None) | ||
|
||
|
||
return dict(pagination=pagination, count=count, endorsements=endorsements) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from flask import current_app, Response | ||
from flask_sqlalchemy import Pagination | ||
from admin_webapp.extensions import get_db | ||
from sqlalchemy import select, or_, func | ||
from arxiv_db.models import TapirUsers, TapirNicknames | ||
|
||
""" | ||
Basic search logic that does some loose similarity checking: | ||
|
||
""" | ||
def general_search(search_string: str, per_page:int, page: int) -> Response: | ||
session = get_db(current_app).session | ||
|
||
# check if the string is numeric | ||
if search_string.isdigit(): | ||
# Check if unique user exists based on user ID | ||
unique_user_id = session.query(TapirUsers).filter(TapirUsers.user_id==search_string).all() | ||
if len(unique_user_id) == 1: | ||
return dict(count=1, unique_id=search_string) | ||
|
||
# Check if unique user exists based on nickname | ||
unique_user_nickname = session.query(TapirNicknames).filter(TapirNicknames.nickname==search_string).all() | ||
if len(unique_user_nickname) == 1: | ||
return dict(count=1, unique_id=unique_user_nickname[0].user_id) | ||
|
||
# General search logic | ||
stmt = (select(TapirUsers).join(TapirNicknames) | ||
.filter( | ||
or_(TapirUsers.user_id.like(f'%{search_string}%'), | ||
TapirUsers.first_name.like(f'%{search_string}%'), | ||
TapirUsers.last_name.like(f'%{search_string}%'), | ||
TapirNicknames.nickname.like(f'%{search_string}%') | ||
)) | ||
.limit(per_page).offset((page -1) * per_page)) | ||
|
||
count_stmt = (select(func.count(TapirUsers.user_id)).where( | ||
or_(TapirUsers.user_id.like(f'%{search_string}%'), | ||
TapirUsers.first_name.like(f'%{search_string}%'), | ||
TapirUsers.last_name.like(f'%{search_string}%'), | ||
))) | ||
|
||
users = session.scalars(stmt) | ||
count = session.execute(count_stmt).scalar_one() | ||
|
||
pagination = Pagination(query=None, page=page, per_page=per_page, total=count, items=None) | ||
|
||
return dict(pagination=pagination, count=count, users=users) | ||
|
||
def advanced_search(options): | ||
session = get_db(current_app).session | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from flask import current_app, Response | ||
from admin_webapp.extensions import get_db | ||
from sqlalchemy import select, func | ||
from arxiv_db.models import TapirEmailTemplates | ||
import json | ||
|
||
""" | ||
Tapir email templates | ||
""" | ||
def manage_email_templates() -> Response: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a different name here? maybe |
||
session = get_db(current_app).session | ||
|
||
stmt = (select(TapirEmailTemplates)) | ||
count_stmt = (select(func.count(TapirEmailTemplates.template_id))) | ||
|
||
email_templates = session.scalars(stmt) | ||
count = session.execute(count_stmt).scalar_one() | ||
|
||
# return json.dumps(email_templates) | ||
return dict(count=count, email_templates=email_templates) | ||
|
||
def email_template(template_id: int) -> Response: | ||
session = get_db(current_app).session | ||
|
||
stmt = (select(TapirEmailTemplates).where(TapirEmailTemplates.template_id == template_id)) | ||
|
||
template = session.scalar(stmt) | ||
|
||
return dict(template=template) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this based on https://github.com/arXiv/arxiv-auth/blob/develop/accounts/accounts/controllers/registration.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is. (which is good)