diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dbf9c0a437b049658194537f08ebf0339c3ba836..597d82f129c5ee8079df66298bf596bb772eaa8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,11 @@ -before_script: - - apt update - - apt install -y python3 - - python3 -V - - uname -a - unittest: image: debian:stretch stage: test script: + - apt update + - apt install -y python3 + - python3 -V + - uname -a - apt install -y sqlite3 locales-all git python3-flask python3-ldap3 python3-requests python3-lxml python3-icalendar python3-mysql.connector python3-requests python3-coverage - python3 -m coverage run tests.py - python3 -m coverage report --include "./*" @@ -23,5 +21,16 @@ livetest: image: debian:stretch stage: test script: + - apt update + - apt install -y python3 + - python3 -V + - uname -a - apt install -y python3-requests - - ./tests/urlcheck_sinf.py \ No newline at end of file +# - ./tests/urlcheck_sinf.py + +deploy_staging: + image: archlinux/base + stage: deploy + script: + - pacman --noconfirm -Sy ansible git + \ No newline at end of file diff --git a/server.py b/server.py index 8ece609dd1667136ed89aacbfa86ace040b85048..2b36d5b418b4150b94fd615b990ec3111d270bee 100644 --- a/server.py +++ b/server.py @@ -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 AND NOT chapters.deleted 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 = ? AND NOT chapters.visible AND NOT chapters.deleted 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) diff --git a/templates/base.html b/templates/base.html index f406d4db614a0c0d0060ebd6bccc9db9e520a496..4d6f13150b3b59cc91b60745b2cea12a70ba7a2d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -167,7 +167,7 @@ </li> {% if ismod() or config.DEBUG %} <li class="pull-right"> - <a target="_blank" href="https://git.fsmpi.rwth-aachen.de/videoagwebsite/videoagwebsite/commit/{{ gitversion.longhash }}"><span title="{{ gitversion.branch }} {{ gitversion.hash }}: {{ gitversion.msg }}" data-toggle="tooltip">{{ gitversion.hash }}</span></a> + <a target="_blank" href="https://git.fsmpi.rwth-aachen.de/videoaginfra/website/commit/{{ gitversion.longhash }}"><span title="{{ gitversion.branch }} {{ gitversion.hash }}: {{ gitversion.msg }}" data-toggle="tooltip">{{ gitversion.hash }}</span></a> <span>{{ gethostname() }}</span> {% if is_readonly() %} <span>(read-only)</span> diff --git a/templates/courses.html b/templates/courses.html index 6b8ee827a37f921af04ce795dc4ae7d9ff97758c..9eb562f0905ef49a41c9730f0f68f13525bb3f16 100644 --- a/templates/courses.html +++ b/templates/courses.html @@ -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> diff --git a/templates/macros.html b/templates/macros.html index 49fb6633300d0a29a4403b963a71a3e60fb36baa..ea67c2a75544349d59f2664c1051fada3dac478e 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -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() %}