remotes/1693045480750635534/spooky-22
Aevann1 2021-08-03 14:05:37 +02:00
parent 652da9fd66
commit 84507a4f55
5 changed files with 51 additions and 53 deletions

View File

@ -19,11 +19,7 @@ class BannedDomain(Base):
reason = Column(Integer, default=0)
@property
def reason_text(self): return reasons.get(self.reason)
@property
def permalink(self): return f"/admin/domain/{self.domain}"
def reason_text(self): return reasons.get(self.reason)
class BadLink(Base):
@ -35,5 +31,4 @@ class BadLink(Base):
autoban = Column(Boolean, default=False)
@property
def reason_text(self):
return reasons.get(self.reason)
def reason_text(self): return reasons.get(self.reason)

View File

@ -459,20 +459,16 @@ def admin_appdata(v):
v=v)
@app.get("/admin/domain/<domain_name>")
@app.get("/admin/banned_domains/")
@admin_level_required(4)
def admin_domain_domain(domain_name, v):
def admin_domain_domain(v):
d_query=domain_name.replace("_","\_")
domain=g.db.query(BannedDomain).filter_by(domain=d_query).first()
if not domain: domain=BannedDomain(domain=domain_name)
domains = g.db.query(BannedDomain).all()
return render_template(
"admin/manage_domain.html",
"admin/banned_domains.html",
v=v,
domain_name=domain_name,
domain=domain,
domains=domains,
reasons=REASONS
)
@ -967,6 +963,7 @@ def admin_dump_cache(v):
def admin_ban_domain(v):
domain=request.form.get("domain",'').strip()
if not domain: abort(400)
reason=int(request.form.get("reason",0))

View File

@ -12,7 +12,7 @@
{% filter markdown %}
* [Grant User Award](/admin/user_award)
* [Advanced Stats](/user_stat_data)
* [Ban Domain](/admin/domain/enter%20domain%20here)
* [Banned Domains](/admin/banned_domains)
* [Shadowbanned Users](/admin/shadowbanned)
* [Users with Agendaposter Theme](/admin/agendaposters)
* [Flagged Posts](/admin/flagged/posts)

View File

@ -0,0 +1,42 @@
{% extends "default.html" %}
{% block title %}
<title>Banned Domains</title>
{% endblock %}
{% block content %}
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th style="font-weight:bold;">Domain</th>
<th style="font-weight:bold;">Ban reason</th>
</tr>
</thead>
{% for domain in domains %}
<tr>
<td style="font-weight:bold;">{{domain}}</td>
<td>{{domain.reason_text}}</td>
</tr>
{% endfor %}
</table>
<form action="/admin/ban_domain" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="domain" value="{{domain_name}}">
<input name="domain" placeholder="domain" required>
<label for="reason_select">Ban reason</label>
<select id="reason_select" class="form-control" name="reason" onchange="$('#ban-submit').prop('disabled', false)">
<option value="0">---Select Ban Reason---</option>
{% for i in reasons %}
<option value="{{i}}"{% if i == domain.reason %} selected{% endif %}>{{reasons[i]}}</option>
{% endfor %}
</select>
<input id="ban-submit" type="submit" class="btn btn-primary" value="Ban {{domain_name}}" disabled>
</form>
{% endblock %}

View File

@ -1,36 +0,0 @@
{% extends "default.html" %}
{% block title %}
<title>{{"SITE_NAME" | app_config}}</title>
<meta name="description" content="{{"SITE_NAME" | app_config}} Help">
{% endblock %}
{% block content %}
<pre>
</pre>
<input id="domainget" type="text" class="form-control" placeholder="Enter domain name" value="{{domain_name}}">
<a class="btn btn-primary" href="javascript:void(0)" onclick="window.location.href='/admin/domain/'+document.getElementById('domainget').value">Check if domain is banned</a>
<h1>{{domain_name}}</h2>
<h3 class="h5 pt-2">Current ban reason</h3>
<p>{{domain.reason_text}}</p>
<h2>Actions</h2>
<form action="/admin/ban_domain" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="domain" value="{{domain_name}}">
<label for="reason_select">Ban reason</label>
<select id="reason_select" class="form-control" name="reason" onchange="$('#ban-submit').prop('disabled', false)">
<option value="0">---Select Ban Reason---</option>
{% for i in reasons %}
<option value="{{i}}"{% if i==domain.reason %} selected{% endif %}>{{reasons[i]}}</option>
{% endfor %}
</select>
<input id="ban-submit" type="submit" class="btn btn-primary" value="Ban {{domain_name}}" disabled>
</form>
{% endblock %}