No Gods, No Managers, No Tutors
This commit is contained in:
parent
c854c2687e
commit
7f6a373e8d
@ -26,10 +26,6 @@ def AdminPage():
|
|||||||
if adminuserform.validate_on_submit():
|
if adminuserform.validate_on_submit():
|
||||||
if adminuserform.delete.data:
|
if adminuserform.delete.data:
|
||||||
DeleteUsers(adminuserform)
|
DeleteUsers(adminuserform)
|
||||||
if adminuserform.tutors.data:
|
|
||||||
ToggleUsersAsTutors(adminuserform, True)
|
|
||||||
if adminuserform.nottutors.data:
|
|
||||||
ToggleUsersAsTutors(adminuserform, False)
|
|
||||||
|
|
||||||
template = render_template(
|
template = render_template(
|
||||||
"admin.html",
|
"admin.html",
|
||||||
@ -50,23 +46,6 @@ def DeleteUsers(adminuserform):
|
|||||||
userform.errors.append(f"User {useremail} deleted!")
|
userform.errors.append(f"User {useremail} deleted!")
|
||||||
|
|
||||||
|
|
||||||
def ToggleUsersAsTutors(adminuserform, is_tutor):
|
|
||||||
for userform in adminuserform:
|
|
||||||
if "user" in userform.id:
|
|
||||||
if userform.data:
|
|
||||||
useremail = userform.label.text
|
|
||||||
user = User.query.filter_by(email=useremail).first()
|
|
||||||
ToggleUserTutorinDb(user, is_tutor)
|
|
||||||
userform.errors.append(f"Is User {useremail} tutor {is_tutor}")
|
|
||||||
|
|
||||||
|
|
||||||
def ToggleUserTutorinDb(user, is_tutor):
|
|
||||||
try:
|
|
||||||
user.tutor = is_tutor
|
|
||||||
db.session.commit()
|
|
||||||
except (InvalidRequestError, DataError, InterfaceError, DatabaseError):
|
|
||||||
db.session.rollback()
|
|
||||||
|
|
||||||
|
|
||||||
def DeleteUserFromDb(user):
|
def DeleteUserFromDb(user):
|
||||||
try:
|
try:
|
||||||
|
@ -20,8 +20,4 @@ class AdminUserForm(FlaskForm):
|
|||||||
|
|
||||||
return UserListForm()
|
return UserListForm()
|
||||||
|
|
||||||
tutors = SubmitField("Are tutors")
|
|
||||||
|
|
||||||
nottutors = SubmitField("Are not tutors")
|
|
||||||
|
|
||||||
delete = SubmitField("Delete")
|
delete = SubmitField("Delete")
|
||||||
|
0
verse/models/distribusi_file_model.py
Normal file
0
verse/models/distribusi_file_model.py
Normal file
@ -15,8 +15,6 @@ class User(UserMixin, db.Model):
|
|||||||
currentdistribusi = db.Column(db.String(300), nullable=True, unique=False)
|
currentdistribusi = db.Column(db.String(300), nullable=True, unique=False)
|
||||||
resethash = db.Column(db.String(300), nullable=True, unique=True)
|
resethash = db.Column(db.String(300), nullable=True, unique=True)
|
||||||
resettime = db.Column(db.DateTime)
|
resettime = db.Column(db.DateTime)
|
||||||
# active = db.Column(db.Boolean, default=False)
|
|
||||||
tutor = db.Column(db.Boolean, default=False)
|
|
||||||
admin = db.Column(db.Boolean, default=False)
|
admin = db.Column(db.Boolean, default=False)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -149,12 +149,6 @@ input[type="submit"]:disabled:focus {
|
|||||||
background-color: #62b264;
|
background-color: #62b264;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tutors {
|
|
||||||
color: black;
|
|
||||||
background-color: #62b264;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* unvisited link */
|
/* unvisited link */
|
||||||
a:link {
|
a:link {
|
||||||
color: #fff600;
|
color: #fff600;
|
||||||
|
@ -77,10 +77,7 @@ class UserHelper:
|
|||||||
def distribusi_limit_reached():
|
def distribusi_limit_reached():
|
||||||
user = User.query.filter_by(email=current_user.email).first()
|
user = User.query.filter_by(email=current_user.email).first()
|
||||||
distribusiamount = len(DistribusisInfo.getuserdistribusis(user.email))
|
distribusiamount = len(DistribusisInfo.getuserdistribusis(user.email))
|
||||||
if user.tutor and distribusiamount > 14:
|
if distribusiamount > 19:
|
||||||
print("tutor already has 15 distribusis")
|
print("user already has 20 distribusis")
|
||||||
return True
|
|
||||||
if not user.tutor and distribusiamount > 4:
|
|
||||||
print("user already has 5 distribusis")
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -149,11 +149,6 @@ input[type="submit"]:disabled:focus {
|
|||||||
background-color: #62b264;
|
background-color: #62b264;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tutors {
|
|
||||||
color: black;
|
|
||||||
background-color: #62b264;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* unvisited link */
|
/* unvisited link */
|
||||||
a:link {
|
a:link {
|
||||||
|
@ -14,9 +14,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="maincontent">
|
<div class="maincontent">
|
||||||
<h2>Admin Page</h2>
|
<h2>Admin Page</h2>
|
||||||
<p>Here you can bulk delete distribusis and users or make users into tutors
|
|
||||||
<strong> These actions cannot be undone! </strong>
|
|
||||||
</p>
|
|
||||||
<div id="distribusiverse" class="maincontent">
|
<div id="distribusiverse" class="maincontent">
|
||||||
<h2>List of distribusis</h2>
|
<h2>List of distribusis</h2>
|
||||||
<form method="POST" enctype="multipart/form-data" action="{{ url_for('admin') }}">
|
<form method="POST" enctype="multipart/form-data" action="{{ url_for('admin') }}">
|
||||||
@ -53,12 +50,6 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<fieldset class="button required">
|
|
||||||
{{ adminuserform.tutors }}
|
|
||||||
</fieldset>
|
|
||||||
<fieldset class="button required">
|
|
||||||
{{ adminuserform.nottutors }}
|
|
||||||
</fieldset>
|
|
||||||
<fieldset class="button required">
|
<fieldset class="button required">
|
||||||
{{ adminuserform.delete }}
|
{{ adminuserform.delete }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
Loading…
Reference in New Issue
Block a user