add web
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
{% extends '__layout__.html' %}
|
||||
{% block title %}Banned{% endblock %}
|
||||
{% block head %}
|
||||
<style>
|
||||
.text-secondary {
|
||||
color: rgb(200,200,200) !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div style="display: flex;align-items: center;justify-content: center;min-height: 100vh;">
|
||||
<div class="p-3 border" style="min-width: 700px;">
|
||||
<h1 class="mb-0">{{banText}}</h1>
|
||||
<div class="d-flex">
|
||||
<p class="text-secondary m-0" style="font-size: 13px;">Banned On: <span class="text-white">{{userban.created_at}} UTC</span></p>
|
||||
<p class="text-secondary m-0 ms-auto" style="font-size: 13px;">Expires On: <span class="text-white">{% if userban.expires_at != None%}{{userban.expires_at}} UTC{%else%}Never{%endif%}</span></p>
|
||||
</div>
|
||||
<div class="linebreak"></div>
|
||||
<p class="text-secondary m-0" style="font-size: 16px;">Reason: <span class="text-white">{{userban.reason}}</span></p>
|
||||
<div class="linebreak"></div>
|
||||
<div class="w-100 d-flex align-items-center">
|
||||
{% if not hasBanExpired: %}
|
||||
<p class="text-secondary m-0" style="font-size: 13px;">If you wish to appeal this ban you can open a ticket on our <a class="text-decoration-none" href="https://discord.gg/spUbRdSa5J">Discord Server</a></p>
|
||||
<form action="/logout" method="post"><input type="hidden" name="csrf_token" value="{{csrf_token()}}"><button class="btn border-primary btn-sm text-white ms-auto" type="submit">Logout</button></form>
|
||||
{%else%}
|
||||
<p class="text-secondary m-0" style="font-size: 13px;">By clicking Re-activate you agree to our <a href="/terms" class="text-decoration-none">Terms Of Service</a></p>
|
||||
<form method="post" class="ms-auto">
|
||||
<input type="hidden" name="csrf_token" value="{{csrf_token()}}">
|
||||
<button class="btn border-success btn-sm text-white" type="submit">Re-activate my Account</button>
|
||||
</form>
|
||||
<form action="/logout" method="post"><input type="hidden" name="csrf_token" value="{{csrf_token()}}"><button class="btn border-primary btn-sm text-white ms-auto" type="submit">Logout</button></form>
|
||||
{%endif%}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,90 @@
|
||||
from flask import Blueprint, render_template, request, redirect, url_for, flash, session, abort
|
||||
from app.models.user_ban import UserBan
|
||||
from app.extensions import db, csrf, limiter, redis_controller
|
||||
from app.models.user import User
|
||||
from app.enums.BanType import BanType
|
||||
from app.util import auth
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
NotApprovedRoute = Blueprint('notapproved', __name__, template_folder="pages")
|
||||
|
||||
BanTypeToText = {
|
||||
BanType.Warning: "Warning",
|
||||
BanType.Day1Ban: "Banned for 1 day",
|
||||
BanType.Day3Ban: "Banned for 3 days",
|
||||
BanType.Day7Ban: "Banned for 7 days",
|
||||
BanType.Day14Ban: "Banned for 14 days",
|
||||
BanType.Day30Ban: "Banned for 30 days",
|
||||
BanType.Deleted: "Account Deleted",
|
||||
}
|
||||
|
||||
@NotApprovedRoute.route("/not-approved", methods=["GET"])
|
||||
def not_approved():
|
||||
CurrentUser : User = auth.GetCurrentUser()
|
||||
if CurrentUser is not None:
|
||||
return redirect("/")
|
||||
|
||||
if "not-approved-viewer" not in session:
|
||||
abort(404)
|
||||
|
||||
UserObj : User = User.query.filter_by(id=session["not-approved-viewer"]).first()
|
||||
if UserObj is None:
|
||||
del session["not-approved-viewer"]
|
||||
abort(404)
|
||||
|
||||
if UserObj.accountstatus == 4:
|
||||
del session["not-approved-viewer"]
|
||||
return redirect("/")
|
||||
|
||||
if UserObj.accountstatus == 1:
|
||||
del session["not-approved-viewer"]
|
||||
return redirect("/")
|
||||
|
||||
LatestUserBanObj : UserBan = UserBan.query.filter_by(userid=UserObj.id, acknowledged = False).order_by(UserBan.id.desc()).first()
|
||||
if LatestUserBanObj is None:
|
||||
del session["not-approved-viewer"]
|
||||
UserObj.accountstatus = 1
|
||||
db.session.commit()
|
||||
return redirect("/")
|
||||
hasBanExpired = False
|
||||
if LatestUserBanObj.expires_at is not None:
|
||||
if LatestUserBanObj.expires_at < datetime.utcnow():
|
||||
hasBanExpired = True
|
||||
|
||||
return render_template("notapproved/banpage.html", user=UserObj,
|
||||
userban=LatestUserBanObj,
|
||||
banText=BanTypeToText[LatestUserBanObj.ban_type],
|
||||
hasBanExpired=hasBanExpired)
|
||||
|
||||
@NotApprovedRoute.route("/not-approved", methods=["POST"])
|
||||
def not_approved_post():
|
||||
CurrentUser : User = auth.GetCurrentUser()
|
||||
if CurrentUser is not None:
|
||||
return redirect("/")
|
||||
if "not-approved-viewer" not in session:
|
||||
abort(404)
|
||||
|
||||
UserObj : User = User.query.filter_by(id=session["not-approved-viewer"]).first()
|
||||
if UserObj is None:
|
||||
del session["not-approved-viewer"]
|
||||
abort(404)
|
||||
|
||||
if UserObj.accountstatus == 1:
|
||||
del session["not-approved-viewer"]
|
||||
return redirect("/")
|
||||
|
||||
LatestUserBanObj : UserBan = UserBan.query.filter_by(userid=UserObj.id, acknowledged = False).order_by(UserBan.id.desc()).first()
|
||||
if LatestUserBanObj is None:
|
||||
del session["not-approved-viewer"]
|
||||
UserObj.accountstatus = 1
|
||||
db.session.commit()
|
||||
return redirect("/")
|
||||
if LatestUserBanObj.ban_type != BanType.Warning:
|
||||
flash("u can log back in now thank u", "error")
|
||||
return redirect("/not-approved")
|
||||
LatestUserBanObj.acknowledged = True
|
||||
UserObj.accountstatus = 1
|
||||
db.session.commit()
|
||||
del session["not-approved-viewer"]
|
||||
flash("Your account has been reactivated", "success")
|
||||
return redirect("/login")
|
||||
Reference in New Issue
Block a user