Commit 6bb2fe36 authored by Julian Rother's avatar Julian Rother
Browse files

Implemented fancy semester naming

parent 31a90ae3
...@@ -7,7 +7,7 @@ import os ...@@ -7,7 +7,7 @@ import os
import hashlib import hashlib
import locale import locale
locale.setlocale(locale.LC_ALL, 'de_DE') locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
app = Flask(__name__) app = Flask(__name__)
...@@ -94,8 +94,20 @@ def handle_not_found(e): ...@@ -94,8 +94,20 @@ def handle_not_found(e):
return render_endpoint('index', 'Diese Seite existiert nicht!'), 404 return render_endpoint('index', 'Diese Seite existiert nicht!'), 404
@app.template_filter(name='semester') @app.template_filter(name='semester')
def human_semester(s): def human_semester(s, long=False):
return s if not s or s == 'zeitlos' or len(s) != 6:
return 'Zeitlos'
year = s[0:4]
semester = s[4:6].upper()
if not year.isdigit() or semester not in ['SS', 'WS']:
print('Invalid semester string "%s"'%s)
return '??'
if not long:
return semester+year[2:]
elif semester == 'SS':
return 'Sommersemester %s'%year
else:
return 'Wintersemester %s/%s'%(year, str(int(year)+1)[2:])
@app.template_filter(name='date') @app.template_filter(name='date')
def human_date(d): def human_date(d):
......
...@@ -20,7 +20,11 @@ ...@@ -20,7 +20,11 @@
<div class="row panel-group"> <div class="row panel-group">
<div class="col-xs-12"><div class="panel panel-default"> <div class="col-xs-12"><div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
{% if groupedby == 'semester' %}
<h1 class="panel-title">{{g.grouper|semester(long=True)}}</h1>
{% else %}
<h1 class="panel-title">{{g.grouper}}</h1> <h1 class="panel-title">{{g.grouper}}</h1>
{% endif %}
</div> </div>
<ul class="{% if not ismod() %}courses-list {% endif %}list-group"> <ul class="{% if not ismod() %}courses-list {% endif %}list-group">
{% for i in g.list %} {% for i in g.list %}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment