Skip to content

Commit

Permalink
updates to new api response
Browse files Browse the repository at this point in the history
  • Loading branch information
Highfire1 committed Jun 20, 2024
1 parent 701a5e0 commit 2d30a42
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
19 changes: 12 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]

Expand Down
35 changes: 34 additions & 1 deletion templates/course.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,56 @@
</style>
</head>
<body>

{% if not course_info.active%}
<h2>{{course_info.subject}} {{course_info.course_code}}: {{course_info.title}}</h2>
<p>WARNING: This course is no longer offered by Langara. Information provided here is solely for historical purposes.</p>
{% else %}
<h2><a href="https://langara.ca/programs-and-courses/courses/{{course_info.subject}}/{{course_info.course_code}}.html">{{course_info.subject}} {{course_info.course_code}}: {{course_info.title}}</a></h2>
{% endif%}


{% if course_info.description %}
<p>{{ course_info.description }}</p>
{% else %}
<p>Course description not available.</p>
{% endif %}

{% if course_info.desc_registration_restriction %}
<p>{{ course_info.desc_registration_restriction }}</p>
{% endif %}
{% if course_info.desc_duplicate_credit %}
<p>{{ course_info.desc_duplicate_credit }}</p>
{% endif %}
{% if course_info.desc_prerequisite %}
<p>{{ course_info.desc_prerequisite }}</p>
{% endif %}


<h2>Course Information:</h2>

<div class="grid">
<p>Credits:</p><p>{{ course_info.credits }}</p>
<p>Title:</p><p>{{ course_info.title }}</p>
{# TODO: NEEDS TO BE ADDED TO API#}
<p>Additional Fees:</p><p>{{ course_info.add_fees }}</p>
<p>Additional Fees:</p><p>${{ course_info.add_fees }}</p>
<p>Repeat Limit:</p><p>{{ course_info.rpt_limit }}</p>
<p>Lecture Hours:</p><p>{{ course_info.hours_lecture }}</p>
<p>Seminar Hours:</p><p>{{ course_info.hours_seminar }}</p>
<p>Lab Hours:</p><p>{{ course_info.hours_lab }}</p>

<p>Offered online:</p><p>{{course_info.offered_online|format_attribute}}</p>

<p>Course outline(s):</p>
{% if course_info.outlines%}
<p>
{% for outline in course_info.outlines %}
<a href={{outline.url}} target="_blank">{{outline.file_name}}</a><br>
{% endfor %}
</p>
{% else %}
<p>None</p>
{% endif%}

{# <p>Notes:</p><p>{{ course_info.notes }}</p> #}
</div>
Expand Down Expand Up @@ -188,6 +219,7 @@ <h2>Current Offerings:</h2>
<table class="offeredTable mono">
<thead>
<th>Semester</th>
<th>CRN</th>
<th>Section</th>
<th>Seats</th>
<th>Waitlist</th>
Expand All @@ -204,6 +236,7 @@ <h2>Current Offerings:</h2>
<tr>
{% if loop.first %}
<td rowspan="{{ schedule_length }}">{{ offering.year }} {{ offering.term }}</td>
<td rowspan="{{ schedule_length }}">{{ offering.crn }}</td>
<td rowspan="{{ schedule_length }}">{{ offering.section }}</td>
<td rowspan="{{ schedule_length }}">{{ offering.seats|default('N/A', true) }}</td>
<td rowspan="{{ schedule_length }}">{{ offering.waitlist|default('N/A', true) }}</td>
Expand Down

0 comments on commit 2d30a42

Please sign in to comment.