Compare commits

...

2 Commits

Author SHA1 Message Date
Lukáš Kucharczyk 6f1886bca2
finish purchase from list
Django CI/CD / test (push) Successful in 1m23s Details
Django CI/CD / build-and-push (push) Successful in 2m4s Details
2024-09-10 15:04:18 +02:00
Lukáš Kucharczyk 37169c4f9b
align last column to the right 2024-09-10 15:00:27 +02:00
5 changed files with 39 additions and 1 deletions

View File

@ -3188,6 +3188,10 @@ textarea:disabled:is(.dark *) {
border-end-end-radius: 0.5rem;
}
.\[\&_\:last-child\]\:text-right :last-child {
text-align: right;
}
.\[\&_a\]\:underline a {
text-decoration-line: underline;
}
@ -3203,3 +3207,7 @@ textarea:disabled:is(.dark *) {
.\[\&_h1\]\:mb-2 h1 {
margin-bottom: 0.5rem;
}
.\[\&_td\]\:last-of-type\:text-right:last-of-type td {
text-align: right;
}

View File

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
viewBox="0 0 48 48"
class="text-black dark:text-white w-4 h-4">
<path fill="currentColor" d="M 43.470703 8.9863281 A 1.50015 1.50015 0 0 0 42.439453 9.4394531 L 16.5 35.378906 L 5.5605469 24.439453 A 1.50015 1.50015 0 1 0 3.4394531 26.560547 L 15.439453 38.560547 A 1.50015 1.50015 0 0 0 17.560547 38.560547 L 44.560547 11.560547 A 1.50015 1.50015 0 0 0 43.470703 8.9863281 z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 477 B

View File

@ -1,4 +1,4 @@
<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 [&_a]:underline [&_a]:underline-offset-4 [&_a]:decoration-2">
<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 [&_a]:underline [&_a]:underline-offset-4 [&_a]:decoration-2 [&_:last-child]:text-right">
{% if slot %}
{{ slot }}
{% else %}

View File

@ -54,6 +54,11 @@ urlpatterns = [
purchase.delete_purchase,
name="delete_purchase",
),
path(
"purchase/<int:purchase_id>/finish",
purchase.finish_purchase,
name="finish_purchase",
),
path(
"purchase/list",
purchase.list_purchases,

View File

@ -103,6 +103,15 @@ def list_purchases(request: HttpRequest) -> HttpResponse:
"cotton/button_group.html",
{
"buttons": [
{
"href": reverse(
"finish_purchase", args=[purchase.pk]
),
"slot": Icon("checkmark"),
"title": "Mark as finished",
}
if not purchase.date_finished
else {},
{
"href": reverse(
"drop_purchase", args=[purchase.pk]
@ -223,6 +232,14 @@ def refund_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
return redirect("list_purchases")
@login_required
def finish_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
purchase = get_object_or_404(Purchase, id=purchase_id)
purchase.date_finished = timezone.now()
purchase.save()
return redirect("list_purchases")
def related_purchase_by_edition(request: HttpRequest) -> HttpResponse:
edition_id = request.GET.get("edition")
if not edition_id: