Browse Source

No Gods, No Managers, No Tutors

pull/11/head
crunk 7 months ago
parent
commit
7f6a373e8d
  1. 21
      verse/adminpage.py
  2. 4
      verse/forms/adminuserform.py
  3. 0
      verse/models/distribusi_file_model.py
  4. 2
      verse/models/usermodel.py
  5. 6
      verse/static/css/style.css
  6. 7
      verse/statuspengguna/helper.py
  7. 5
      verse/statuspengguna/static/css/style.css
  8. 9
      verse/templates/base/admin.html

21
verse/adminpage.py

@ -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:

4
verse/forms/adminuserform.py

@ -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

2
verse/models/usermodel.py

@ -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):

6
verse/static/css/style.css

@ -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;

7
verse/statuspengguna/helper.py

@ -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

5
verse/statuspengguna/static/css/style.css

@ -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 {

9
verse/templates/base/admin.html

@ -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…
Cancel
Save