Skip to content
Snippets Groups Projects
Commit 023cf9af authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

delete view

parent 2301b2dc
No related branches found
No related tags found
1 merge request!9Release
Pipeline #14977 passed
......@@ -667,9 +667,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001481",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001481.tgz",
"integrity": "sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==",
"version": "1.0.30001547",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001547.tgz",
"integrity": "sha512-W7CrtIModMAxobGhz8iXmDfuJiiKg1WADMO/9x7/CLNin5cpSbuBjooyoIUVB5eyCc36QuTVlkVa1iB2S5+/eA==",
"funding": [
{
"type": "opencollective",
......@@ -1627,9 +1627,15 @@
}
},
"node_modules/nanoid": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
"integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
"integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"bin": {
"nanoid": "bin/nanoid.cjs"
},
......@@ -1814,9 +1820,9 @@
}
},
"node_modules/postcss": {
"version": "8.4.21",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz",
"integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==",
"version": "8.4.31",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
"integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==",
"funding": [
{
"type": "opencollective",
......@@ -1825,10 +1831,14 @@
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"dependencies": {
"nanoid": "^3.3.4",
"nanoid": "^3.3.6",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
},
......
{% extends "shared/base.html" %}
{% load render_bundle from webpack_loader %}
{% block title %}Časovače{% endblock %}
{% block header_name %}Časovače{% endblock %}
{% block description %}{% endblock %}
{% block head %}
<link
rel="stylesheet"
href="https://styleguide.pirati.cz/2.12.x/css/styles.css"
>
{% render_bundle "timer" %}
{% endblock %}
{% block content %}
<main>
<h1 class="text-6xl font-bebas">Odstranění časovače {{ timer.name }}</h1>
<div class="prose mb-4">
Skutečně chceš odstranit časovač {{ timer.name }}? Tento krok nelze vrátit zpět.
</div>
<div class="flex gap-2">
<a
class="btn btn--icon btn--black"
href="{% url 'timer:edit_timer' timer.id %}"
>
<div class="btn__body-wrap">
<div class="btn__body">Zrušit</div>
<div class="btn__icon">
<i class="ico--cross"></i>
</div>
</div>
</a>
<form method="post">
{% csrf_token %}
<button
class="btn btn--icon btn--red-600"
href="{% url 'timer:edit_timer' timer.id %}"
>
<div class="btn__body-wrap">
<div class="btn__body">Smazat</div>
<div class="btn__icon">
<i class="ico--checkmark"></i>
</div>
</div>
</a>
</form>
</div>
</main>
{% endblock %}
......@@ -77,6 +77,15 @@
<div class="btn__body">Aktualizovat čas</div>
</button>
</div>
<a
id="delete-timer"
class="btn btn--red-600 w-64"
role="button"
href="{% url 'timer:delete_timer' timer.id %}"
>
<div class="btn__body">Smazat časovač</div>
</a>
</div>
</main>
{% endblock %}
......@@ -8,4 +8,5 @@ urlpatterns = [
path("novy", views.create, name="create"),
path("<int:id>", views.view_timer, name="view_timer"),
path("<int:id>/uprava", views.edit_timer, name="edit_timer"),
path("<int:id>/smazat", views.delete_timer, name="delete_timer"),
]
......@@ -20,7 +20,6 @@ def create(request):
if form.is_valid():
timer = OngoingTimer(
hours=form.cleaned_data["hours"],
minutes=form.cleaned_data["minutes"],
seconds=form.cleaned_data["seconds"],
name=form.cleaned_data["name"],
......@@ -44,3 +43,13 @@ def edit_timer(request, id: int):
timer = get_object_or_404(OngoingTimer, id=id)
return render(request, "timer/edit_timer.html", {"timer": timer})
def delete_timer(request, id: int):
timer = get_object_or_404(OngoingTimer, id=id)
if request.method == "POST":
timer.delete()
return redirect("timer:index")
return render(request, "timer/delete_timer.html", {"timer": timer})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment