Skip to content

Commit

Permalink
add no-limits users that are no admins
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunsi committed Dec 18, 2024
1 parent ef74d9e commit 2fbbb09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
login_disabled_for_user,
login_required,
user_is_admin,
user_without_limits,
)
from ib_hosted import get_scoped_api_key, ib, update_asset_userdata
from notifier import Notifier
Expand Down Expand Up @@ -125,6 +126,7 @@ def collect(self) -> Iterable[Metric]:
def before_request():
user = session.get("gh_login")
g.user_is_admin = user_is_admin(user)
g.user_without_limits = user_without_limits(user)

if login_disabled_for_user(user):
g.user = None
Expand Down Expand Up @@ -333,6 +335,16 @@ def content_request_review(asset_id):
)
)
moderation_message += "It was automatically confirmed because user is an admin."
elif g.user_without_limits:
update_asset_userdata(asset, state=State.CONFIRMED, moderated_by=g.user)
app.logger.warn(
"auto-confirming {} because it was uploaded by no-limits user {}".format(
asset["id"], g.user
)
)
moderation_message += (
"It was automatically confirmed because user is on the no-limits list."
)
else:
moderation_url = url_for("content_moderate", asset_id=asset_id, _external=True)
app.logger.info(
Expand Down
6 changes: 5 additions & 1 deletion helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def user_is_admin(user) -> bool:
return user is not None and user.lower() in CONFIG.get("ADMIN_USERS", set())


def user_without_limits(user) -> bool:
return user is not None and user.lower() in CONFIG.get("NO_LIMIT_USERS", set())


def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
Expand Down Expand Up @@ -143,7 +147,7 @@ def get_all_live_assets(no_time_filter=False):


def login_disabled_for_user(user=None):
if user_is_admin(user):
if user_is_admin(user) or user_without_limits(user):
return False

now = datetime.now().timestamp()
Expand Down

0 comments on commit 2fbbb09

Please sign in to comment.