Esempio n. 1
0
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')
Esempio n. 2
0
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))
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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!"
Esempio n. 6
0
def load_corgis(path):
    return app.send_static_file('corgis/{path}'.format(path=path))
Esempio n. 7
0
def index():
    # return render_template('index.html')
    return app.send_static_file('index.html')
Esempio n. 8
0
def corgis_static_libs(path):
    return app.send_static_file('libs/' + path)
Esempio n. 9
0
def corgis_static_images(path):
    return app.send_static_file('images/' + path)
Esempio n. 10
0
def get_stats():
    if request.method == "GET":
        from main import app
        return app.send_static_file('index.html')
    else:
        return ""
Esempio n. 11
0
def grading_static(path):
    return app.send_static_file(path)
Esempio n. 12
0
def static_proxy(path):
    return app.send_static_file(path)
Esempio n. 13
0
def root():
    return app.send_static_file("index.html")
Esempio n. 14
0
def download_pic():
    return app.send_static_file("images/dd.PNG")
Esempio n. 15
0
def blockpy_static(path):
    return app.send_static_file(path)
Esempio n. 16
0
def index():
    return app.send_static_file('index.html')
Esempio n. 17
0
def assignments_static_images(path):
    return app.send_static_file('images/' + path)
Esempio n. 18
0
def reports():
    from main import app
    return app.send_static_file('index.html')