forked from rDrama/rDrama
cvx
parent
d0ec7358a3
commit
dc696bf473
|
@ -14,6 +14,7 @@ from .badges import *
|
||||||
from .clients import *
|
from .clients import *
|
||||||
from .mod_logs import *
|
from .mod_logs import *
|
||||||
from .mod import *
|
from .mod import *
|
||||||
|
from .sub_block import *
|
||||||
from files.__main__ import Base, cache
|
from files.__main__ import Base, cache
|
||||||
from files.helpers.security import *
|
from files.helpers.security import *
|
||||||
import random
|
import random
|
||||||
|
@ -154,6 +155,15 @@ class User(Base):
|
||||||
def mods(self, sub):
|
def mods(self, sub):
|
||||||
return self.id == AEVANN_ID or g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none()
|
return self.id == AEVANN_ID or g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none()
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def all_blocks(self):
|
||||||
|
return tuple(x[0] for x in g.db.query(SubBlock.sub).filter_by(user_id=self.id).all())
|
||||||
|
|
||||||
|
@lazy
|
||||||
|
def blocks(self, sub):
|
||||||
|
return g.db.query(SubBlock).filter_by(user_id=self.id, sub=sub).one_or_none()
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def mod_date(self, sub):
|
def mod_date(self, sub):
|
||||||
if self.id == AEVANN_ID: return 1
|
if self.id == AEVANN_ID: return 1
|
||||||
|
|
|
@ -305,38 +305,38 @@ def monthly(v):
|
||||||
return {"message": "Monthly coins granted"}
|
return {"message": "Monthly coins granted"}
|
||||||
|
|
||||||
|
|
||||||
@app.get('/admin/sidebar')
|
# @app.get('/admin/sidebar')
|
||||||
@admin_level_required(3)
|
# @admin_level_required(3)
|
||||||
def get_sidebar(v):
|
# def get_sidebar(v):
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
# with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||||
except:
|
# except:
|
||||||
sidebar = None
|
# sidebar = None
|
||||||
|
|
||||||
return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
|
# return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
|
||||||
|
|
||||||
|
|
||||||
@app.post('/admin/sidebar')
|
# @app.post('/admin/sidebar')
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
# @limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(3)
|
# @admin_level_required(3)
|
||||||
def post_sidebar(v):
|
# def post_sidebar(v):
|
||||||
|
|
||||||
text = request.values.get('sidebar', '').strip()
|
# text = request.values.get('sidebar', '').strip()
|
||||||
|
|
||||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
|
# with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
|
||||||
|
|
||||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
# with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||||
|
|
||||||
ma = ModAction(
|
# ma = ModAction(
|
||||||
kind="change_sidebar",
|
# kind="change_sidebar",
|
||||||
user_id=v.id,
|
# user_id=v.id,
|
||||||
)
|
# )
|
||||||
g.db.add(ma)
|
# g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
# g.db.commit()
|
||||||
|
|
||||||
return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!')
|
# return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!')
|
||||||
|
|
||||||
@app.get("/admin/shadowbanned")
|
@app.get("/admin/shadowbanned")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -269,7 +269,9 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
|
||||||
|
|
||||||
if sub: posts = posts.filter_by(sub=sub.name)
|
if sub: posts = posts.filter_by(sub=sub.name)
|
||||||
elif SITE_NAME == '2Much4You': posts = posts.filter(Submission.sub.in_(toomuch_subs))
|
elif SITE_NAME == '2Much4You': posts = posts.filter(Submission.sub.in_(toomuch_subs))
|
||||||
elif SITE_NAME == 'Ruqqus': posts = posts.filter(Submission.sub != None)
|
elif SITE_NAME == 'Ruqqus':
|
||||||
|
posts = posts.filter(Submission.sub != None)
|
||||||
|
if v and v.all_blocks: posts = posts.filter(Submission.sub.notin_(v.all_blocks))
|
||||||
else: posts = posts.filter_by(sub=None)
|
else: posts = posts.filter_by(sub=None)
|
||||||
|
|
||||||
if gt: posts = posts.filter(Submission.created_utc > gt)
|
if gt: posts = posts.filter(Submission.created_utc > gt)
|
||||||
|
|
|
@ -6,6 +6,43 @@ from .front import frontlist
|
||||||
|
|
||||||
valid_sub_regex = re.compile("^[a-zA-Z0-9_\-]{3,20}$")
|
valid_sub_regex = re.compile("^[a-zA-Z0-9_\-]{3,20}$")
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/s/<sub>/block")
|
||||||
|
@auth_required
|
||||||
|
def block_sub(v, sub):
|
||||||
|
sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none()
|
||||||
|
if not sub: abort(404)
|
||||||
|
sub = sub.name
|
||||||
|
|
||||||
|
# if v.mods(sub): return {"error": "You can't block subs you mod!"}
|
||||||
|
|
||||||
|
existing = g.db.query(SubBlock).filter_by(user_id=v.id, sub=sub).one_or_none()
|
||||||
|
|
||||||
|
if not existing:
|
||||||
|
block = SubBlock(user_id=v.id, sub=sub)
|
||||||
|
g.db.add(block)
|
||||||
|
g.db.commit()
|
||||||
|
cache.delete_memoized(frontlist)
|
||||||
|
|
||||||
|
return {"message": "Sub blocked successfully!"}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/s/<sub>/unblock")
|
||||||
|
@auth_required
|
||||||
|
def unblock_sub(v, sub):
|
||||||
|
sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none()
|
||||||
|
if not sub: abort(404)
|
||||||
|
sub = sub.name
|
||||||
|
|
||||||
|
block = g.db.query(SubBlock).filter_by(user_id=v.id, sub=sub).one_or_none()
|
||||||
|
|
||||||
|
if block:
|
||||||
|
g.db.delete(block)
|
||||||
|
g.db.commit()
|
||||||
|
cache.delete_memoized(frontlist)
|
||||||
|
|
||||||
|
return {"message": "Sub unblocked successfully!"}
|
||||||
|
|
||||||
@app.get("/s/<sub>/mods")
|
@app.get("/s/<sub>/mods")
|
||||||
@is_not_permabanned
|
@is_not_permabanned
|
||||||
def mods(v, sub):
|
def mods(v, sub):
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
{% if sub %}
|
{% if sub %}
|
||||||
{% set image=sub.sidebar_url %}
|
{% set image=sub.sidebar_url %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set image='/static/assets/images/2Much4You/sidebar.webp?a=1040' %}
|
{% set image='/static/assets/images/{{SITE_NAME}}/sidebar.webp?a=1040' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<img alt="sidebar image" role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
|
<img alt="sidebar image" role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
|
||||||
|
|
||||||
|
|
||||||
{% if sub %}
|
{% if sub %}
|
||||||
{% if sub.sidebar_html %}
|
{% if sub.sidebar_html %}
|
||||||
<div class="mt-4">{{sub.sidebar_html|safe}}</div>
|
<div class="mt-4">{{sub.sidebar_html|safe}}</div>
|
||||||
|
@ -16,6 +15,10 @@
|
||||||
{% if v and v.mods(sub.name) %}
|
{% if v and v.mods(sub.name) %}
|
||||||
<a class="btn btn-primary btn-block" href="/s/{{sub.name}}/settings">SUB SETTINGS</a>
|
<a class="btn btn-primary btn-block" href="/s/{{sub.name}}/settings">SUB SETTINGS</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if v %}
|
||||||
|
<a class="btn btn-primary btn-block {% if v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/s/{{sub.name}}/block','block-sub','unblock-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">BLOCK SUB</a>
|
||||||
|
<a class="btn btn-primary btn-block {% if not v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/s/{{sub.name}}/unblock','block-sub','unblock-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">UNBLOCK SUB</a>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="mt-4">Rules: No doxxing, No CP or other clearly illegal shit. Thanks!</p>
|
<p class="mt-4">Rules: No doxxing, No CP or other clearly illegal shit. Thanks!</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% if sub %}
|
{% if sub %}
|
||||||
{% set image=sub.sidebar_url %}
|
{% set image=sub.sidebar_url %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set image='/static/assets/images/Ruqqus/sidebar.webp?a=1040' %}
|
{% set image='/static/assets/images/{{SITE_NAME}}/sidebar.webp?a=1040' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<img alt="sidebar image" role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
|
<img alt="sidebar image" role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
|
||||||
|
@ -15,6 +15,10 @@
|
||||||
{% if v and v.mods(sub.name) %}
|
{% if v and v.mods(sub.name) %}
|
||||||
<a class="btn btn-primary btn-block" href="/s/{{sub.name}}/settings">SUB SETTINGS</a>
|
<a class="btn btn-primary btn-block" href="/s/{{sub.name}}/settings">SUB SETTINGS</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if v %}
|
||||||
|
<a class="btn btn-primary btn-block {% if v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/s/{{sub.name}}/block','block-sub','unblock-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">BLOCK SUB</a>
|
||||||
|
<a class="btn btn-primary btn-block {% if not v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/s/{{sub.name}}/unblock','block-sub','unblock-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">UNBLOCK SUB</a>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="mt-4">Rules: No doxxing, No CP or other clearly illegal shit. Also no nazis, go to communities.win. Thanks!</p>
|
<p class="mt-4">Rules: No doxxing, No CP or other clearly illegal shit. Also no nazis, go to communities.win. Thanks!</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue