Commit ded08bd3 authored by Andreas Valder's avatar Andreas Valder
Browse files

displaying not published chapters on course list and lectures

parent c695d754
......@@ -206,7 +206,11 @@ def index():
@register_navbar('Videos', icon='film')
def courses():
courses = query('SELECT * FROM courses WHERE (? OR (visible AND listed)) ORDER BY lower(semester), lower(title)', ismod())
chapters = {}
for i in query('SELECT lectures.course_id AS id, COUNT(chapters.id) AS c FROM chapters JOIN lectures ON chapters.lecture_id = lectures.id WHERE NOT chapters.visible GROUP BY lectures.course_id'):
chapters[i['id']] = i['c']
for course in courses:
course['chapter_count'] = chapters.get(course['id'], 0)
if course['semester'] == '':
course['semester'] = 'zeitlos'
groupedby = request.args.get('groupedby')
......@@ -224,11 +228,15 @@ def course(id=None, handle=None):
course = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', handle, ismod())[0]
course['perm'] = query('SELECT * FROM perm WHERE (NOT perm.deleted) AND course_id = ? ORDER BY type', course['id'])
perms = query('SELECT perm.* FROM perm JOIN lectures ON (perm.lecture_id = lectures.id) WHERE (NOT perm.deleted) AND lectures.course_id = ? ORDER BY perm.type', course['id'])
chapters = {}
for i in query('SELECT lectures.id AS id, COUNT(chapters.id) AS c FROM chapters JOIN lectures ON chapters.lecture_id = lectures.id WHERE lectures.course_id = ? GROUP BY chapters.lecture_id;', course['id']):
chapters[i['id']] = i['c']
lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible) ORDER BY time, duration DESC', course['id'], ismod())
for lecture in lectures:
lecture['perm'] = []
lecture['perm'] += course['perm']
lecture['course'] = course
lecture['chapter_count'] = chapters.get(lecture['id'], 0)
for perm in perms:
if perm['lecture_id'] == lecture['id']:
lecture['perm'].append(perm)
......
......@@ -71,7 +71,7 @@
{% if groupedby == 'semester' %}
{{ course_list_item(i) }}
{% else %}
{{ course_list_item(i,true) }}
{{ course_list_item(i, true) }}
{% endif %}
{% endfor %}
</ul>
......
......@@ -155,6 +155,9 @@ $(function() {
<a href="{{url_for('course', handle=course.handle)}}">
{{ course.title }}{% if ismod() %}<i> ({{course.id}})</i>{% endif %}
</a>
{% if course.chapter_count|d(0) > 0 and ismod() %}
<span class="label label-info" data-toggle="tooltip" title="Nicht freigegebene Kapitel">{{ course.chapter_count }}</span>
{% endif %}
</span>
<span class="col-xs-8 col-md-3">
{{ course.organizer }}
......@@ -216,7 +219,13 @@ $('#embedcodebtn').popover(
{% endif %}
</div>
<ul class="list-unstyled col-sm-3 col-xs-12">
<li>{{ moderator_editor(['lectures',lecture.id,'title'], lecture.title) }}{{livelabel((lecture.live and lecture.time > datetime.now()-timedelta(days=1)), videos|selectattr("livehandle")|list|length)}}</li>
<li>
{{ moderator_editor(['lectures',lecture.id,'title'], lecture.title) }}
{{ livelabel((lecture.live and lecture.time > datetime.now()-timedelta(days=1)), videos|selectattr("livehandle")|list|length) }}
{% if lecture.chapter_count|d(0) > 0 and ismod() %}
<span class="label label-info" data-toggle="tooltip" title="Nicht freigegebene Kapitel">{{ lecture.chapter_count }}</span>
{% endif %}
</li>
{% if lecture.speaker or ismod() %}<li>Gehalten von {{ moderator_editor(['lectures',lecture.id,'speaker'], lecture.speaker) }}</li>{% endif %}
{% if ismod() %}
<li>{{ moderator_editor(['lectures',lecture.id,'time'], lecture.time) }} </li>
......@@ -263,7 +272,13 @@ $('#embedcodebtn').popover(
<div class="col-sm-2 col-xs-12">
</div>
<ul class="list-unstyled col-sm-3 col-xs-12">
<li>{{ moderator_editor(['lectures',lecture.id,'title'], lecture.title) }}{{livelabel((lecture.live and lecture.time > datetime.now()-timedelta(days=1)), videos|selectattr("livehandle")|list|length)}}</li>
<li>
{{ moderator_editor(['lectures',lecture.id,'title'], lecture.title) }}
{{livelabel((lecture.live and lecture.time > datetime.now()-timedelta(days=1)), videos|selectattr("livehandle")|list|length)}}
{% if lecture.chapter_count|d(0) > 0 and ismod() %}
<span class="label label-info" data-toggle="tooltip" title="Nicht freigegebene Kapitel">{{ lecture.chapter_count }}</span>
{% endif %}
</li>
</ul>
<ul class="list-unstyled col-sm-3 col-xs-12">
{% if ismod() %}
......
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