1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Create Assistant if role was added

This commit is contained in:
Mo 2021-08-21 23:18:55 +02:00
parent 4a83ffdabc
commit c98d85c810
2 changed files with 9 additions and 9 deletions

View file

@ -138,10 +138,6 @@ class UserView(SecureAdminModelView):
active_semester=form.active_semester.data,
)
if "assistant" in roles:
assistant = Assistant(user=model, semester_experiments=form.semester_experiments.data)
self.session.add(assistant)
self.on_model_change(form, model, True)
self.session.commit()
except Exception as ex:
@ -150,7 +146,7 @@ class UserView(SecureAdminModelView):
self.session.rollback()
else:
flash(
f"{email} registered with roles: {', '.join([role.name for role in form.roles.data])}.",
f"{email} registered with roles: {', '.join([role.name for role in model.roles])}.",
category="success",
)
@ -177,6 +173,12 @@ class UserView(SecureAdminModelView):
model, password, notify=False
) # Password is automatically hashed with this method
if model.has_role("assistant") and not model.assistant:
semester_experiments = form.semester_experiments.data if form.semester_experiments else None
assistant = Assistant(user=model, semester_experiments=semester_experiments)
self.session.add(assistant)
class RoleView(SecureAdminModelView):
can_create = False

View file

@ -117,10 +117,8 @@ class PartStudent(db.Model):
else:
if current_user.has_role("admin"):
if oldFinalPartMark != self.final_part_mark:
if oldFinalPartMark > self.final_part_mark:
category = "danger"
else:
category = "warning"
category = "danger" if oldFinalPartMark > self.final_part_mark else "info"
flash(
f"Final part mark changed for {self} from {oldFinalPartMark} to {self.final_part_mark}.",
category,