Commit cf2dbd3d authored by Julian Rother's avatar Julian Rother
Browse files

Introduce tagid filter to generate proper element ids

parent 7a769943
......@@ -272,6 +272,17 @@ def fixnl(s):
# To be remove, as soon as db schema is cleaned-up
return str(s).replace('\n', '<br>')
@app.template_filter()
def tagid(s):
if not s:
return 'EMPTY'
s = s.replace(' ', '_').lower()
r = ''
for c in s:
if c in string.ascii_lowercase+string.digits+'_':
r = r + c
return r
@app.route('/')
@register_navbar('Home', icon='home')
def index():
......
......@@ -34,7 +34,7 @@
function autocollapse() {
if($("#xs-check").is(":visible")) {
/* Only expand current semester */
$(".collapse[id!='{{grouped_courses[1].grouper}}']").removeClass('in');
$(".collapse[id!='{{grouped_courses[1].grouper|tagid}}']").removeClass('in');
}
}
$(document).ready(autocollapse);
......@@ -47,7 +47,7 @@
<div class="row panel-group" id="accordion">
<div class="col-xs-12"><div class="panel panel-default">
<div class="panel-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#{{g.grouper}}" style="color: #222;">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#{{g.grouper|tagid}}" style="color: #222;">
{% if groupedby == 'semester' %}
<h1 class="panel-title">{{g.grouper|semester(long=True)}} ({{g.list|length}} Veranstaltungen)</h1>
{% else %}
......@@ -55,7 +55,7 @@
{% endif %}
</a>
</div>
<ul class="{% if not ismod() %}courses-list {% endif %}list-group panel-collapse collapse in" id="{{g.grouper}}">
<ul class="{% if not ismod() %}courses-list {% endif %}list-group panel-collapse collapse in" id="{{g.grouper|tagid}}">
{% for i in g.list|sort(attribute='title') %}
{% if groupedby == 'semester' %}
{{ course_list_item(i) }}
......
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