Skip to content
Snippets Groups Projects
Commit 6f9983f0 authored by Andreas Valder's avatar Andreas Valder
Browse files

made schedule look better

parent 511b61d4
No related branches found
No related tags found
No related merge requests found
......@@ -196,9 +196,11 @@ def auth(): # For use with nginx auth_request
@mod_required
def schedule():
start = date.today() - timedelta(days=date.today().weekday()+7*20)
days = [{'date': start, 'lectures': [], 'atonce':0 }]
days = [{'date': start, 'lectures': [], 'atonce':0, 'index': 0 }]
earlieststart=time(23,59)
latestend=time(0,0)
for i in range(1,7):
days.append({'date': days[i-1]['date'] + timedelta(days=1), 'lectures':[], 'atonce':0 })
days.append({'date': days[i-1]['date'] + timedelta(days=1), 'atonce':0, 'index': i, 'lectures':[] })
for i in days:
# date and times are burning in sqlite
s = datetime.combine(i['date'],time())
......@@ -219,12 +221,18 @@ def schedule():
if len(freecol) == 0:
freecol.append(maxcol)
l[2]['schedule_col'] = freecol.pop()
if earlieststart > l[0].time():
earlieststart = l[0].time()
else:
curcol -= 1
freecol.append(l[2]['schedule_col'])
if latestend < l[0].time():
latestend = l[0].time()
i['maxcol'] = max(maxcol,1)
times=[]
for i in range(0,int(60*24/15)):
s = min(earlieststart,time(8,0))
e = max(latestend,time(20,0))
for i in range(s.hour*4,int(60*e.hour/15)):
t = i*15
times.append(time(int(t/60),t%60))
......
......@@ -7,15 +7,15 @@
</div>
<div class="panel-body row">
<table class="table-bordered col-xs-12">
<tr><th></th>{% for d in days %}<th colspan="{{d.maxcol}}">{{ d.date.strftime("%A (%d.%m.%Y)") }}</th>{% endfor %}</tr>
<tr><th></th>{% for d in days if (d.index < 5) or (d.lectures|length) > 0%}<th colspan="{{d.maxcol}}">{{ d.date.strftime("%A (%d.%m.%Y)") }}</th>{% endfor %}</tr>
{% for t in times %}
{% set time_loop = loop %}
<tr height="10px">
{% if ((loop.index - 1) is divisibleby 4) %} <td rowspan=4>{{ t }}</td> {% endif %}
{% for d in days %}
<tr height="15px">
{% if ((loop.index - 1) is divisibleby 4) %} <td rowspan="4" style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %}
{% for d in days if (d.index < 5) or (d.lectures|length) > 0 %}
{% for i in range(1,d.maxcol+1) %}
{% for l in d.lectures|selectattr('schedule_col','equalto',i) if (((l.time_asdate.time() > t) and (l.time_asdate.time() < times[time_loop.index+1])) != (l.time_asdate.time() == t ) ) %}
<td rowspan="{{l.duration / 15}}" style="background: red;">{{l.handle}}</td>
<td rowspan="{{l.duration / 15}}" style="background: lightgrey;"><p class="small"><strong>{{l.short}}</strong><br>{{l.time_asdate.strftime("%H:%M")}} - {{l.end_asdate.strftime("%H:%M")}}<br>{{l.place}}</p> </td>
{% else %}
{% for l in d.lectures|selectattr('schedule_col','equalto',i) if (l.time_asdate.time() < t) and (l.end_asdate.time() > t) %}
{% else %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment