Skip to content

Commit bb82e74

Browse files
etaveRomainMechain
andcommitted
feat/ Ajout des paramètres dans les routes
Co-authored-by: RomainMechain <RomainMechain@users.noreply.github.com>
1 parent 330d42f commit bb82e74

File tree

11 files changed

+76
-247
lines changed

11 files changed

+76
-247
lines changed

app/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
def create_app(config_class = Config, is_worker=False):
3232
from app.register import bp as register_bp
33-
from app.api import bp as api_bp
3433
from app.notifications import bp as notifications_bp
3534
from app.login import bp as login_bp
3635
from app.home import bp as home_bp
@@ -81,7 +80,6 @@ def handle_process_status_message(message):
8180
pubsub.subscribe(**{'process_status': handle_process_status_message})
8281
pubsub.run_in_thread(sleep_time=0.5)
8382

84-
app.register_blueprint(api_bp, url_prefix='/api')
8583
app.register_blueprint(register_bp, url_prefix='/inscription')
8684
app.register_blueprint(notifications_bp, url_prefix='/notifications')
8785
app.register_blueprint(login_bp, url_prefix='/connexion')

app/api/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/api/routes.py

Lines changed: 0 additions & 210 deletions
This file was deleted.

app/desktop/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
@bp.route('/')
99
@login_required
1010
def desktop():
11-
return render_template('desktop/index.html', is_authenticated=True, is_admin=current_user.id_Role == 1)
11+
return render_template('desktop/index.html', is_authenticated=True, is_admin=current_user.id_Role == 1, has_notifications=current_user.NOTIFICATION != [])

app/file_handler/routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from app.file_handler import bp
22
from flask import send_from_directory, abort, current_app, request
33
from app.models.fichier import FICHIER
4-
from flask_login import current_user
4+
from flask_login import current_user, login_required
55
from app import socketio
66
from app.extensions import db
77

88
@bp.route('/dossier/<int:folder_id>/fichier/<int:file_id>', methods=['GET'])
9+
@login_required
910
def file(folder_id, file_id):
1011
file = FICHIER.query.get(file_id)
1112
as_attachment = request.args.get('as_attachment', default=False, type=bool)

app/home/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def home():
3434
"home/index.html",
3535
is_authenticated=True,
3636
is_admin=current_user.id_Role == 1,
37+
has_notifications=current_user.NOTIFICATION != [],
3738
favorite_files=favorite_files,
3839
researches=researches,
3940
form=form,

app/login/routes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from flask import render_template, redirect, url_for, flash
6-
from flask_login import login_user
6+
from flask_login import login_user, current_user
77
from flask_bcrypt import check_password_hash, generate_password_hash
88
from app.login import bp
99
from app.models.utilisateur import UTILISATEUR
@@ -39,6 +39,8 @@ def login():
3939
Returns:
4040
The rendered login template with the login form and forgotten password form.
4141
"""
42+
if current_user is not None and current_user.is_authenticated:
43+
return redirect(url_for("home.home"))
4244
form = LoginForm()
4345
mdp_form = ForgottenPasswordForm()
4446
if form.validate_on_submit():

0 commit comments

Comments
 (0)