gf
This commit is contained in:
parent
a69c5351fe
commit
f3bb52e379
34 changed files with 3208 additions and 3185 deletions
|
@ -194,7 +194,8 @@ def get_comment(i, v=None, graceful=False):
|
|||
UserBlock.user_id == v.id,
|
||||
UserBlock.target_id == comment.author_id
|
||||
),
|
||||
and_(UserBlock.user_id == comment.author_id,
|
||||
and_(
|
||||
UserBlock.user_id == comment.author_id,
|
||||
UserBlock.target_id == v.id
|
||||
)
|
||||
)
|
||||
|
|
|
@ -203,12 +203,10 @@ def award_post(pid, v):
|
|||
return {"error": "That award doesn't exist."}, 404
|
||||
|
||||
post_award = g.db.query(AwardRelationship).filter(
|
||||
and_(
|
||||
AwardRelationship.kind == kind,
|
||||
AwardRelationship.user_id == v.id,
|
||||
AwardRelationship.submission_id == None,
|
||||
AwardRelationship.comment_id == None
|
||||
)
|
||||
).first()
|
||||
|
||||
if not post_award:
|
||||
|
@ -439,12 +437,10 @@ def award_comment(cid, v):
|
|||
return {"error": "That award doesn't exist."}, 404
|
||||
|
||||
comment_award = g.db.query(AwardRelationship).filter(
|
||||
and_(
|
||||
AwardRelationship.kind == kind,
|
||||
AwardRelationship.user_id == v.id,
|
||||
AwardRelationship.submission_id == None,
|
||||
AwardRelationship.comment_id == None
|
||||
)
|
||||
).first()
|
||||
|
||||
if not comment_award:
|
||||
|
|
|
@ -52,6 +52,20 @@ def ghost_price(v):
|
|||
|
||||
return int(500*discount)
|
||||
|
||||
|
||||
def submit_ghost(v,db):
|
||||
ghost = db.query(AwardRelationship.id).filter(
|
||||
AwardRelationship.kind == 'ghosts',
|
||||
AwardRelationship.user_id == v.id,
|
||||
AwardRelationship.submission_id == None,
|
||||
AwardRelationship.comment_id == None
|
||||
).first()
|
||||
|
||||
if ghost: ghost = 42069
|
||||
else: ghost = ghost_price(v)
|
||||
return ghost
|
||||
|
||||
|
||||
@app.post("/toggle_club/<pid>")
|
||||
@auth_required
|
||||
def toggle_club(pid, v):
|
||||
|
@ -112,7 +126,7 @@ def submit_get(v, sub=None):
|
|||
|
||||
if request.path.startswith('/s/') and not sub: abort(404)
|
||||
|
||||
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, sub=sub, price=ghost_price(v))
|
||||
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, sub=sub, ghost=submit_ghost(v,g.db))
|
||||
|
||||
@app.get("/post/<pid>")
|
||||
@app.get("/post/<pid>/<anything>")
|
||||
|
@ -847,7 +861,7 @@ def submit_post(v, sub=None):
|
|||
def error(error):
|
||||
print(sub, flush=True)
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): error(error)
|
||||
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=error, title=title, url=url, body=body, price=ghost_price(v)), 400
|
||||
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=error, title=title, url=url, body=body, price=submit_ghost(v,g.db)), 400
|
||||
|
||||
if v.is_suspended: error( "You can't perform this action while banned.")
|
||||
|
||||
|
@ -1079,19 +1093,6 @@ def submit_post(v, sub=None):
|
|||
|
||||
if embed and len(embed) > 1500: embed = None
|
||||
|
||||
ghost = False
|
||||
if request.values.get('ghost'):
|
||||
|
||||
price = ghost_price(v)
|
||||
|
||||
if v.coins >= price:
|
||||
v.coins -= price
|
||||
ghost = True
|
||||
elif v.procoins >= price:
|
||||
v.procoins -= price
|
||||
ghost = True
|
||||
|
||||
|
||||
new_post = Submission(
|
||||
private=bool(request.values.get("private","")),
|
||||
club=club,
|
||||
|
@ -1106,12 +1107,33 @@ def submit_post(v, sub=None):
|
|||
title=title[:500],
|
||||
title_html=title_html,
|
||||
sub=sub,
|
||||
ghost=ghost
|
||||
ghost=False
|
||||
)
|
||||
|
||||
g.db.add(new_post)
|
||||
g.db.flush()
|
||||
|
||||
if request.values.get('ghost'):
|
||||
|
||||
ghost_award = g.db.query(AwardRelationship).filter(
|
||||
AwardRelationship.kind == 'ghosts',
|
||||
AwardRelationship.user_id == v.id,
|
||||
AwardRelationship.submission_id == None,
|
||||
AwardRelationship.comment_id == None
|
||||
).first()
|
||||
|
||||
if ghost_award:
|
||||
ghost_award.submission_id = new_post.id
|
||||
new_post.ghost = True
|
||||
else:
|
||||
price = ghost_price(v)
|
||||
if v.coins >= price:
|
||||
v.coins -= price
|
||||
new_post.ghost = True
|
||||
elif v.procoins >= price:
|
||||
v.procoins -= price
|
||||
new_post.ghost = True
|
||||
|
||||
if v and v.admin_level > 2:
|
||||
for option in bet_options:
|
||||
bet_option = Comment(author_id=AUTOBETTER_ID,
|
||||
|
|
|
@ -183,8 +183,12 @@
|
|||
{% endif %}
|
||||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input {% if v.coins < price and v.procoins < price %}disabled{% endif %} autocomplete="off" type="checkbox" class="custom-control-input" id="ghostCheck" name="ghost">
|
||||
<label class="custom-control-label" for="ghostCheck">Ghost Thread (cost: {{price}} coins or marseybux)</label>
|
||||
<input {% if ghost != 42069 and v.coins < ghost and v.procoins < ghost %}disabled{% endif %} autocomplete="off" type="checkbox" class="custom-control-input" id="ghostCheck" name="ghost">
|
||||
{% if ghost == 42069 %}
|
||||
<label class="custom-control-label" for="ghostCheck">Ghost Thread (will use a ghost award you own)</label>
|
||||
{% else %}
|
||||
<label class="custom-control-label" for="ghostCheck">Ghost Thread (cost: {{ghost}} coins or marseybux)</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<pre>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue