added confused dashboard
This commit is contained in:
@@ -4,6 +4,8 @@ from datetime import datetime
|
||||
from typing import List, cast
|
||||
|
||||
import flask_login
|
||||
from flask_socketio import join_room
|
||||
|
||||
import pytz
|
||||
from flask import (
|
||||
Blueprint,
|
||||
@@ -19,6 +21,8 @@ from flask import (
|
||||
url_for,
|
||||
)
|
||||
|
||||
from . import socketio
|
||||
|
||||
from .auth import check_password, user_loader
|
||||
from .forms import DeckForm, InfoBannerForm, LoginForm, PasswordForm
|
||||
from .models import Deck, InfoBanner, Password, db
|
||||
@@ -40,6 +44,10 @@ main = Blueprint('main', __name__)
|
||||
slidev_deck_pattern = re.compile(r"^\/slides\/[^\/]+\/\d*(?:\?.*)?$")
|
||||
slidev_all_pattern = re.compile(r"^\/slides\/[^\/]+(?:\/presenter)?\/\d+(?:\?.*)?$")
|
||||
|
||||
@socketio.on("connect")
|
||||
def on_connect():
|
||||
if flask_login.current_user.is_authenticated:
|
||||
join_room("instructor")
|
||||
|
||||
@main.before_request
|
||||
def ensure_cookie():
|
||||
@@ -56,7 +64,7 @@ def ensure_cookie():
|
||||
@main.after_request
|
||||
def inject_confused_button(response):
|
||||
if True:
|
||||
if (slidev_deck_pattern.match(request.path) or request.path == '/')and response.content_type.startswith('text/html'):
|
||||
if (slidev_deck_pattern.match(request.path) or request.path == '/') and response.content_type.startswith('text/html') and not flask_login.current_user.is_authenticated :
|
||||
if response.direct_passthrough:
|
||||
response.direct_passthrough = False
|
||||
body = response.get_data(as_text=True)
|
||||
@@ -157,8 +165,16 @@ def access_link(access_code: str):
|
||||
|
||||
@main.route('/confused', methods=['POST'])
|
||||
def confused():
|
||||
resp = jsonify(success=True)
|
||||
return resp
|
||||
|
||||
socketio.emit(
|
||||
"confused",
|
||||
{
|
||||
"time": datetime.utcnow().isoformat()
|
||||
},
|
||||
to="instructor"
|
||||
)
|
||||
return ("", 204)
|
||||
|
||||
|
||||
@main.route('/retrieve-token', methods=['POST'])
|
||||
def set_username_token():
|
||||
@@ -293,3 +309,7 @@ def hide_active_banner():
|
||||
db.session.commit()
|
||||
return redirect(url_for('main.banner'))
|
||||
|
||||
@main.route('/admin/confused')
|
||||
@flask_login.login_required
|
||||
def confused_notifications():
|
||||
return render_template("confused.html")
|
||||
|
||||
Reference in New Issue
Block a user