forked from rDrama/rDrama
fsfsd
parent
92b587bfea
commit
833058c2d1
|
@ -137,110 +137,57 @@ def remove_fake_admin(v, username):
|
||||||
return {"message": "Fake admin removed!"}
|
return {"message": "Fake admin removed!"}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/admin/monthly")
|
@app.post("/admin/monthly")
|
||||||
|
@limiter.limit("1/day")
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
def monthly(v):
|
def monthly(v):
|
||||||
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [1,12,28,29,747,995,1480]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
_awards = []
|
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
||||||
t = time.time()
|
for u in g.db.query(User).options(lazyload('*')).filter(User.patron > 0).all():
|
||||||
for u in g.db.query(User).options(lazyload('*')).filter(User.patron > 0).all():
|
grant_awards = {}
|
||||||
grant_awards = {}
|
|
||||||
|
|
||||||
if u.patron == 1:
|
if u.patron == 1:
|
||||||
grant_awards["shit"] = 1
|
grant_awards["shit"] = 1
|
||||||
grant_awards["stars"] = 1
|
grant_awards["stars"] = 1
|
||||||
elif u.patron == 2:
|
elif u.patron == 2:
|
||||||
grant_awards["shit"] = 3
|
grant_awards["shit"] = 3
|
||||||
grant_awards["stars"] = 3
|
grant_awards["stars"] = 3
|
||||||
elif u.patron == 3:
|
elif u.patron == 3:
|
||||||
grant_awards["shit"] = 5
|
grant_awards["shit"] = 5
|
||||||
grant_awards["stars"] = 5
|
grant_awards["stars"] = 5
|
||||||
grant_awards["ban"] = 1
|
grant_awards["ban"] = 1
|
||||||
elif u.patron == 4:
|
elif u.patron == 4:
|
||||||
grant_awards["shit"] = 10
|
grant_awards["shit"] = 10
|
||||||
grant_awards["stars"] = 10
|
grant_awards["stars"] = 10
|
||||||
grant_awards["ban"] = 3
|
grant_awards["ban"] = 3
|
||||||
elif u.patron == 5 or u.patron == 8:
|
elif u.patron == 5 or u.patron == 8:
|
||||||
grant_awards["shit"] = 20
|
grant_awards["shit"] = 20
|
||||||
grant_awards["stars"] = 20
|
grant_awards["stars"] = 20
|
||||||
grant_awards["ban"] = 6
|
grant_awards["ban"] = 6
|
||||||
|
|
||||||
|
|
||||||
for name in grant_awards:
|
for name in grant_awards:
|
||||||
for count in range(grant_awards[name]):
|
for count in range(grant_awards[name]):
|
||||||
|
|
||||||
thing += 1
|
thing += 1
|
||||||
|
|
||||||
_awards.append(AwardRelationship(
|
award = AwardRelationship(
|
||||||
id=thing,
|
id=thing,
|
||||||
user_id=u.id,
|
user_id=u.id,
|
||||||
kind=name
|
kind=name
|
||||||
))
|
)
|
||||||
|
|
||||||
text = "You were given the following awards:\n\n"
|
g.db.add(award)
|
||||||
|
|
||||||
for key, value in grant_awards.items():
|
text = "You were given the following awards:\n\n"
|
||||||
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
|
|
||||||
|
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
|
for key, value in grant_awards.items():
|
||||||
|
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
|
||||||
|
|
||||||
|
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
|
||||||
|
|
||||||
g.db.add_all(_awards)
|
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
print(time.time() - t)
|
|
||||||
return {"message": "Monthly awards granted"}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/admin/monthly2")
|
|
||||||
@admin_level_required(6)
|
|
||||||
def monthly2(v):
|
|
||||||
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
|
||||||
t = time.time()
|
|
||||||
for u in g.db.query(User).options(lazyload('*')).filter(User.patron > 0).all():
|
|
||||||
grant_awards = {}
|
|
||||||
|
|
||||||
if u.patron == 1:
|
|
||||||
grant_awards["shit"] = 1
|
|
||||||
grant_awards["stars"] = 1
|
|
||||||
elif u.patron == 2:
|
|
||||||
grant_awards["shit"] = 3
|
|
||||||
grant_awards["stars"] = 3
|
|
||||||
elif u.patron == 3:
|
|
||||||
grant_awards["shit"] = 5
|
|
||||||
grant_awards["stars"] = 5
|
|
||||||
grant_awards["ban"] = 1
|
|
||||||
elif u.patron == 4:
|
|
||||||
grant_awards["shit"] = 10
|
|
||||||
grant_awards["stars"] = 10
|
|
||||||
grant_awards["ban"] = 3
|
|
||||||
elif u.patron == 5 or u.patron == 8:
|
|
||||||
grant_awards["shit"] = 20
|
|
||||||
grant_awards["stars"] = 20
|
|
||||||
grant_awards["ban"] = 6
|
|
||||||
|
|
||||||
|
|
||||||
for name in grant_awards:
|
|
||||||
for count in range(grant_awards[name]):
|
|
||||||
|
|
||||||
thing += 1
|
|
||||||
|
|
||||||
a = AwardRelationship(
|
|
||||||
id=thing,
|
|
||||||
user_id=u.id,
|
|
||||||
kind=name
|
|
||||||
)
|
|
||||||
g.db.add(a)
|
|
||||||
|
|
||||||
text = "You were given the following awards:\n\n"
|
|
||||||
|
|
||||||
for key, value in grant_awards.items():
|
|
||||||
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
|
|
||||||
|
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
|
|
||||||
|
|
||||||
g.db.commit()
|
|
||||||
print(time.time() - t)
|
|
||||||
return {"message": "Monthly awards granted"}
|
return {"message": "Monthly awards granted"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,8 +409,6 @@ def badge_grant_post(v):
|
||||||
|
|
||||||
if len(grant_awards):
|
if len(grant_awards):
|
||||||
|
|
||||||
_awards = []
|
|
||||||
|
|
||||||
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
||||||
|
|
||||||
for name in grant_awards:
|
for name in grant_awards:
|
||||||
|
@ -471,13 +416,13 @@ def badge_grant_post(v):
|
||||||
|
|
||||||
thing += 1
|
thing += 1
|
||||||
|
|
||||||
_awards.append(AwardRelationship(
|
award = AwardRelationship(
|
||||||
id=thing,
|
id=thing,
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
kind=name
|
kind=name
|
||||||
))
|
)
|
||||||
|
|
||||||
g.db.add_all(_awards)
|
g.db.add(award)
|
||||||
|
|
||||||
text = "You were given the following awards:\n\n"
|
text = "You were given the following awards:\n\n"
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,6 @@ def admin_userawards_post(v):
|
||||||
|
|
||||||
u = get_user(request.form.get("username", '1'), graceful=False, v=v)
|
u = get_user(request.form.get("username", '1'), graceful=False, v=v)
|
||||||
|
|
||||||
awards = []
|
|
||||||
notify_awards = {}
|
notify_awards = {}
|
||||||
|
|
||||||
latest = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first()
|
latest = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first()
|
||||||
|
@ -348,13 +347,14 @@ def admin_userawards_post(v):
|
||||||
for x in range(int(value)):
|
for x in range(int(value)):
|
||||||
thing += 1
|
thing += 1
|
||||||
|
|
||||||
awards.append(AwardRelationship(
|
award = AwardRelationship(
|
||||||
id=thing,
|
id=thing,
|
||||||
user_id=u.id,
|
user_id=u.id,
|
||||||
kind=key
|
kind=key
|
||||||
))
|
)
|
||||||
|
|
||||||
|
g.db.add(award)
|
||||||
|
|
||||||
g.db.add_all(awards)
|
|
||||||
text = "You were given the following awards:\n\n"
|
text = "You were given the following awards:\n\n"
|
||||||
|
|
||||||
for key, value in notify_awards.items():
|
for key, value in notify_awards.items():
|
||||||
|
|
|
@ -339,8 +339,6 @@ def gumroad(v):
|
||||||
grant_awards["stars"] = 20
|
grant_awards["stars"] = 20
|
||||||
grant_awards["ban"] = 6
|
grant_awards["ban"] = 6
|
||||||
|
|
||||||
_awards = []
|
|
||||||
|
|
||||||
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
||||||
|
|
||||||
for name in grant_awards:
|
for name in grant_awards:
|
||||||
|
@ -348,13 +346,13 @@ def gumroad(v):
|
||||||
|
|
||||||
thing += 1
|
thing += 1
|
||||||
|
|
||||||
_awards.append(AwardRelationship(
|
award = AwardRelationship(
|
||||||
id=thing,
|
id=thing,
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
kind=name
|
kind=name
|
||||||
))
|
)
|
||||||
|
|
||||||
g.db.add_all(_awards)
|
g.db.add(award)
|
||||||
|
|
||||||
if not v.has_badge(20+tier):
|
if not v.has_badge(20+tier):
|
||||||
new_badge = Badge(badge_id=20+tier,
|
new_badge = Badge(badge_id=20+tier,
|
||||||
|
|
Loading…
Reference in New Issue