adding admin
parent
e3a3e7aa19
commit
d2092ab496
@ -1,25 +1,18 @@
|
|||||||
from flask import session, redirect, url_for, flash
|
from flask import redirect, flash, request, url_for
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from nerochan.models import User, CreatorProfile, BackerProfile, Subscription
|
from nerochan.models import User
|
||||||
|
|
||||||
|
def admin_required(f):
|
||||||
# def login_required(f):
|
|
||||||
# @wraps(f)
|
|
||||||
# def decorated_function(*args, **kwargs):
|
|
||||||
# if "auth" not in session or not session["auth"]:
|
|
||||||
# return redirect(url_for("auth.login"))
|
|
||||||
# return f(*args, **kwargs)
|
|
||||||
# return decorated_function
|
|
||||||
|
|
||||||
def subscription_required(f):
|
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated_function(*args, **kwargs):
|
def decorated_function(*args, **kwargs):
|
||||||
print(current_user)
|
if current_user.is_admin:
|
||||||
# m = Moderator.filter(username=session["auth"]["preferred_username"])
|
return f(*args, **kwargs)
|
||||||
# if m:
|
else:
|
||||||
# return f(*args, **kwargs)
|
flash('Must be an admin to access that page.', 'warning')
|
||||||
# else:
|
if request.referrer:
|
||||||
# flash("You are not a moderator")
|
u = request.referrer
|
||||||
# return redirect(url_for("index"))
|
else:
|
||||||
|
u = url_for('main.index')
|
||||||
|
return redirect(u)
|
||||||
return decorated_function
|
return decorated_function
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
{% extends 'includes/base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<h1>admins</h1>
|
||||||
|
<p>Add a homie</p>
|
||||||
|
<form method="post" action="">
|
||||||
|
{{ user_form.csrf_token }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="two columns">
|
||||||
|
{{ user_form.handle }}
|
||||||
|
</div>
|
||||||
|
<div class="two columns">
|
||||||
|
<input class="button-primary" type="submit" value="Submit">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
{%- for field, errors in user_form.errors.items() %}
|
||||||
|
<li>{{ ', '.join(errors) }}</li>
|
||||||
|
{%- endfor %}
|
||||||
|
</ul>
|
||||||
|
</form>
|
||||||
|
<ul>
|
||||||
|
{% for admin in admins %}
|
||||||
|
<li><h6>{{ admin.handle }} - <a href="?remove={{ admin.handle }}">remove</a></h6></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue