diff --git a/l2pauth.py b/l2pauth.py index a643c82ed5c9c10be494bdd159628e076e9ec772..8678e9ff0b04aa6829aff90d5079d3720b3dfb54 100644 --- a/l2pauth.py +++ b/l2pauth.py @@ -2,15 +2,9 @@ import requests from server import * -L2P_BASE = 'https://www3.elearning.rwth-aachen.de/_vti_bin/l2pservices/api.svc/v1/' OAUTH_BASE = 'https://oauth.campus.rwth-aachen.de/oauth2waitress/oauth2.svc/' MOODLE_BASE = 'https://moped.ecampus.rwth-aachen.de/proxy/api/v2/eLearning/Moodle/' -def l2pget(endpoint, token, **args): - args['accessToken'] = token - r = requests.request('GET', L2P_BASE+endpoint, params=args) - return r.json() - def moodleget(endpoint, token, **args): args['token'] = token r = requests.request('GET', MOODLE_BASE+endpoint, params=args) @@ -23,12 +17,7 @@ def oauthget(endpoint, **args): @app.route('/internal/l2pauth') def start_l2pauth(): - if 'L2P_APIKEY' not in config: - return render_template("500.html"), 500 - code = oauthget('code', scope='l2p2013.rwth') - session['oauthcode'] = code['device_code'] - session['oauthscope'] = 'l2p' - return redirect(code['verification_url']+'?q=verify&d='+code['user_code']) + return "L2P is no longer available." @app.route('/internal/moodleauth') def start_moodleauth(): @@ -39,6 +28,10 @@ def start_moodleauth(): session['oauthscope'] = 'moodle' return redirect(code['verification_url']+'?q=verify&d='+code['user_code']) +@app.route('/internal/moodlel2pauth') +def start_moodlel2pauth(): + return start_moodleauth() + @app.route('/internal/rwthauth') def start_rwthauth(): if 'L2P_APIKEY' not in config: @@ -48,15 +41,6 @@ def start_rwthauth(): session['oauthscope'] = 'rwth' return redirect(code['verification_url']+'?q=verify&d='+code['user_code']) -@app.route('/internal/moodlel2pauth') -def start_moodlel2pauth(): - if 'L2P_APIKEY' not in config: - return render_template("500.html"), 500 - code = oauthget('code', scope='moodle.rwth l2p2013.rwth') - session['oauthcode'] = code['device_code'] - session['oauthscope'] = 'l2pandmoodle' - return redirect(code['verification_url']+'?q=verify&d='+code['user_code']) - @app.before_request def finish_oauth(): if 'L2P_APIKEY' not in config: @@ -67,13 +51,10 @@ def finish_oauth(): if token.get('status') != 'ok': return del session['oauthcode'] + if session['oauthscope'] not in ['l2p', 'rwth', 'moodle', 'l2pandmoodle']: return session['rwthintern'] = True - if session['oauthscope'] == 'l2p' or session['oauthscope'] == 'l2pandmoodle': - session['l2p_courses'] = [] - for course in l2pget('viewAllCourseInfo', token['access_token'])['dataSet']: - session['l2p_courses'].append(course['uniqueid']) if session['oauthscope'] == 'moodle' or session['oauthscope'] == 'l2pandmoodle': data = moodleget('getmyenrolledcourses', token['access_token']) if data and data.get('Data'): diff --git a/server.py b/server.py index 30c57ccc12efe8c99fca2b5fb002659b03e9e1ea..61e39eae3d54444f2af9e8ba058fbea2391ea15b 100644 --- a/server.py +++ b/server.py @@ -345,18 +345,6 @@ def lecture(id, course=None, courseid=None): #pylint: disable=unused-argument,to mode, text = permdescr(perms) if mode == 'rwth': flash(text+'. <a target="_blank" class="reloadonclose" href="'+url_for('start_rwthauth')+'">Hier authorisieren</a>.', category='player') - elif mode == 'l2pandmoodle': - if 'l2p_courses' in session or 'moodle_courses' in session: - flash(text+'. Du bist kein Teilnehmer des L2P oder Moodle-Kurses! \ - <a target="_blank" class="reloadonclose" href="'+url_for('start_moodlel2pauth')+'">Kurse aktualisieren</a>.', category='player') - else: - flash(text+'. <a target="_blank" class="reloadonclose" href="'+url_for('start_moodlel2pauth')+'">Hier authorisieren</a>.', category='player') - elif mode == 'l2p': - if 'l2p_courses' in session: - flash(text+'. Du bist kein Teilnehmer des L2P-Kurses! \ - <a target="_blank" class="reloadonclose" href="'+url_for('start_l2pauth')+'">Kurse aktualisieren</a>.', category='player') - else: - flash(text+'. <a target="_blank" class="reloadonclose" href="'+url_for('start_l2pauth')+'">Hier authorisieren</a>.', category='player') elif mode == 'moodle': if 'moodle_courses' in session: flash(text+'. Du bist kein Teilnehmer des Moodle-Kurses! \ diff --git a/template_helper.py b/template_helper.py index 0ec2aa9f69cb7aa6faf8d7d1be3263d5ef68e8d7..e7fb5f448632c5ddcf441b6d0d255236daa33016 100644 --- a/template_helper.py +++ b/template_helper.py @@ -133,7 +133,6 @@ def permdescr(perms): #pylint: disable=too-many-branches,too-many-return-stateme perms = evalperm(perms) public = False password = False - l2p_courses = [] moodle_courses = [] rwth_intern = False fsmpi_intern = False @@ -142,8 +141,6 @@ def permdescr(perms): #pylint: disable=too-many-branches,too-many-return-stateme public = True elif perm['type'] == 'password': password = True - elif perm['type'] == 'l2p': - l2p_courses.append(perm['param1']) elif perm['type'] == 'moodle': moodle_courses.append(perm['param1']) elif perm['type'] == 'rwth': @@ -158,22 +155,11 @@ def permdescr(perms): #pylint: disable=too-many-branches,too-many-return-stateme return 'rwth', 'Nur für RWTH-Angehörige verfügbar' if fsmpi_intern: return 'fsmpi', 'Nur für Fachschaftler verfügbar' - if l2p_courses: - if password: - if moodle_courses: - return 'l2pandmoodle', 'Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar' - return 'l2p', 'Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar' - if moodle_courses: - return 'l2pandmoodle', 'Nur für Teilnehmer der Veranstaltung verfügbar' - return 'l2p', 'Nur für Teilnehmer der Veranstaltung verfügbar' if moodle_courses: if password: - if l2p_courses: - return 'l2pandmoodle', 'Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar' return 'moodle', 'Nur für Teilnehmer der Veranstaltung und Nutzer mit Passwort verfügbar' - if l2p_courses: - return 'l2pandmoodle', 'Nur für Teilnehmer der Veranstaltung verfügbar' - return 'moodle', 'Nur für Teilnehmer der Veranstaltung verfügbar' + else: + return 'moodle', 'Nur für Teilnehmer der Veranstaltung verfügbar' if password: return 'password', 'Nur für Nutzer mit Passwort verfügbar' return 'none', 'Nicht verfügbar' diff --git a/templates/course.html b/templates/course.html index b1602bf0c5a5b5f8aa326a8dfc1044f34b8b9406..84233d6320f3e2efbb60db1d0b2b1284055be077 100644 --- a/templates/course.html +++ b/templates/course.html @@ -126,7 +126,6 @@ <option selected value="password">Passwort</option> <option value="rwth">RWTH intern</option> <option value="fsmpi">FSMPI intern</option> - <option value="l2p">L2P Lernraum</option> <option value="moodle">Moodle Lernraum</option> <option value="none">Kein Zugriff</option> </select> diff --git a/templates/macros.html b/templates/macros.html index 9c6bf841ed13acbf18492cea375e39634344639c..570cec0f873993a56fa37d5d66c827eea2290461 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -195,19 +195,11 @@ $(function() { <a target="_blank" href="{{ url_for('start_rwthauth') }}" class="btn btn-default reloadonclose">Anmelden</a> </div> {% endif %} - {% if 'l2p' in permtypes or 'moodle' in permtypes %} + {% if 'moodle' in permtypes %} <div class="col-sm-4"> - <h4 class="text-center"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> L2P/Moodle</h4> + <h4 class="text-center"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Moodle</h4> <p>Für Teilnehmer der Veranstaltung verfügbar</p> - {% if 'l2p' in permtypes and not 'moodle' in permtypes %} - {% if not courses_loaded %} - <a target="_blank" href="{{ url_for('start_l2pauth') }}" class="btn btn-default reloadonclose">Anmelden</a> - {% else %} - <p class="alert alert-info">Du bist kein Teilnehmer des L2P-Kurses!</p> - <a target="_blank" href="{{ url_for('start_l2pauth') }}" class="btn btn-default reloadonclose">Kurse aktualisieren</a> - {% endif %} - {% endif %} - {% if 'moodle' in permtypes and not 'l2p' in permtypes %} + {% if 'moodle' in permtypes %} {% if not courses_loaded %} <a target="_blank" href="{{ url_for('start_moodleauth') }}" class="btn btn-default reloadonclose">Anmelden</a> {% else %} @@ -215,18 +207,10 @@ $(function() { <a target="_blank" href="{{ url_for('start_moodleauth') }}" class="btn btn-default reloadonclose">Kurse aktualisieren</a> {% endif %} {% endif %} - {% if 'moodle' in permtypes and 'l2p' in permtypes %} - {% if not courses_loaded %} - <a target="_blank" href="{{ url_for('start_moodlel2pauth') }}" class="btn btn-default reloadonclose">Anmelden</a> - {% else %} - <p class="alert alert-info">Du bist kein Teilnehmer des L2P oder Moodle-Kurses!</p> - <a target="_blank" href="{{ url_for('start_moodlel2pauth') }}" class="btn btn-default reloadonclose">Kurse aktualisieren</a> - {% endif %} - {% endif %} </div> {% endif %} </div> - {% if 'l2p' not in permtypes and 'moodle' not in permtypes and 'rwth' not in permtypes and 'password' not in permtypes %} + {% if 'moodle' not in permtypes and 'rwth' not in permtypes and 'password' not in permtypes %} <p class="alert alert-info" style="margin-top: 2em;">Nur für Fachschaftler verfügbar.</p> {% endif %} </div>