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.delete.data:
|
||||
DeleteUsers(adminuserform)
|
||||
if adminuserform.tutors.data:
|
||||
ToggleUsersAsTutors(adminuserform, True)
|
||||
if adminuserform.nottutors.data:
|
||||
ToggleUsersAsTutors(adminuserform, False)
|
||||
|
||||
template = render_template(
|
||||
"admin.html",
|
||||
@ -50,23 +46,6 @@ def DeleteUsers(adminuserform):
|
||||
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):
|
||||
try:
|
||||
|
@ -20,8 +20,4 @@ class AdminUserForm(FlaskForm):
|
||||
|
||||
return UserListForm()
|
||||
|
||||
tutors = SubmitField("Are tutors")
|
||||
|
||||
nottutors = SubmitField("Are not tutors")
|
||||
|
||||
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)
|
||||
resethash = db.Column(db.String(300), nullable=True, unique=True)
|
||||
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)
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -149,12 +149,6 @@ input[type="submit"]:disabled:focus {
|
||||
background-color: #62b264;
|
||||
}
|
||||
|
||||
#tutors {
|
||||
color: black;
|
||||
background-color: #62b264;
|
||||
}
|
||||
|
||||
|
||||
/* unvisited link */
|
||||
a:link {
|
||||
color: #fff600;
|
||||
|
@ -77,10 +77,7 @@ class UserHelper:
|
||||
def distribusi_limit_reached():
|
||||
user = User.query.filter_by(email=current_user.email).first()
|
||||
distribusiamount = len(DistribusisInfo.getuserdistribusis(user.email))
|
||||
if user.tutor and distribusiamount > 14:
|
||||
print("tutor already has 15 distribusis")
|
||||
return True
|
||||
if not user.tutor and distribusiamount > 4:
|
||||
print("user already has 5 distribusis")
|
||||
if distribusiamount > 19:
|
||||
print("user already has 20 distribusis")
|
||||
return True
|
||||
return False
|
||||
|
@ -149,11 +149,6 @@ input[type="submit"]:disabled:focus {
|
||||
background-color: #62b264;
|
||||
}
|
||||
|
||||
#tutors {
|
||||
color: black;
|
||||
background-color: #62b264;
|
||||
}
|
||||
|
||||
|
||||
/* unvisited link */
|
||||
a:link {
|
||||
|
@ -14,9 +14,6 @@
|
||||
</div>
|
||||
<div class="maincontent">
|
||||
<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">
|
||||
<h2>List of distribusis</h2>
|
||||
<form method="POST" enctype="multipart/form-data" action="{{ url_for('admin') }}">
|
||||
@ -53,12 +50,6 @@
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<fieldset class="button required">
|
||||
{{ adminuserform.tutors }}
|
||||
</fieldset>
|
||||
<fieldset class="button required">
|
||||
{{ adminuserform.nottutors }}
|
||||
</fieldset>
|
||||
<fieldset class="button required">
|
||||
{{ adminuserform.delete }}
|
||||
</fieldset>
|
||||
|
Loading…
Reference in New Issue
Block a user