LGB: disable awards, badges.

remotes/1693045480750635534/spooky-22
Snakes 2022-07-19 19:59:39 -04:00
parent 82de9657e9
commit 3225a2a3d4
Signed by: Snakes
GPG Key ID: E745A82778055C7E
14 changed files with 89 additions and 33 deletions

View File

@ -36,13 +36,15 @@ function popclick(e) {
let popover = document.getElementsByClassName("popover")
popover = popover[popover.length-1]
const badgesDOM = popover.getElementsByClassName('pop-badges')[0];
badgesDOM.innerHTML = "";
for (const badge of author["badges"]) {
const badgeDOM = popClickBadgeTemplateDOM.cloneNode();
badgeDOM.src = badge + "?v=1021";
if (popover.getElementsByClassName('pop-badges').length > 0) {
const badgesDOM = popover.getElementsByClassName('pop-badges')[0];
badgesDOM.innerHTML = "";
for (const badge of author["badges"]) {
const badgeDOM = popClickBadgeTemplateDOM.cloneNode();
badgeDOM.src = badge + "?v=1021";
badgesDOM.append(badgeDOM);
badgesDOM.append(badgeDOM);
}
}
popover.getElementsByClassName('pop-banner')[0].src = author["bannerurl"]

View File

@ -145,9 +145,11 @@ PERMS = { # Minimum admin_level to perform action.
FEATURES = {
'PROCOINS': True,
'AWARDS': True,
'CHAT': True,
'PINS': True,
'PRONOUNS': False,
'BADGES': True,
'HOUSES': False,
'USERS_SUICIDE': True,
'GAMBLING': True,
@ -326,7 +328,9 @@ elif SITE == 'lgbdropthet.com':
PERMS['USER_VOTERS_VISIBLE'] = 2
FEATURES['PROCOINS'] = False
FEATURES['AWARDS'] = False
FEATURES['CHAT'] = False
FEATURES['BADGES'] = False
FEATURES['USERS_SUICIDE'] = False
FEATURES['GAMBLING'] = False
@ -352,8 +356,6 @@ else: # localhost or testing environment implied
FEATURES['PRONOUNS'] = True
FEATURES['HOUSES'] = True
FEATURES['GAMBLING'] = False
if SITE == 'deuxrama.net':
PERMS['HOLE_CREATE'] = 3
PERMS['CONTENT_THREADS'] = 2

View File

@ -507,6 +507,9 @@ def under_attack(v):
@app.get("/admin/badge_grant")
@admin_level_required(2)
def badge_grant_get(v):
if not FEATURES['BADGES']:
abort(404)
badges = g.db.query(BadgeDef).order_by(BadgeDef.id).all()
return render_template("admin/badge_grant.html", v=v, badge_types=badges)
@ -515,6 +518,9 @@ def badge_grant_get(v):
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
def badge_grant_post(v):
if not FEATURES['BADGES']:
abort(404)
badges = g.db.query(BadgeDef).order_by(BadgeDef.id).all()
user = get_user(request.values.get("username").strip(), graceful=True)
@ -562,6 +568,9 @@ def badge_grant_post(v):
@app.get("/admin/badge_remove")
@admin_level_required(2)
def badge_remove_get(v):
if not FEATURES['BADGES']:
abort(404)
badges = g.db.query(BadgeDef).order_by(BadgeDef.id).all()
return render_template("admin/badge_remove.html", v=v, badge_types=badges)
@ -571,6 +580,9 @@ def badge_remove_get(v):
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
def badge_remove_post(v):
if not FEATURES['BADGES']:
abort(404)
badges = g.db.query(BadgeDef).order_by(BadgeDef.id).all()
user = get_user(request.values.get("username").strip(), graceful=True)

View File

@ -16,6 +16,9 @@ from copy import deepcopy
@app.get("/settings/shop")
@auth_required
def shop(v):
if not FEATURES['AWARDS']:
abort(404)
AWARDS = deepcopy(AWARDS2)
for val in AWARDS.values(): val["owned"] = 0
@ -34,6 +37,9 @@ def shop(v):
@app.post("/buy/<award>")
@auth_required
def buy(v, award):
if not FEATURES['AWARDS']:
abort(404)
if award == 'benefactor' and not request.values.get("mb"):
return {"error": "You can only buy the Benefactor award with marseybux."}, 403
@ -106,6 +112,8 @@ def buy(v, award):
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@is_not_permabanned
def award_thing(v, thing_type, id):
if not FEATURES['AWARDS']:
abort(404)
if thing_type == 'post': thing = get_post(id)
else: thing = get_comment(id)
@ -315,6 +323,9 @@ def award_thing(v, thing_type, id):
@app.get("/admin/awards")
@admin_level_required(2)
def admin_userawards_get(v):
if not FEATURES['AWARDS']:
abort(404)
if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
if v.admin_level != 3:
@ -326,6 +337,9 @@ def admin_userawards_get(v):
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
def admin_userawards_post(v):
if not FEATURES['AWARDS']:
abort(404)
if SITE == 'pcmemes.net' and v.admin_level < 3: abort(403)
try: u = request.values.get("username").strip()

View File

@ -323,6 +323,9 @@ def badge_list(site):
@app.get("/badges")
@auth_required
def badges(v):
if not FEATURES['BADGES']:
abort(404)
badges, counts = badge_list(SITE)
return render_template("badges.html", v=v, badges=badges, counts=counts)

View File

@ -23,9 +23,13 @@
<li><a href="/admin/users">Users Feed</a></li>
<li><a href="/admin/shadowbanned">Shadowbanned Users</a></li>
<li><a href="/banned">Permabanned Users</a></li>
<li><a href="/agendaposters">Users with Chud Theme</a></li>
<li><a href="/grassed">Currently Grassed Users</a></li>
<li><a href="/patrons">Patrons / Paypigs</a></li>
{% if FEATURES['AWARDS'] -%}
<li><a href="/agendaposters">Users with Chud Theme</a></li>
<li><a href="/grassed">Currently Grassed Users</a></li>
{%- endif %}
{% if FEATURES['PROCOINS'] -%}
<li><a href="/patrons">Patrons / Paypigs</a></li>
{%- endif %}
<li><a href="/admin/loggedin">Currently Logged-in Users</a></li>
<li><a href="/admin/loggedout">Currently Logged-out Users</a></li>
</ul>
@ -36,12 +40,18 @@
<li><a href="/admin/alt_votes">Multi Vote Analysis</a></li>
</ul>
{% if FEATURES['BADGES'] or FEATURES['AWARDS'] -%}
<h4>Grant</h4>
<ul>
<li><a href="/admin/awards">Give User Award</a></li>
<li><a href="/admin/badge_grant">Grant Badges</a></li>
<li><a href="/admin/badge_remove">Remove Badges</a></li>
{% if FEATURES['AWARDS'] -%}
<li><a href="/admin/awards">Give User Award</a></li>
{%- endif %}
{% if FEATURES['BADGES'] -%}
<li><a href="/admin/badge_grant">Grant Badges</a></li>
<li><a href="/admin/badge_remove">Remove Badges</a></li>
{%- endif %}
</ul>
{%- endif %}
<h4>API Access Control</h4>
<ul>

View File

@ -8,7 +8,7 @@
</script>
{% endif %}
{% if v %}
{% if v and FEATURES['AWARDS'] %}
{% include "award_modal.html" %}
{% endif %}
@ -25,8 +25,10 @@
<span class="pop-bio popover-bio text-black"></span>
</div>
{% if FEATURES['BADGES'] -%}
<div class="pop-badges ml-3 mr-3 my-2">
</div>
{%- endif %}
<div class="border-top d-flex align-items-center p-3 gap-3 smol">
<span>
@ -448,7 +450,9 @@
<button class="btn caction py-0 nobackground px-1 text-muted" data-bs-toggle="modal" data-bs-target="#reportCommentModal" onclick="report_commentModal('{{c.id}}','{{c.author_name}}',)"><i class="fas fa-flag fa-fw"></i>Report</button>
{% if FEATURES['AWARDS'] -%}
<button class="btn caction py-0 nobackground px-1 text-muted" role="button" data-bs-toggle="modal" data-bs-target="#awardModal" data-url="/award/comment/{{c.id}}"><i class="fas fa-gift" aria-hidden="true"></i>Give Award</button>
{%- endif %}
<button id="unsave-{{c.id}}" class="btn caction py-0 nobackground px-1 {% if c.id in v.saved_comment_idlist %}d-md-inline-block{% endif %} text-muted d-none" role="button" onclick="post_toast(this,'/unsave_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}','d-md-inline-block')"><i class="fas fa-save"></i>Unsave</button>
@ -653,7 +657,9 @@
{% if v %}
<a role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportCommentModal" onclick="report_commentModal('{{c.id}}','{{c.author_name}}')" class="list-group-item"><i class="fas fa-flag mr-2"></i>Report</a>
{% if FEATURES['AWARDS'] -%}
<a class="list-group-item" role="button" data-bs-toggle="modal" data-bs-target="#awardModal" data-url="/award/comment/{{c.id}}"><i class="fas fa-gift mr-2" aria-hidden="true"></i>Give Award</a>
{%- endif %}
<a id="save2-{{c.id}}" class="list-group-item {% if c.id in v.saved_comment_idlist %}d-none{% endif %}" role="button" data-bs-dismiss="modal" onclick="post_toast(this,'/save_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}','d-none')"><i class="fas fa-save mr-2"></i>Save</a>

View File

@ -130,11 +130,9 @@
<a class="mobile-nav-icon d-md-none" href="/random_user"><i class="fas fa-music align-middle text-gray-500 black"></i></a>
{% if v and v.can_gamble and LOTTERY_ENABLED %}
<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Lottershe">
<a href="/lottery" class="mobile-nav-icon d-md-none">
<a class="mobile-nav-icon d-md-none" href="/lottery">
<i class="fas fa-ticket align-middle text-gray-500"></i>
</a>
</span>
{% endif %}
<button class="navbar-toggler" role="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive"
@ -188,9 +186,11 @@
</li>
{% endif %}
{% if FEATURES['AWARDS'] -%}
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
<a class="nav-link" href="/shop" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Shop"><i class="fas fa-store"></i></a>
</li>
{%- endif %}
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
<a class="nav-link" href="/comments" data-bs-toggle="tooltip" data-bs-placement="bottom" title="All Comments"><i class="fas fa-comment-dots"></i></a>

View File

@ -57,6 +57,7 @@
</a>
</button>
{%- endif %}
{% if FEATURES['AWARDS'] -%}
<button class="col px-0 mr-3 btn btn-dead m-0" style="background: None !important; border: None;">
<a href="/shop" class="text-decoration-none" role="button">
<div class="text-center {% if request.path=='/shop' %}text-primary{% else %}text-muted{% endif %}">
@ -65,6 +66,7 @@
</div>
</a>
</button>
{%- endif %}
{% else %}
<button class="col px-0 mr-3 btn btn-dead m-0" style="background: None !important; border: None;">
<a href="/signup" class="text-decoration-none" role="button">

View File

@ -8,7 +8,7 @@
{% if v and ((not p.ghost and v.admin_level >= PERMS['VOTES_VISIBLE']) or v.id == AEVANN_ID) %}<a class="list-inline-item" href="/votes/{{p.fullname}}"><i class="fas fa-arrows-v"></i>Votes</a>{% endif %}
{% if v %}
{% if v and FEATURES['AWARDS'] %}
<a class="list-inline-item text-muted d-none d-md-inline-block" role="button" data-bs-toggle="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}'><i class="fas fa-gift fa-fw"></i>Give Award</a>
{% endif %}

View File

@ -12,7 +12,9 @@
<button class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportPostModal" onclick="report_postModal('{{p.id}}')"><i class="far fa-flag text-center text-muted mr-3"></i>Report</button>
{% if FEATURES['AWARDS'] -%}
<button class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}'><i class="fas fa-gift text-center text-muted mr-3"></i>Give Award</button>
{%- endif %}
<button id="subscribe2-{{p.id}}" class="{% if p.id in v.subscribed_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/subscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye text-center text-muted mr-3"></i>Subscribe</button>
<button id="unsubscribe2-{{p.id}}" class="{% if not p.id in v.subscribed_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/unsubscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash text-center text-muted mr-3"></i>Unsubscribe</button>

View File

@ -1,7 +1,7 @@
{%- from 'util/assetcache.html' import asset, asset_siteimg with context -%}
{%- import 'util/helpers.html' as help -%}
{% if v %}
{% if v and FEATURES['AWARDS'] %}
{% include "award_modal.html" %}
{% endif %}
@ -28,8 +28,10 @@
<span class="pop-bio popover-bio text-black"></span>
</div>
{% if FEATURES['BADGES'] -%}
<div class="pop-badges ml-3 mr-3 my-2">
</div>
{%- endif %}
<div class="border-top d-flex align-items-center p-3 gap-3 smol">
<span>

View File

@ -157,7 +157,7 @@
<div id="profile--enemies">{{u.enemies_html | safe}}</div>
{% endif %}
{% if u.received_awards %}
{% if u.received_awards and FEATURES['AWARDS'] %}
<div class="text-white rounded p-2 mb-3" id="profile--awards" style="background-color: rgba(50, 50, 50, 0.6); width: 30%;">
<p class="text-uppercase my-0" style="font-weight: bold; font-size: 12px;">Awards received</p>
{% for a in u.received_awards %}
@ -352,17 +352,18 @@
</div>
</div>
</div>
<div id="profile--badges">
{% for b in u.badges %}
{% if b.url %}
<a rel="nofollow noopener noreferrer" href="{{b.url}}"><img alt="{{b.name}}" width=55 height=60 loading="lazy" src="{{b.path}}?v=1021" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{b.text}}" {% if b.until %}data-until="{{b.until}}" onmouseover="badge_timestamp(this)"{% endif %}></a>
{% else %}
<img alt="{{b.name}}" width=55 height=60 loading="lazy" src="{{b.path}}?v=1021" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{b.text}}" {% if b.until %}data-until="{{b.until}}" onmouseover="badge_timestamp(this)"{% endif %}>
{% endif %}
{% endfor %}
</div>
{% if FEATURES['BADGES'] -%}
<div id="profile--badges">
{% for b in u.badges %}
{% if b.url %}
<a rel="nofollow noopener noreferrer" href="{{b.url}}"><img alt="{{b.name}}" width=55 height=60 loading="lazy" src="{{b.path}}?v=1021" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{b.text}}" {% if b.until %}data-until="{{b.until}}" onmouseover="badge_timestamp(this)"{% endif %}></a>
{% else %}
<img alt="{{b.name}}" width=55 height=60 loading="lazy" src="{{b.path}}?v=1021" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{b.text}}" {% if b.until %}data-until="{{b.until}}" onmouseover="badge_timestamp(this)"{% endif %}>
{% endif %}
{% endfor %}
</div>
{%- endif %}
</div>
</div>
</div>
@ -471,7 +472,7 @@
<div id="profile-mobile--enemies">{{u.enemies_html | safe}}</div>
{% endif %}
{% if u.received_awards %}
{% if u.received_awards and FEATURES['AWARDS'] %}
<div class="text-white rounded p-2 my-3 text-center" id="profile-mobile--awards" style="background-color: rgba(50, 50, 50, 0.6);">
<p class="text-uppercase my-0" style="font-weight: bold; font-size: 12px;">Awards received</p>
{% for a in u.received_awards %}

View File

@ -18,7 +18,7 @@ set CACHE_VER = {
'js/award_modal.js': 253,
'js/bootstrap.js': 275,
'js/comments+submission_listing.js': 263,
'js/comments+submission_listing.js': 264,
'js/submission_listing.js': 261,
'js/emoji_modal.js': 312,
'js/formatting.js': 240,