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()
|
||||
logout_user()
|
||||
flash("Password changed succesfully, please log back in")
|
||||
return redirect(url_for("auth.login"))
|
||||
return render_template("update_user.html", form=form, active_page="update")
|
||||
|
||||
@@ -104,6 +105,7 @@ def login():
|
||||
user.password, password # type: ignore
|
||||
):
|
||||
login_user(user) # type: ignore
|
||||
flash("Logged in succesfully")
|
||||
return redirect("/")
|
||||
else:
|
||||
feedback = "Username or password is incorrect"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 flask_login import current_user # type: ignore
|
||||
from application.dash.models import Service
|
||||
@@ -28,10 +28,12 @@ def delete_service(service_id: int):
|
||||
|
||||
# Check ownership
|
||||
if service.user_id != current_user.id:
|
||||
flash("This is not your service!")
|
||||
return redirect(url_for("dash.index"))
|
||||
|
||||
db.session.delete(service)
|
||||
db.session.commit()
|
||||
flash("Service deleted")
|
||||
return redirect(url_for("dash.index"))
|
||||
|
||||
|
||||
@@ -57,12 +59,8 @@ def add_service():
|
||||
) # type: ignore
|
||||
db.session.add(new_service)
|
||||
db.session.commit()
|
||||
return render_template(
|
||||
"add_service.html",
|
||||
form=ServiceForm(formdata=None),
|
||||
feedback="Service succesfully added",
|
||||
active_page="service",
|
||||
)
|
||||
flash("Service added")
|
||||
return redirect(url_for("dash.index"))
|
||||
return render_template(
|
||||
"add_service.html", form=service_form, active_page="service"
|
||||
)
|
||||
@@ -94,6 +92,7 @@ def edit_service(service_id: int):
|
||||
commit = True
|
||||
if commit:
|
||||
db.session.commit()
|
||||
flash("Service edited")
|
||||
return redirect(url_for("dash.index"))
|
||||
# Fill in correct data
|
||||
form = ServiceForm(name=service.name, url=service.url)
|
||||
|
||||
@@ -59,10 +59,19 @@
|
||||
</div>
|
||||
</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;">
|
||||
{% 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}}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user