Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0a3cda2b52
8 changed files with 67 additions and 66 deletions
|
@ -436,6 +436,7 @@ def badge_grant_post(v):
|
||||||
|
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return redirect("/admin/badge_grant")
|
return redirect("/admin/badge_grant")
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,6 @@ ALLOW_MULTIPLE = (
|
||||||
|
|
||||||
@app.post("/post/<pid>/awards")
|
@app.post("/post/<pid>/awards")
|
||||||
@auth_required
|
@auth_required
|
||||||
@validate_formkey
|
|
||||||
def award_post(pid, v):
|
def award_post(pid, v):
|
||||||
|
|
||||||
if v.is_suspended and v.unban_utc == 0:
|
if v.is_suspended and v.unban_utc == 0:
|
||||||
|
@ -260,12 +259,11 @@ def award_post(pid, v):
|
||||||
g.db.add(post.author)
|
g.db.add(post.author)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Award given!"}
|
return redirect(request.referrer)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/comment/<cid>/awards")
|
@app.post("/comment/<cid>/awards")
|
||||||
@auth_required
|
@auth_required
|
||||||
@validate_formkey
|
|
||||||
def award_comment(cid, v):
|
def award_comment(cid, v):
|
||||||
|
|
||||||
if v.is_suspended and v.unban_utc == 0:
|
if v.is_suspended and v.unban_utc == 0:
|
||||||
|
@ -325,7 +323,7 @@ def award_comment(cid, v):
|
||||||
g.db.add(c.author)
|
g.db.add(c.author)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Award given!"}
|
return redirect(request.referrer)
|
||||||
|
|
||||||
@app.get("/admin/user_award")
|
@app.get("/admin/user_award")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -161,7 +161,7 @@ def api_comment(v):
|
||||||
|
|
||||||
if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400
|
if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400
|
||||||
|
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
@ -607,7 +607,7 @@ def edit_comment(cid, v):
|
||||||
if c.is_banned or c.deleted_utc > 0: abort(403)
|
if c.is_banned or c.deleted_utc > 0: abort(403)
|
||||||
|
|
||||||
body = request.form.get("body", "")[:10000]
|
body = request.form.get("body", "")[:10000]
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
|
@ -47,17 +47,29 @@ def check_for_alts(current_id):
|
||||||
|
|
||||||
otheralts = g.db.query(Alt).options(lazyload('*')).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
|
otheralts = g.db.query(Alt).options(lazyload('*')).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
|
||||||
for a in otheralts:
|
for a in otheralts:
|
||||||
|
try:
|
||||||
new_alt = Alt(user1=a.user1, user2=past_id)
|
new_alt = Alt(user1=a.user1, user2=past_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
except: g.db.rollback()
|
||||||
for a in otheralts:
|
for a in otheralts:
|
||||||
|
try:
|
||||||
new_alt = Alt(user1=a.user1, user2=current_id)
|
new_alt = Alt(user1=a.user1, user2=current_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
except: g.db.rollback()
|
||||||
for a in otheralts:
|
for a in otheralts:
|
||||||
|
try:
|
||||||
new_alt = Alt(user1=a.user2, user2=past_id)
|
new_alt = Alt(user1=a.user2, user2=past_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
except: g.db.rollback()
|
||||||
for a in otheralts:
|
for a in otheralts:
|
||||||
|
try:
|
||||||
new_alt = Alt(user1=a.user2, user2=current_id)
|
new_alt = Alt(user1=a.user2, user2=current_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
except: g.db.rollback()
|
||||||
|
|
||||||
# login post procedure
|
# login post procedure
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ def toggle_club(pid, v):
|
||||||
|
|
||||||
post = get_post(pid)
|
post = get_post(pid)
|
||||||
|
|
||||||
if (post.author_id != v.id or v.club_banned) and not v.admin_level >= 3: abort(403)
|
if post.author_id != v.id or not v.paid_dues: abort(403)
|
||||||
|
|
||||||
post.club = not post.club
|
post.club = not post.club
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
@ -251,7 +251,7 @@ def edit_post(pid, v):
|
||||||
p.title_html = filter_title(title)
|
p.title_html = filter_title(title)
|
||||||
|
|
||||||
if body != p.body:
|
if body != p.body:
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
@ -803,7 +803,7 @@ def submit_post(v):
|
||||||
else: return render_template("submit.html", v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.form.get("body", "")), 400
|
else: return render_template("submit.html", v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.form.get("body", "")), 400
|
||||||
|
|
||||||
# render text
|
# render text
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
@ -859,9 +859,12 @@ def submit_post(v):
|
||||||
# check for embeddable video
|
# check for embeddable video
|
||||||
domain = parsed_url.netloc
|
domain = parsed_url.netloc
|
||||||
|
|
||||||
|
if v.paid_dues: club = bool(request.form.get("club",""))
|
||||||
|
else: club = False
|
||||||
|
|
||||||
new_post = Submission(
|
new_post = Submission(
|
||||||
private=bool(request.form.get("private","")),
|
private=bool(request.form.get("private","")),
|
||||||
club=bool(request.form.get("club","")),
|
club=club,
|
||||||
author_id=v.id,
|
author_id=v.id,
|
||||||
over_18=bool(request.form.get("over_18","")),
|
over_18=bool(request.form.get("over_18","")),
|
||||||
app_id=v.client.application.id if v.client else None,
|
app_id=v.client.application.id if v.client else None,
|
||||||
|
|
|
@ -102,7 +102,7 @@ def settings_profile_post(v):
|
||||||
if request.values.get("bio"):
|
if request.values.get("bio"):
|
||||||
bio = request.values.get("bio")[:1500]
|
bio = request.values.get("bio")[:1500]
|
||||||
|
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', bio, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', bio, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'})')
|
if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'})')
|
||||||
bio = bio.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
bio = bio.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
|
|
||||||
|
@ -312,6 +312,7 @@ def gumroad(v):
|
||||||
return {"error": f"{patron} rewards already claimed"}, 400
|
return {"error": f"{patron} rewards already claimed"}, 400
|
||||||
|
|
||||||
v.patron = tier
|
v.patron = tier
|
||||||
|
g.db.add(v)
|
||||||
|
|
||||||
grant_awards = {}
|
grant_awards = {}
|
||||||
if tier == 1:
|
if tier == 1:
|
||||||
|
@ -355,12 +356,12 @@ def gumroad(v):
|
||||||
|
|
||||||
g.db.bulk_save_objects(_awards)
|
g.db.bulk_save_objects(_awards)
|
||||||
|
|
||||||
|
if not v.has_badge(20+tier):
|
||||||
new_badge = Badge(badge_id=20+tier,
|
new_badge = Badge(badge_id=20+tier,
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
)
|
)
|
||||||
g.db.add(new_badge)
|
g.db.add(new_badge)
|
||||||
|
|
||||||
g.db.add(v)
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return {"message": f"{patron} rewards claimed!"}
|
return {"message": f"{patron} rewards claimed!"}
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
<input type="hidden" id="awardTarget" value="" />
|
<script>
|
||||||
|
function bruh(kind) {
|
||||||
|
document.getElementById('giveaward').disabled=false;
|
||||||
|
document.getElementById('kind').value=kind;
|
||||||
|
try {document.getElementsByClassName('picked')[0].classList.toggle('picked');} catch(e) {}
|
||||||
|
document.getElementById(kind).classList.toggle('picked')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered" role="document">
|
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -9,35 +17,24 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="awardModalBody" class="modal-body">
|
<div id="awardModalBody" class="modal-body">
|
||||||
<form class="pt-3 pb-0" action="/post/{{p.id}}/awards" method="post">
|
<form id="awardTarget" class="pt-3 pb-0" action="" method="post">
|
||||||
<div class="card-columns awards-wrapper">
|
<div class="card-columns awards-wrapper">
|
||||||
{% for award in v.user_awards %}
|
{% for award in v.user_awards %}
|
||||||
<div>
|
<a href="javascript:void(0)" id="{{award.kind}}" class="card" onclick="bruh('{{award.kind}}')">
|
||||||
<label class="card" onclick="document.getElementById('desc-{{award.kind}}').classList.toggle('d-none');document.getElementById('giveaward').disabled=false">
|
|
||||||
<i class="{{award.icon}} {{award.color}}"></i><br />
|
<i class="{{award.icon}} {{award.color}}"></i><br />
|
||||||
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px;">{{award.title}}</span>
|
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px; color:#E1E1E1">{{award.title}}</span>
|
||||||
<span class="text-muted">{{award.owned}} owned</span>
|
<span class="text-muted">{{award.owned}} owned</span>
|
||||||
</label>
|
</a>
|
||||||
</div>
|
|
||||||
<div id="desc-{{award.kind}}" class="d-none">
|
|
||||||
<div class="award-desc p-3">
|
|
||||||
<i style="font-size: 35px;"></i>
|
|
||||||
<div style="margin-left: 15px;">
|
|
||||||
<strong>{{pickedAward.title}} Award</strong><br />
|
|
||||||
<span class="text-muted">{{pickedAward.description}}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<label for="note" class="pt-4">Note (optional):</label>
|
|
||||||
<textarea id="note" name="note" class="form-control" placeholder="Note to include in award notification"></textarea>
|
|
||||||
</div>
|
|
||||||
<input name="{{award.kind}}" hidden>
|
|
||||||
<input id="giveaward" class="btn btn-primary" type="submit" value="Give Award" disabled>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
<label for="note" class="pt-4">Note (optional):</label>
|
||||||
|
<input id="kind" name="kind" value="" hidden>
|
||||||
|
<textarea id="note" name="note" class="form-control" placeholder="Note to include in award notification"></textarea>
|
||||||
|
<input id="giveaward" class="btn btn-primary" style="float:right" type="submit" value="Give Award" disabled>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -45,36 +42,26 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.awards-wrapper label {
|
.awards-wrapper a {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
text-transform: none!important;
|
text-transform: none!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.awards-wrapper label i {
|
.awards-wrapper a i {
|
||||||
font-size: 45px;
|
font-size: 45px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.awards-wrapper label.disabled {
|
.awards-wrapper a.disabled {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.awards-wrapper label:hover {
|
.awards-wrapper a:hover, .picked {
|
||||||
/*background-color: rgba(173, 226, 255, 0.7)!important;*/
|
|
||||||
background-color: var(--primary)!important;
|
background-color: var(--primary)!important;
|
||||||
background-opacity: 0.4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.awards-wrapper input[type="radio"]:checked+label {
|
.awards-wrapper input[type="radio"]:checked+a {
|
||||||
/*background-color: rgba(173, 226, 255, 0.9)!important;*/
|
|
||||||
background-color: var(--primary)!important;
|
background-color: var(--primary)!important;
|
||||||
background-opacity: 0.9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.award-desc {
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: rgba(221, 221, 221, 0.23);
|
|
||||||
display: flex;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -670,8 +670,7 @@
|
||||||
|
|
||||||
function awardModal(link) {
|
function awardModal(link) {
|
||||||
var target = document.getElementById("awardTarget");
|
var target = document.getElementById("awardTarget");
|
||||||
|
target.action = link;
|
||||||
target.value = link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand Images on Desktop
|
// Expand Images on Desktop
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue