mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Create Assistant if role was added
This commit is contained in:
parent
4a83ffdabc
commit
c98d85c810
2 changed files with 9 additions and 9 deletions
|
@ -138,10 +138,6 @@ class UserView(SecureAdminModelView):
|
||||||
active_semester=form.active_semester.data,
|
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.on_model_change(form, model, True)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -150,7 +146,7 @@ class UserView(SecureAdminModelView):
|
||||||
self.session.rollback()
|
self.session.rollback()
|
||||||
else:
|
else:
|
||||||
flash(
|
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",
|
category="success",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -177,6 +173,12 @@ class UserView(SecureAdminModelView):
|
||||||
model, password, notify=False
|
model, password, notify=False
|
||||||
) # Password is automatically hashed with this method
|
) # 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):
|
class RoleView(SecureAdminModelView):
|
||||||
can_create = False
|
can_create = False
|
||||||
|
|
|
@ -117,10 +117,8 @@ class PartStudent(db.Model):
|
||||||
else:
|
else:
|
||||||
if current_user.has_role("admin"):
|
if current_user.has_role("admin"):
|
||||||
if oldFinalPartMark != self.final_part_mark:
|
if oldFinalPartMark != self.final_part_mark:
|
||||||
if oldFinalPartMark > self.final_part_mark:
|
category = "danger" if oldFinalPartMark > self.final_part_mark else "info"
|
||||||
category = "danger"
|
|
||||||
else:
|
|
||||||
category = "warning"
|
|
||||||
flash(
|
flash(
|
||||||
f"Final part mark changed for {self} from {oldFinalPartMark} to {self.final_part_mark}.",
|
f"Final part mark changed for {self} from {oldFinalPartMark} to {self.final_part_mark}.",
|
||||||
category,
|
category,
|
||||||
|
|
Loading…
Reference in a new issue