forked from rDrama/rDrama
remove redundant function
parent
324037c049
commit
a9a16c8376
|
@ -11,28 +11,6 @@ def sanitize_username(username):
|
|||
if not username: return username
|
||||
return username.replace('\\', '').replace('_', '\_').replace('%', '').replace('(', '').replace(')', '').strip()
|
||||
|
||||
def get_id(username, graceful=False):
|
||||
username = sanitize_username(username)
|
||||
if not username:
|
||||
if graceful: return None
|
||||
abort(400, "Empty username.")
|
||||
|
||||
user = g.db.query(
|
||||
User.id
|
||||
).filter(
|
||||
or_(
|
||||
User.username.ilike(username),
|
||||
User.original_username.ilike(username),
|
||||
User.prelock_username.ilike(username),
|
||||
)
|
||||
).one_or_none()
|
||||
|
||||
if not user:
|
||||
if graceful: return None
|
||||
abort(404, "User not found.")
|
||||
|
||||
return user[0]
|
||||
|
||||
def get_user(username, v=None, graceful=False, include_blocks=False, attributes=None):
|
||||
if not username:
|
||||
if graceful: return None
|
||||
|
|
|
@ -170,7 +170,7 @@ def log(v):
|
|||
page = get_page()
|
||||
|
||||
admin = request.values.get("admin")
|
||||
if admin: admin_id = get_id(admin)
|
||||
if admin: admin_id = get_user(admin, attributes=[User.id]).id
|
||||
else: admin_id = 0
|
||||
|
||||
kind = request.values.get("kind")
|
||||
|
|
|
@ -854,7 +854,7 @@ def hole_log(v, sub):
|
|||
page = get_page()
|
||||
|
||||
mod = request.values.get("mod")
|
||||
if mod: mod_id = get_id(mod)
|
||||
if mod: mod_id = get_user(mod, attributes=[User.id]).id
|
||||
else: mod_id = 0
|
||||
|
||||
kind = request.values.get("kind")
|
||||
|
|
Loading…
Reference in New Issue