Added custom 404 display and login redirect
This commit is contained in:
		@@ -27,7 +27,12 @@ $('form.form-post').submit(function(event) {
 | 
			
		||||
        data: data,
 | 
			
		||||
        dataType: 'json',
 | 
			
		||||
        success: function(response) {
 | 
			
		||||
            if (response.redirect_to) {
 | 
			
		||||
                window.location.href = response.redirect_to;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                window.location.href = rel_success;
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        error: function(response) {
 | 
			
		||||
            error_response(response);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
from flask import Blueprint, render_template, flash, redirect, request, jsonify, abort, make_response
 | 
			
		||||
from flask import Blueprint, render_template, flash, redirect, request, jsonify, abort, session
 | 
			
		||||
from flask.helpers import url_for
 | 
			
		||||
from functools import wraps
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
@@ -56,6 +56,7 @@ def login_required(function):
 | 
			
		||||
    @wraps(function)
 | 
			
		||||
    def decorated_function(*args, **kwargs):
 | 
			
		||||
        if not check_login():
 | 
			
		||||
            session['prev_page'] = request.url
 | 
			
		||||
            flash('Please log in to view this page.', 'alert')
 | 
			
		||||
            return redirect(url_for('admin_auth.login'))
 | 
			
		||||
        return function(*args, **kwargs)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
 | 
			
		||||
from flask import Flask, flash, request
 | 
			
		||||
from flask import Flask, flash, request, render_template
 | 
			
		||||
from flask.helpers import url_for
 | 
			
		||||
from flask.json import jsonify
 | 
			
		||||
from flask_bootstrap import Bootstrap
 | 
			
		||||
@@ -77,4 +77,8 @@ if __name__ == '__main__':
 | 
			
		||||
    def _get_id_from_cookie():
 | 
			
		||||
        return dict(get_id_from_cookie = get_id_from_cookie)
 | 
			
		||||
 | 
			
		||||
    @app.errorhandler(404)
 | 
			
		||||
    def _404_handler(e):
 | 
			
		||||
        return render_template('/quiz/404.html'), 404
 | 
			
		||||
 | 
			
		||||
    app.run(host=app.config['APP_HOST'])
 | 
			
		||||
							
								
								
									
										8
									
								
								ref-test/quiz/templates/quiz/404.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								ref-test/quiz/templates/quiz/404.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
{% extends "quiz/components/base.html" %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <h1>Page Not Found</h1>
 | 
			
		||||
    <p>
 | 
			
		||||
        The page you were looking for does not exist. Try going back and navigating to the desired destination correctly.
 | 
			
		||||
    </p>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -30,11 +30,11 @@
 | 
			
		||||
                {% include "quiz/components/server-alerts.html" %}
 | 
			
		||||
            {% endblock %}
 | 
			
		||||
            {% block content %}{% endblock %}
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
            <footer class="container site-footer">
 | 
			
		||||
                {% include "quiz/components/footer.html" %}
 | 
			
		||||
            </footer>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <!-- JQuery, Popper, and Bootstrap js dependencies -->
 | 
			
		||||
        <script
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user