diff --git a/conditional/blueprints/dashboard.py b/conditional/blueprints/dashboard.py index fbffde8..47cdb79 100644 --- a/conditional/blueprints/dashboard.py +++ b/conditional/blueprints/dashboard.py @@ -6,6 +6,8 @@ from conditional.models.models import HouseMeeting from conditional.models.models import MajorProject from conditional.models.models import MemberHouseMeetingAttendance +from conditional.models.models import MemberSeminarAttendance +from conditional.models.models import TechnicalSeminar from conditional.models.models import SpringEval from conditional.util.auth import get_user from conditional.util.flask import render_template @@ -20,6 +22,10 @@ dashboard_bp = Blueprint('dashboard_bp', __name__) +def is_seminar_attendance_valid(attendance): + seminar = TechnicalSeminar.query.filter( + TechnicalSeminar.id == attendance.seminar_id).first() + return seminar and seminar.approved and seminar.timestamp > start_of_year() @dashboard_bp.route('/dashboard/') @auth.oidc_auth @@ -85,6 +91,18 @@ def display_dashboard(user_dict=None): data['major_projects_count'] = len(data['major_projects']) + # technical seminar total + t_seminars = [s.seminar_id for s in + MemberSeminarAttendance.query.filter( + MemberSeminarAttendance.uid == user_dict['account'].uid, + ) if is_seminar_attendance_valid(s)] + data['ts_total'] = len(t_seminars) + attendance = [m.name for m in TechnicalSeminar.query.filter( + TechnicalSeminar.id.in_(t_seminars) + )] + + data['ts_list'] = attendance + spring['mp_status'] = "Failed" for mp in data['major_projects']: if mp['status'] == "Pending": diff --git a/conditional/templates/dashboard.html b/conditional/templates/dashboard.html index 3069b9e..3bfd819 100644 --- a/conditional/templates/dashboard.html +++ b/conditional/templates/dashboard.html @@ -109,6 +109,21 @@

Membership Evaluations {% endif %}

+
+ Technical Seminars {% if ts_total == 0 %} +
+ +
+ {% else %} +
+ +
+ {% endif %} +