mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 11:19:58 +00:00
Removed any errors by ignoring them
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from flask import Blueprint, render_template, redirect, url_for, flash
|
from flask import Blueprint, render_template, redirect, url_for
|
||||||
|
|
||||||
# from application import db
|
# from application import db
|
||||||
from application.auth.models import User
|
from application.auth.models import User
|
||||||
@@ -36,5 +36,4 @@ def login():
|
|||||||
@login_required
|
@login_required
|
||||||
def logout():
|
def logout():
|
||||||
logout_user()
|
logout_user()
|
||||||
flash("Je bent nu uitgelogd.")
|
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ def admin():
|
|||||||
feedback="Username is already taken",
|
feedback="Username is already taken",
|
||||||
)
|
)
|
||||||
new_user = User(
|
new_user = User(
|
||||||
username=username,
|
username=username, # type: ignore
|
||||||
password=generate_password_hash(password),
|
password=generate_password_hash(password), # type: ignore
|
||||||
is_admin=is_admin,
|
is_admin=is_admin,
|
||||||
)
|
)
|
||||||
db.session.add(new_user)
|
db.session.add(new_user)
|
||||||
@@ -61,10 +61,14 @@ def admin():
|
|||||||
def service():
|
def service():
|
||||||
service_form = ServiceForm()
|
service_form = ServiceForm()
|
||||||
|
|
||||||
if service_form.validate_on_submit():
|
if service_form.validate_on_submit(): # type: ignore
|
||||||
name = service_form.name.data
|
name = service_form.name.data
|
||||||
url = service_form.url.data
|
url = service_form.url.data
|
||||||
new_service = Service(name=name, url=url, user_id=current_user.id)
|
new_service = Service(
|
||||||
|
name=name, # type: ignore
|
||||||
|
url=url, # type: ignore
|
||||||
|
user_id=current_user.id,
|
||||||
|
)
|
||||||
db.session.add(new_service)
|
db.session.add(new_service)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from typing import Callable, Any
|
from typing import Callable, Any
|
||||||
from flask_login import current_user # type: ignore
|
from flask_login import current_user # type: ignore
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from flask import redirect, url_for, flash
|
from flask import redirect, url_for
|
||||||
|
|
||||||
|
|
||||||
def admin_required(f: Callable[..., Any]) -> Callable[..., Any]:
|
def admin_required(f: Callable[..., Any]) -> Callable[..., Any]:
|
||||||
@@ -10,7 +10,6 @@ def admin_required(f: Callable[..., Any]) -> Callable[..., Any]:
|
|||||||
if not current_user.is_authenticated:
|
if not current_user.is_authenticated:
|
||||||
return redirect(url_for("login"))
|
return redirect(url_for("login"))
|
||||||
if not current_user.is_admin:
|
if not current_user.is_admin:
|
||||||
flash("Admins only!")
|
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user