Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show seminars for members too #386

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 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,7 +22,12 @@

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()

# pylint: disable=too-many-statements
@dashboard_bp.route('/dashboard/')
@auth.oidc_auth
@get_user
Expand Down Expand Up @@ -85,6 +92,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
Loading