Skip to content

Commit

Permalink
Show seminars for members too
Browse files Browse the repository at this point in the history
  • Loading branch information
Mstrodl committed Oct 17, 2023
1 parent f0e8f93 commit 3a755e6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions conditional/blueprints/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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":
Expand Down
15 changes: 15 additions & 0 deletions conditional/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ <h3 class="panel-title">Membership Evaluations
{% endif %}
</h3>
</div>
<div class="panel-body" style="padding:0px 0px 8px 8px">
<b>Technical Seminars</b> {% if ts_total == 0 %}
<div class="panel-body">
<div class="alert alert-warning" role="alert">You have not attended any technical seminars.</div>
</div>
{% else %}
<div class="panel-body table-fill">
<ul>
{% for ts in ts_list %}
<li>{{ts}}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
<div class="panel-body table-fill">
<table class="table table-striped table-responsive no-bottom-margin">
<tbody>
Expand Down

0 comments on commit 3a755e6

Please sign in to comment.