fish
This commit is contained in:
parent
a435d7e8cb
commit
70cc5c85e7
9 changed files with 75 additions and 49 deletions
|
@ -251,54 +251,57 @@ def remove_mod(v, sub):
|
|||
|
||||
return redirect(f'/s/{sub}/mods')
|
||||
|
||||
if SITE_NAME == 'PCM':
|
||||
@app.get("/create_sub")
|
||||
@is_not_permabanned
|
||||
def create_sub(v):
|
||||
if v.id == MENTION_ID: cost = 0
|
||||
else:
|
||||
@app.get("/create_sub")
|
||||
@is_not_permabanned
|
||||
def create_sub(v):
|
||||
if SITE_NAME == 'Drama' and v.id not in (AEVANN_ID, CARP_ID): abort(403)
|
||||
|
||||
if v.id == MENTION_ID: cost = 0
|
||||
else:
|
||||
num = v.subs_created + 1
|
||||
for a in v.alts:
|
||||
num += a.subs_created
|
||||
cost = num * 100
|
||||
|
||||
return render_template("sub/create_sub.html", v=v, cost=cost)
|
||||
|
||||
|
||||
@app.post("/create_sub")
|
||||
@is_not_permabanned
|
||||
def create_sub2(v):
|
||||
if SITE_NAME == 'Drama' and v.id not in (AEVANN_ID, CARP_ID): abort(403)
|
||||
|
||||
name = request.values.get('name')
|
||||
if not name: abort(400)
|
||||
name = name.strip().lower()
|
||||
|
||||
if not valid_sub_regex.fullmatch(name):
|
||||
return render_template("sub/create_sub.html", v=v, error="Sub name not allowed."), 400
|
||||
|
||||
sub = g.db.query(Sub).filter_by(name=name).one_or_none()
|
||||
if not sub:
|
||||
if v.id != MENTION_ID:
|
||||
num = v.subs_created + 1
|
||||
for a in v.alts:
|
||||
num += a.subs_created
|
||||
cost = num * 100
|
||||
|
||||
return render_template("sub/create_sub.html", v=v, cost=cost)
|
||||
|
||||
if v.coins < cost:
|
||||
return render_template("sub/create_sub.html", v=v, error="You don't have enough coins!"), 403
|
||||
|
||||
@app.post("/create_sub")
|
||||
@is_not_permabanned
|
||||
def create_sub2(v):
|
||||
name = request.values.get('name')
|
||||
if not name: abort(400)
|
||||
name = name.strip().lower()
|
||||
v.coins -= cost
|
||||
|
||||
if not valid_sub_regex.fullmatch(name):
|
||||
return render_template("sub/create_sub.html", v=v, error="Sub name not allowed."), 400
|
||||
v.subs_created += 1
|
||||
g.db.add(v)
|
||||
|
||||
sub = g.db.query(Sub).filter_by(name=name).one_or_none()
|
||||
if not sub:
|
||||
if v.id != MENTION_ID:
|
||||
num = v.subs_created + 1
|
||||
for a in v.alts:
|
||||
num += a.subs_created
|
||||
cost = num * 100
|
||||
sub = Sub(name=name)
|
||||
g.db.add(sub)
|
||||
g.db.flush()
|
||||
mod = Mod(user_id=v.id, sub=sub.name)
|
||||
g.db.add(mod)
|
||||
g.db.commit()
|
||||
|
||||
if v.coins < cost:
|
||||
return render_template("sub/create_sub.html", v=v, error="You don't have enough coins!"), 403
|
||||
|
||||
v.coins -= cost
|
||||
|
||||
v.subs_created += 1
|
||||
g.db.add(v)
|
||||
|
||||
sub = Sub(name=name)
|
||||
g.db.add(sub)
|
||||
g.db.flush()
|
||||
mod = Mod(user_id=v.id, sub=sub.name)
|
||||
g.db.add(mod)
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f'/s/{sub.name}')
|
||||
return redirect(f'/s/{sub.name}')
|
||||
|
||||
@app.post("/kick/<pid>")
|
||||
@is_not_permabanned
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue