From 2d30a422110075c2a64596b2e9f8bffd996af206 Mon Sep 17 00:00:00 2001 From: Anderson T Date: Thu, 20 Jun 2024 04:02:05 -0700 Subject: [PATCH] updates to new api response --- main.py | 19 ++++++++++++------- templates/course.html | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index e3ff58a..0711b63 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,11 @@ def attr_color(value): @app.template_filter() def format_attribute(value): - return "yes" if value else "no" + if value == "yes": + return "yes" + if value == "no": + return "no" + return value # route for getting specific course @@ -51,15 +55,16 @@ def course(department, course_number): current_term = requests.get("https://coursesapi.langaracs.ca/index/latest_semester") current_term = current_term.json() + + # for c in data["offerings"]: + # c["year"] = int(c['id'].split("-")[3]) + # c["term"] = int(c['id'].split("-")[4]) - for c in data["offerings"]: - c["year"] = int(c['id'].split("-")[1]) - c["term"] = int(c['id'].split("-")[2]) - offered_in_current_semester = [c for c in data["offerings"] if c['year'] == current_term['year'] and c['term'] == current_term['term']] - old_offerings = [c for c in data["offerings"] if c['year'] != current_term['year'] or c['term'] != current_term['term']] + offered_in_current_semester = [s for s in data["offerings"] if s['year'] == current_term['year'] and s['term'] == current_term['term']] + old_offerings = [s for s in data["offerings"] if s['year'] != current_term['year'] or s['term'] != current_term['term']] old_offerings.reverse() - + current_transfers = [t for t in data["transfers"] if t["effective_end"] == None] inactive_transfers = [t for t in data["transfers"] if t["effective_end"] != None] diff --git a/templates/course.html b/templates/course.html index a7f1363..ba02cd0 100644 --- a/templates/course.html +++ b/templates/course.html @@ -52,7 +52,14 @@ + + {% if not course_info.active%} +

{{course_info.subject}} {{course_info.course_code}}: {{course_info.title}}

+

WARNING: This course is no longer offered by Langara. Information provided here is solely for historical purposes.

+ {% else %}

{{course_info.subject}} {{course_info.course_code}}: {{course_info.title}}

+ {% endif%} + {% if course_info.description %}

{{ course_info.description }}

@@ -60,17 +67,41 @@

Credits:

{{ course_info.credits }}

Title:

{{ course_info.title }}

{# TODO: NEEDS TO BE ADDED TO API#} -

Additional Fees:

{{ course_info.add_fees }}

+

Additional Fees:

${{ course_info.add_fees }}

Repeat Limit:

{{ course_info.rpt_limit }}

Lecture Hours:

{{ course_info.hours_lecture }}

Seminar Hours:

{{ course_info.hours_seminar }}

Lab Hours:

{{ course_info.hours_lab }}

+ +

Offered online:

{{course_info.offered_online|format_attribute}}

+ +

Course outline(s):

+ {% if course_info.outlines%} +

+ {% for outline in course_info.outlines %} + {{outline.file_name}}
+ {% endfor %} +

+ {% else %} +

None

+ {% endif%} {#

Notes:

{{ course_info.notes }}

#} @@ -188,6 +219,7 @@

Current Offerings:

+ @@ -204,6 +236,7 @@

Current Offerings:

{% if loop.first %} +
SemesterCRN Section Seats Waitlist
{{ offering.year }} {{ offering.term }}{{ offering.crn }} {{ offering.section }} {{ offering.seats|default('N/A', true) }} {{ offering.waitlist|default('N/A', true) }}