diff --git a/appdata/.gitignore b/appdata/.gitignore index 6176789..7288846 100644 --- a/appdata/.gitignore +++ b/appdata/.gitignore @@ -1,2 +1,3 @@ -cssignin.yaml -db/ \ No newline at end of file +cssignin.yaml +db/ +kanboard/ \ No newline at end of file diff --git a/signinapp/event.py b/signinapp/event.py index 3bfd0d9..32b7911 100644 --- a/signinapp/event.py +++ b/signinapp/event.py @@ -200,9 +200,9 @@ def export_stamps( @login_required def export(): if current_user.role.admin: - name = request.values.get("name", None) + name = request.values.get("name", current_user.email) else: - name = current_user.name + name = current_user.email user = User.from_email(name) start = request.args.get("start", None) end = request.args.get("end", None) diff --git a/signinapp/team.py b/signinapp/team.py index be8e20e..f056b27 100644 --- a/signinapp/team.py +++ b/signinapp/team.py @@ -6,8 +6,8 @@ from sqlalchemy import or_ from sqlalchemy.future import select -from .model import Role, ShirtSizes, Subteam, User, db -from .util import mentor_required +from .model import Role, ShirtSizes, Student, Subteam, User, db +from .util import get_current_graduation_years, mentor_required team = Blueprint("team", __name__) @@ -43,25 +43,42 @@ def subteam(): @team.route("/users/students") @mentor_required def list_students(): - users = db.session.scalars( - select(User) - .where(or_(User.role.has(name="student"), User.role.has(name="lead"))) - .order_by(User.name) - ) + include_all = request.args.get("include_all", False) == "true" + select_stmt = select(User).where(or_(User.role.has(name="student"), User.role.has(name="lead"))) + if not include_all: + select_stmt = select_stmt.join(Student).where( + Student.graduation_year.in_(get_current_graduation_years()) + ) + users = db.session.scalars(select_stmt.order_by(User.name)).all() return render_template("user_list.html.jinja2", role="Student", users=users) @team.route("/users/guardians") @mentor_required def list_guardians(): - users = db.session.scalars(select(User).where(User.role.has(guardian=True)).order_by(User.name)) + include_all = request.args.get("include_all", False) == "true" + users = db.session.scalars( + select(User).where(User.role.has(guardian=True)).order_by(User.name) + ).all() + if not include_all: + users = [ + guardian + for guardian in users + if any( + student + for student in guardian.guardian_user_data.students + if student.graduation_year in get_current_graduation_years() + ) + ] return render_template("user_list.html.jinja2", role="Guardian", users=users) @team.route("/users/mentors") @mentor_required def list_mentors(): - users = db.session.scalars(select(User).where(User.role.has(mentor=True)).order_by(User.name)) + users = db.session.scalars( + select(User).where(User.role.has(mentor=True)).order_by(User.name) + ).all() return render_template("user_list.html.jinja2", role="Mentor", users=users) diff --git a/signinapp/templates/user_list.html.jinja2 b/signinapp/templates/user_list.html.jinja2 index c69d732..1bc0487 100644 --- a/signinapp/templates/user_list.html.jinja2 +++ b/signinapp/templates/user_list.html.jinja2 @@ -7,6 +7,20 @@