fdfd
This commit is contained in:
parent
68c1740cf9
commit
47505a49b9
3 changed files with 17 additions and 45 deletions
|
@ -1,34 +1,21 @@
|
|||
from sqlalchemy import *
|
||||
from drama.__main__ import Base
|
||||
|
||||
reasons = {
|
||||
1: "URL shorteners are not allowed.",
|
||||
3: "Piracy is not allowed.",
|
||||
4: "Sites hosting digitally malicious content are not allowed.",
|
||||
5: "Spam",
|
||||
6: "Doxxing is not allowed.",
|
||||
7: "Sexualizing minors is strictly prohibited."
|
||||
}
|
||||
|
||||
|
||||
class BannedDomain(Base):
|
||||
|
||||
__tablename__ = "banneddomains"
|
||||
id = Column(Integer, primary_key=True)
|
||||
domain = Column(String)
|
||||
reason = Column(Integer, default=0)
|
||||
|
||||
@property
|
||||
def reason_text(self): return reasons.get(self.reason)
|
||||
reason = Column(String)
|
||||
|
||||
|
||||
class BadLink(Base):
|
||||
|
||||
__tablename__ = "badlinks"
|
||||
id = Column(Integer, primary_key=True)
|
||||
reason = Column(Integer)
|
||||
link = Column(String(512))
|
||||
reason = Column(String)
|
||||
autoban = Column(Boolean, default=False)
|
||||
|
||||
@property
|
||||
def reason_text(self): return reasons.get(self.reason)
|
||||
ALTER TABLE banneddomains ALTER COLUMN TYPE text;
|
||||
ALTER TABLE badlinks ALTER COLUMN TYPE text;
|
|
@ -947,34 +947,26 @@ def admin_dump_cache(v):
|
|||
@admin_level_required(4)
|
||||
def admin_banned_domains(v):
|
||||
|
||||
domains = g.db.query(BannedDomain).all()
|
||||
|
||||
return render_template(
|
||||
"admin/banned_domains.html",
|
||||
v=v,
|
||||
domains=domains,
|
||||
reasons=REASONS
|
||||
)
|
||||
|
||||
banned_domains = g.db.query(BannedDomain).all()
|
||||
return render_template("admin/banned_domains.html", v=v, banned_domains=banned_domains)
|
||||
|
||||
@app.post("/admin/ban_domain")
|
||||
@admin_level_required(4)
|
||||
@validate_formkey
|
||||
def admin_ban_domain(v):
|
||||
|
||||
domain=request.form.get("domain",'').strip()
|
||||
domain=request.form.get("domain").strip()
|
||||
if not domain: abort(400)
|
||||
|
||||
reason=int(request.form.get("reason",0))
|
||||
reason=request.form.get("reason").strip()
|
||||
if not reason: abort(400)
|
||||
|
||||
d_query=domain.replace("_","\_")
|
||||
d=g.db.query(BannedDomain).filter_by(domain=d_query).first()
|
||||
if d: d.reason=reason
|
||||
else: d=BannedDomain(domain=domain, reason=reason)
|
||||
domain = g.db.query(BannedDomain).filter_by(domain=domain.replace("_","\_")).first()
|
||||
if domain: domain.reason=reason
|
||||
else: domain=BannedDomain(domain=domain, reason=reason)
|
||||
|
||||
g.db.add(d)
|
||||
return redirect(d.permalink)
|
||||
g.db.add(domain)
|
||||
return redirect("/admin/banned_domains/")
|
||||
|
||||
|
||||
@app.post("/admin/nuke_user")
|
||||
|
|
|
@ -18,26 +18,19 @@
|
|||
</tr>
|
||||
</thead>
|
||||
|
||||
{% for domain in domains %}
|
||||
{% for domain in banned_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 name="domain" placeholder="Enter domain here.." required>
|
||||
|
||||
<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}}">{{reasons[i]}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input name="domain" placeholder="Enter domain here.." class="form-control" required>
|
||||
<input name="reason" placeholder="Enter ban reason here.." class="form-control" required>
|
||||
<input id="ban-submit" type="submit" class="btn btn-primary" value="Ban domain" disabled>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue