forked from rDrama/rDrama
remove unnecessary shit in badge_grant()
parent
9712a195f8
commit
68a1684035
|
@ -3,24 +3,13 @@ from flask import g
|
||||||
from files.classes.badges import Badge
|
from files.classes.badges import Badge
|
||||||
from files.helpers.alerts import send_repeatable_notification
|
from files.helpers.alerts import send_repeatable_notification
|
||||||
|
|
||||||
def badge_grant(user, badge_id, description=None, url=None, notify=True, check_if_exists=True):
|
def badge_grant(user, badge_id, notify=True, check_if_exists=True):
|
||||||
assert user != None
|
existing = g.db.query(Badge).filter_by(user_id=user.id, badge_id=badge_id).one_or_none()
|
||||||
|
if existing: return
|
||||||
if check_if_exists:
|
|
||||||
existing = g.db.query(Badge).filter_by(user_id=user.id, badge_id=badge_id).one_or_none()
|
|
||||||
if existing: return
|
|
||||||
|
|
||||||
if description and len(description) > 256:
|
|
||||||
abort(400, "Custom description is too long, max 256 characters!")
|
|
||||||
|
|
||||||
if url and len(url) > 256:
|
|
||||||
abort(400, "URL is too long, max 256 characters!")
|
|
||||||
|
|
||||||
badge = Badge(
|
badge = Badge(
|
||||||
badge_id=int(badge_id),
|
badge_id=int(badge_id),
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
description=description,
|
|
||||||
url=url,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(badge)
|
g.db.add(badge)
|
||||||
|
|
Loading…
Reference in New Issue