mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 11:19:58 +00:00
More cleanup
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -22,13 +22,15 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="threeDotDropdown">
|
<ul class="dropdown-menu" aria-labelledby="threeDotDropdown">
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item" href="{{ url_for('dash.edit_service', service_id=service.id) }}">Edit</a>
|
<a class="dropdown-item"
|
||||||
|
href="{{ url_for('dash.edit_service', service_id=service.id) }}">Edit</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<form action="{{ url_for('dash.delete_item', service_id=service.id) }}" method="POST" style="display:inline;">
|
<form action="{{ url_for('dash.delete_service', service_id=service.id) }}" method="POST"
|
||||||
|
style="display:inline;">
|
||||||
<button style="color: red;" type="submit" class="dropdown-item">Delete</button>
|
<button style="color: red;" type="submit" class="dropdown-item">Delete</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ from flask_login import login_required, current_user # type: ignore
|
|||||||
from application.dash.models import Service
|
from application.dash.models import Service
|
||||||
from application.utils import saveImage
|
from application.utils import saveImage
|
||||||
|
|
||||||
|
# Dashboard blueprint
|
||||||
dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
|
dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
|
||||||
|
|
||||||
|
|
||||||
|
# index
|
||||||
@dash_blueprint.route("/", methods=["GET", "POST"])
|
@dash_blueprint.route("/", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def index():
|
def index():
|
||||||
@@ -17,9 +19,10 @@ def index():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dash_blueprint.route("/delete_item/<int:service_id>", methods=["POST"])
|
# Deleting a service
|
||||||
|
@dash_blueprint.route("/delete_service/<int:service_id>", methods=["POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def delete_item(service_id: int):
|
def delete_service(service_id: int):
|
||||||
service = Service.query.get_or_404(service_id)
|
service = Service.query.get_or_404(service_id)
|
||||||
|
|
||||||
# Check ownership
|
# Check ownership
|
||||||
@@ -31,9 +34,10 @@ def delete_item(service_id: int):
|
|||||||
return redirect(url_for("dash.index"))
|
return redirect(url_for("dash.index"))
|
||||||
|
|
||||||
|
|
||||||
|
# Add a service
|
||||||
@dash_blueprint.route("/service", methods=["GET", "POST"])
|
@dash_blueprint.route("/service", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def service():
|
def add_service():
|
||||||
service_form = ServiceForm()
|
service_form = ServiceForm()
|
||||||
|
|
||||||
if service_form.validate_on_submit(): # type: ignore
|
if service_form.validate_on_submit(): # type: ignore
|
||||||
@@ -63,6 +67,7 @@ def service():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Edit service
|
||||||
@dash_blueprint.route(
|
@dash_blueprint.route(
|
||||||
"/edit_service/<int:service_id>", methods=["GET", "POST"]
|
"/edit_service/<int:service_id>", methods=["GET", "POST"]
|
||||||
)
|
)
|
||||||
@@ -92,18 +97,3 @@ def edit_service(service_id: int):
|
|||||||
# 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)
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
def saveImage(image: ...):
|
|
||||||
filename = secure_filename(image.filename)
|
|
||||||
save_path = os.path.join(
|
|
||||||
app.config["UPLOAD_FOLDER"], # type: ignore
|
|
||||||
str(current_user.id),
|
|
||||||
filename,
|
|
||||||
)
|
|
||||||
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
|
||||||
image.save(save_path) # type: ignore
|
|
||||||
filename2 = str(current_user.id) + "/" + filename
|
|
||||||
return filename2
|
|
||||||
"""
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {% if active_page == 'service' %}active{% endif %}"
|
<a class="nav-link {% if active_page == 'service' %}active{% endif %}"
|
||||||
href="{{url_for('dash.service')}}">Add service</a>
|
href="{{url_for('dash.add_service')}}">Add service</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_user.is_admin %}
|
{% if current_user.is_admin %}
|
||||||
|
|||||||
Reference in New Issue
Block a user