def login(): """ Dummy implementation. The real login is to be implemented by Ben & co :) """ from main import app from main import User if request.method == "POST": # get parameters data = request.get_json(force=True) username = data.get('username') password = data.get('password') user = User.check_password(username, password) if user is not None: # remember=True means that the session will remember a user. # If not set, the user will be deleted from the session once the browser tab is closed login_user(user, remember=True) return jsonify({'status': 'success', 'user_data': user.to_json()}) else: # what if connection to LDAP failed? return jsonify({ 'status': 'error', 'error': 'Incorrect username or password' }) # if GET, return index.html return app.send_static_file('index.html')
def language_dataset(language, dataset, path): if path == dataset + '.html' or path is None: return render_template( 'corgis/generic.html', name='corgis/{language}/{dataset}/{dataset}.html'.format( language=language, dataset=dataset)) else: return app.send_static_file( 'corgis/{language}/{dataset}/{path}'.format(language=language, dataset=dataset, path=path))
def get_submission_image(lti=lti): submission_id = int(request.values.get('submission_id')) relative_image_path = 'uploads/submission_blocks/{}.png'.format(submission_id) submission = Submission.query.get(submission_id) user, user_id = get_user() # Check exists check_resource_exists(submission, "Submission", submission_id) # Check permissions if submission.user_id != user_id: require_course_grader(user, submission.course_id) # Do action return app.send_static_file(relative_image_path)
def get_image(): submission_id = int(request.values.get('submission_id')) directory = request.values.get('directory') relative_image_path = 'uploads/{}/{}.png'.format(directory, submission_id) submission = Submission.query.get(submission_id) user, user_id = get_user() # Check exists check_resource_exists(submission, "Submission", submission_id) # Check permissions if submission.user_id != user_id and not user.is_grader(submission.course_id): return ajax_failure("This is not your submission and you are not a grader in its course.") # Do action return app.send_static_file(relative_image_path)
def get_submission_image(lti=lti): submission_id = request.values.get('submission_id', None) if submission_id is None: return "Sorry, no submission ID was given." relative_image_path = 'uploads/submission_blocks/'+str(submission_id)+'.png' submission = Submission.query.get(int(submission_id)) course_id = request.values.get('course_id', None) if course_id is None: if 'course' in g: course_id = g.course.id else: return "No course was found or given." if g.user.is_grader(course_id) or submission.user_id == g.user.id: return app.send_static_file(relative_image_path) else: return "Sorry, you do not have sufficient permissions to spy!"
def load_corgis(path): return app.send_static_file('corgis/{path}'.format(path=path))
def index(): # return render_template('index.html') return app.send_static_file('index.html')
def corgis_static_libs(path): return app.send_static_file('libs/' + path)
def corgis_static_images(path): return app.send_static_file('images/' + path)
def get_stats(): if request.method == "GET": from main import app return app.send_static_file('index.html') else: return ""
def grading_static(path): return app.send_static_file(path)
def static_proxy(path): return app.send_static_file(path)
def root(): return app.send_static_file("index.html")
def download_pic(): return app.send_static_file("images/dd.PNG")
def blockpy_static(path): return app.send_static_file(path)
def index(): return app.send_static_file('index.html')
def assignments_static_images(path): return app.send_static_file('images/' + path)
def reports(): from main import app return app.send_static_file('index.html')