mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 03:10:00 +00:00
Better flash msgs
This commit is contained in:
@@ -85,6 +85,7 @@ def update():
|
|||||||
)
|
)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
logout_user()
|
logout_user()
|
||||||
|
flash("Password changed succesfully, please log back in")
|
||||||
return redirect(url_for("auth.login"))
|
return redirect(url_for("auth.login"))
|
||||||
return render_template("update_user.html", form=form, active_page="update")
|
return render_template("update_user.html", form=form, active_page="update")
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ def login():
|
|||||||
user.password, password # type: ignore
|
user.password, password # type: ignore
|
||||||
):
|
):
|
||||||
login_user(user) # type: ignore
|
login_user(user) # type: ignore
|
||||||
|
flash("Logged in succesfully")
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
else:
|
else:
|
||||||
feedback = "Username or password is incorrect"
|
feedback = "Username or password is incorrect"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from application import db
|
from application import db
|
||||||
from flask import Blueprint, render_template, redirect, url_for
|
from flask import Blueprint, render_template, redirect, url_for, flash
|
||||||
from application.dash.forms import ServiceForm
|
from application.dash.forms import ServiceForm
|
||||||
from flask_login import current_user # type: ignore
|
from flask_login import current_user # type: ignore
|
||||||
from application.dash.models import Service
|
from application.dash.models import Service
|
||||||
@@ -28,10 +28,12 @@ def delete_service(service_id: int):
|
|||||||
|
|
||||||
# Check ownership
|
# Check ownership
|
||||||
if service.user_id != current_user.id:
|
if service.user_id != current_user.id:
|
||||||
|
flash("This is not your service!")
|
||||||
return redirect(url_for("dash.index"))
|
return redirect(url_for("dash.index"))
|
||||||
|
|
||||||
db.session.delete(service)
|
db.session.delete(service)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
flash("Service deleted")
|
||||||
return redirect(url_for("dash.index"))
|
return redirect(url_for("dash.index"))
|
||||||
|
|
||||||
|
|
||||||
@@ -57,12 +59,8 @@ def add_service():
|
|||||||
) # type: ignore
|
) # type: ignore
|
||||||
db.session.add(new_service)
|
db.session.add(new_service)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return render_template(
|
flash("Service added")
|
||||||
"add_service.html",
|
return redirect(url_for("dash.index"))
|
||||||
form=ServiceForm(formdata=None),
|
|
||||||
feedback="Service succesfully added",
|
|
||||||
active_page="service",
|
|
||||||
)
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"add_service.html", form=service_form, active_page="service"
|
"add_service.html", form=service_form, active_page="service"
|
||||||
)
|
)
|
||||||
@@ -94,7 +92,8 @@ def edit_service(service_id: int):
|
|||||||
commit = True
|
commit = True
|
||||||
if commit:
|
if commit:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("dash.index"))
|
flash("Service edited")
|
||||||
|
return redirect(url_for("dash.index"))
|
||||||
# Fill in correct data
|
# Fill in correct data
|
||||||
form = ServiceForm(name=service.name, url=service.url)
|
form = ServiceForm(name=service.name, url=service.url)
|
||||||
return render_template("edit_service.html", form=form)
|
return render_template("edit_service.html", form=form)
|
||||||
|
|||||||
@@ -59,10 +59,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="d-none">
|
||||||
|
<symbol id="check-circle-fill" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
|
||||||
|
</symbol>
|
||||||
|
</svg>
|
||||||
|
|
||||||
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1050;">
|
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1050;">
|
||||||
{% for message in get_flashed_messages() %}
|
{% for message in get_flashed_messages() %}
|
||||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
<svg class="bi flex-shrink-0 me-2" width="15" height="15" role="img" aria-label="Success:">
|
||||||
|
<use xlink:href="#check-circle-fill" />
|
||||||
|
</svg>
|
||||||
{{message}}
|
{{message}}
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user