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
Branches
No related tags found
No related merge requests found
......@@ -61,7 +61,15 @@ def query(operation, *params, delim="sep"):
operation, params = fix_query(operation, params)
cur = get_dbcursor()
cur.execute(operation, params)
rows = []
try:
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 = []
for row in rows:
res.append({})
......@@ -114,7 +122,7 @@ if 'LDAP_HOST' in config:
try:
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']):
groups = [e.cn.value for e in conn.entries]
groups = [e['attributes']['cn'][0] for e in conn.response]
conn.unbind()
return user, groups
except ldap3.core.exceptions.LDAPBindError:
......@@ -125,10 +133,10 @@ if 'LDAP_HOST' in config:
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,
attributes=ldap3.ALL_ATTRIBUTES)
if not conn.entries:
if not conn.response:
return {}
e = conn.entries[0]
return {'uid': user, 'givenName': e.givenName.value, 'sn':e.sn.value}
e = conn.response[0]
return {'uid': user, 'givenName': e['attributes']['givenName'][0], 'sn':e['attributes']['sn'][0]}
else:
notldap = {
......
File moved
......@@ -172,6 +172,11 @@ def handle_errors(endpoint, text, code, *errors, **epargs):
def handle_not_found(e):
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')
def human_semester(s, long=False):
if not s or s == 'zeitlos' or len(s) != 6:
......@@ -205,7 +210,7 @@ def get_announcements(minlevel=0):
offset = timedelta()
if ismod():
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()
def fixnl(s):
......@@ -385,7 +390,7 @@ def edit(prefix='', ignore=[]):
prefix = request.args['prefix']
modify('BEGIN')
changes = request.values.items()
if request.is_json:
if (request.method == 'POST') and (request.get_json()):
changes = request.get_json().items()
for key, val in changes:
if key in ignore:
......@@ -414,7 +419,7 @@ def create(table):
columns.append(column)
values.append(val)
args = request.values
if request.is_json:
if (request.method == 'POST') and (request.get_json()):
args = request.get_json()
for column, val in args.items():
if column == 'ref':
......@@ -539,5 +544,5 @@ if 'ICAL_URL' in config:
import meetings
if 'L2P_APIKEY' in config:
import l2pauth
import worker
import jobs
import timetable
......@@ -26,6 +26,15 @@ def to_ascii(inputstring):
asciistring = asciistring.replace(charset[0],charset[1])
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')
@mod_required
@sched_func(600)
......@@ -130,13 +139,7 @@ def sort_now():
if not 'format' in data:
data['format'] = 0
# insert the video into videos_data and log
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,?,?,"","","",?,?,?,?,"",?)''',
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())
insert_video( matches[0]['id'], dbfilepath, filepath, fileformatid)
else:
# if we couldn't match the video on exactly one lecture, log an error
matches_id = []
......
......@@ -119,6 +119,7 @@
</div>
</div>
</div>
{% block footer %}
<footer class="footer hidden-print">
<div class="container-fluid">
<ul class="list-inline" style="margin-top: 5px;">
......@@ -139,6 +140,7 @@
</li>
</div>
</footer>
{% endblock %}
</body>
{% if ismod() %}
<script>
......
......@@ -14,3 +14,5 @@
</div>
{% endblock %}
{% block footer %}
{% endblock %}
......@@ -8,7 +8,7 @@
</div>
<div class="panel-body">
<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>
<form method="post">
<ul class="list-group row" style="margin-left: 0px; margin-right: 0px;">
......
......@@ -42,9 +42,9 @@
<th></th>
</tr>
{% for c in chapters|sort(attribute='time') %}
<tr onclick="videojs('videoplayer').currentTime({{c['time']}})">
<tr>
<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_checkbox(['chapters',c.id,'visible'], c.visible) }}</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