Skip to content
Snippets Groups Projects
Commit 691de0fd authored by Julian Rother's avatar Julian Rother
Browse files

Merge branch 'master' of git.fsmpi.rwth-aachen.de:videoagwebsite/videoagwebsite

parents 7f406b1a 06543f5e
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,15 @@ def query(operation, *params, delim="sep"): ...@@ -61,7 +61,15 @@ def query(operation, *params, delim="sep"):
operation, params = fix_query(operation, params) operation, params = fix_query(operation, params)
cur = get_dbcursor() cur = get_dbcursor()
cur.execute(operation, params) cur.execute(operation, params)
rows = []
try:
rows = cur.fetchall() rows = cur.fetchall()
except mysql.connector.errors.InterfaceError as ie:
if ie.msg == 'No result set to fetch from.':
# no problem, we were just at the end of the result set
pass
else:
raise
res = [] res = []
for row in rows: for row in rows:
res.append({}) res.append({})
...@@ -114,7 +122,7 @@ if 'LDAP_HOST' in config: ...@@ -114,7 +122,7 @@ if 'LDAP_HOST' in config:
try: try:
conn = ldap3.Connection(config['LDAP_HOST'], 'uid=%s,ou=users,dc=fsmpi,dc=rwth-aachen,dc=de'%user, password, auto_bind=True) conn = ldap3.Connection(config['LDAP_HOST'], 'uid=%s,ou=users,dc=fsmpi,dc=rwth-aachen,dc=de'%user, password, auto_bind=True)
if conn.search("ou=groups,dc=fsmpi,dc=rwth-aachen,dc=de", "(&(cn=*)(memberUid=%s))"%user, attributes=['cn']): if conn.search("ou=groups,dc=fsmpi,dc=rwth-aachen,dc=de", "(&(cn=*)(memberUid=%s))"%user, attributes=['cn']):
groups = [e.cn.value for e in conn.entries] groups = [e['attributes']['cn'][0] for e in conn.response]
conn.unbind() conn.unbind()
return user, groups return user, groups
except ldap3.core.exceptions.LDAPBindError: except ldap3.core.exceptions.LDAPBindError:
...@@ -125,10 +133,10 @@ if 'LDAP_HOST' in config: ...@@ -125,10 +133,10 @@ if 'LDAP_HOST' in config:
conn = ldap3.Connection('ldaps://rumo.fsmpi.rwth-aachen.de', auto_bind=True) conn = ldap3.Connection('ldaps://rumo.fsmpi.rwth-aachen.de', auto_bind=True)
conn.search("ou=users,dc=fsmpi,dc=rwth-aachen,dc=de", "(uid=%s)"%user, conn.search("ou=users,dc=fsmpi,dc=rwth-aachen,dc=de", "(uid=%s)"%user,
attributes=ldap3.ALL_ATTRIBUTES) attributes=ldap3.ALL_ATTRIBUTES)
if not conn.entries: if not conn.response:
return {} return {}
e = conn.entries[0] e = conn.response[0]
return {'uid': user, 'givenName': e.givenName.value, 'sn':e.sn.value} return {'uid': user, 'givenName': e['attributes']['givenName'][0], 'sn':e['attributes']['sn'][0]}
else: else:
notldap = { notldap = {
......
File moved
...@@ -172,6 +172,11 @@ def handle_errors(endpoint, text, code, *errors, **epargs): ...@@ -172,6 +172,11 @@ def handle_errors(endpoint, text, code, *errors, **epargs):
def handle_not_found(e): def handle_not_found(e):
return render_endpoint('index', 'Diese Seite existiert nicht!'), 404 return render_endpoint('index', 'Diese Seite existiert nicht!'), 404
# debian ships jinja2 without this test...
@app.template_test(name='equalto')
def equalto(a,b):
return a == b
@app.template_filter(name='semester') @app.template_filter(name='semester')
def human_semester(s, long=False): def human_semester(s, long=False):
if not s or s == 'zeitlos' or len(s) != 6: if not s or s == 'zeitlos' or len(s) != 6:
...@@ -205,7 +210,7 @@ def get_announcements(minlevel=0): ...@@ -205,7 +210,7 @@ def get_announcements(minlevel=0):
offset = timedelta() offset = timedelta()
if ismod(): if ismod():
offset = timedelta(hours=24) offset = timedelta(hours=24)
return query('SELECT * FROM announcements WHERE NOT deleted AND (time_expire ISNULL OR time_expire > ?) AND (? OR (visible AND time_publish < ?)) AND level >= ? ORDER BY level DESC', datetime.now()-offset, ismod(), datetime.now(), minlevel) return query('SELECT * FROM announcements WHERE NOT deleted AND ((time_expire = NULL) OR time_expire > ?) AND (? OR (visible AND time_publish < ?)) AND level >= ? ORDER BY level DESC', datetime.now()-offset, ismod(), datetime.now(), minlevel)
@app.template_filter() @app.template_filter()
def fixnl(s): def fixnl(s):
...@@ -385,7 +390,7 @@ def edit(prefix='', ignore=[]): ...@@ -385,7 +390,7 @@ def edit(prefix='', ignore=[]):
prefix = request.args['prefix'] prefix = request.args['prefix']
modify('BEGIN') modify('BEGIN')
changes = request.values.items() changes = request.values.items()
if request.is_json: if (request.method == 'POST') and (request.get_json()):
changes = request.get_json().items() changes = request.get_json().items()
for key, val in changes: for key, val in changes:
if key in ignore: if key in ignore:
...@@ -414,7 +419,7 @@ def create(table): ...@@ -414,7 +419,7 @@ def create(table):
columns.append(column) columns.append(column)
values.append(val) values.append(val)
args = request.values args = request.values
if request.is_json: if (request.method == 'POST') and (request.get_json()):
args = request.get_json() args = request.get_json()
for column, val in args.items(): for column, val in args.items():
if column == 'ref': if column == 'ref':
...@@ -539,5 +544,5 @@ if 'ICAL_URL' in config: ...@@ -539,5 +544,5 @@ if 'ICAL_URL' in config:
import meetings import meetings
if 'L2P_APIKEY' in config: if 'L2P_APIKEY' in config:
import l2pauth import l2pauth
import worker import jobs
import timetable import timetable
...@@ -26,6 +26,15 @@ def to_ascii(inputstring): ...@@ -26,6 +26,15 @@ def to_ascii(inputstring):
asciistring = asciistring.replace(charset[0],charset[1]) asciistring = asciistring.replace(charset[0],charset[1])
return asciistring return asciistring
def insert_video(lectureid,dbfilepath,filepath,fileformatid):
video_id = modify('''INSERT INTO videos_data
(lecture_id,visible,path,video_format,title,comment,internal,file_modified,time_created,time_updated,created_by,hash,file_size)
VALUES
(?,0,?,?,"","","",?,?,?,?,"",?)''',
lectureid, dbfilepath, fileformatid, datetime.now(), datetime.now(), datetime.now(), -1, os.stat(filepath).st_size)
query('INSERT INTO sortlog (lecture_id,video_id,path,`when`) VALUES (?,?,?,?)', lectureid, video_id, dbfilepath, datetime.now())
@app.route('/sort/now') @app.route('/sort/now')
@mod_required @mod_required
@sched_func(600) @sched_func(600)
...@@ -130,13 +139,7 @@ def sort_now(): ...@@ -130,13 +139,7 @@ def sort_now():
if not 'format' in data: if not 'format' in data:
data['format'] = 0 data['format'] = 0
# insert the video into videos_data and log # insert the video into videos_data and log
video_id = modify(''' insert_video( matches[0]['id'], dbfilepath, filepath, fileformatid)
INSERT INTO videos_data
(lecture_id,visible,path,video_format,title,comment,internal,file_modified,time_created,time_updated,created_by,hash,file_size)
VALUES
(?,0,?,?,"","","",?,?,?,?,"",?)''',
matches[0]['id'], dbfilepath, data['format'], datetime.now(), datetime.now(), datetime.now(), -1, os.stat(filepath).st_size)
query('INSERT INTO sortlog (lecture_id,video_id,path,`when`) VALUES (?,?,?,?)', matches[0]['id'], video_id, dbfilepath, datetime.now())
else: else:
# if we couldn't match the video on exactly one lecture, log an error # if we couldn't match the video on exactly one lecture, log an error
matches_id = [] matches_id = []
......
...@@ -119,6 +119,7 @@ ...@@ -119,6 +119,7 @@
</div> </div>
</div> </div>
</div> </div>
{% block footer %}
<footer class="footer hidden-print"> <footer class="footer hidden-print">
<div class="container-fluid"> <div class="container-fluid">
<ul class="list-inline" style="margin-top: 5px;"> <ul class="list-inline" style="margin-top: 5px;">
...@@ -139,6 +140,7 @@ ...@@ -139,6 +140,7 @@
</li> </li>
</div> </div>
</footer> </footer>
{% endblock %}
</body> </body>
{% if ismod() %} {% if ismod() %}
<script> <script>
......
...@@ -14,3 +14,5 @@ ...@@ -14,3 +14,5 @@
</div> </div>
{% endblock %} {% endblock %}
{% block footer %}
{% endblock %}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div> <div>
<p>Es folgen viele Pärchen an Campus-URL und Veranstaltungstyp Pärchen. Die Campus URL bekommt man aus dem Campus-System (<a href="https://www.campus.rwth-aachen.de/rwth/all/groups.asp">hier</a>). Der Veranstaltungstyp ist z.B. "Vorlesung" oder "Übung" oder "Praktikum". <p>Es folgen viele Pärchen an Campus-URL und Veranstaltungstyp Pärchen. Die Campus URL bekommt man aus dem Campus-System (<a href="https://www.campus.rwth-aachen.de/rwth/all/groups.asp" target="_blank">hier</a>). Der Veranstaltungstyp ist z.B. "Vorlesung" oder "Übung" oder "Praktikum".
</p> </p>
<form method="post"> <form method="post">
<ul class="list-group row" style="margin-left: 0px; margin-right: 0px;"> <ul class="list-group row" style="margin-left: 0px; margin-right: 0px;">
......
...@@ -42,9 +42,9 @@ ...@@ -42,9 +42,9 @@
<th></th> <th></th>
</tr> </tr>
{% for c in chapters|sort(attribute='time') %} {% for c in chapters|sort(attribute='time') %}
<tr onclick="videojs('videoplayer').currentTime({{c['time']}})"> <tr>
<td>{{ loop.index }}</td> <td>{{ loop.index }}</td>
<td>{{ vtttime(c['time']) }}</td> <td><a href="javascript:videojs('videoplayer').currentTime({{c['time']}})">{{ vtttime(c['time']) }}</a></td>
<td>{{ moderator_editor(['chapters',c.id,'text'],c['text']) }}</td> <td>{{ moderator_editor(['chapters',c.id,'text'],c['text']) }}</td>
<td>{{ moderator_checkbox(['chapters',c.id,'visible'], c.visible) }}</td> <td>{{ moderator_checkbox(['chapters',c.id,'visible'], c.visible) }}</td>
<td>{{ moderator_delete(['chapters',c.id,'deleted']) }}</td> <td>{{ moderator_delete(['chapters',c.id,'deleted']) }}</td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment