From 5c9aa1378f5a3ad9a8c1511ca50e7517dd84d3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20G=C3=BCtzkow?= <70779496+CJGutz@users.noreply.github.com> Date: Thu, 11 Apr 2024 00:11:53 +0200 Subject: [PATCH] use base detail view with deletion mixin to delete loan applications with translation --- inventory/locale/en/LC_MESSAGES/django.po | 10 +++++++++- inventory/locale/nb/LC_MESSAGES/django.po | 10 +++++++++- inventory/views/item_loan.py | 19 ++++++++----------- news/locale/en/LC_MESSAGES/django.po | 20 ++++++++------------ news/locale/nb/LC_MESSAGES/django.po | 16 ++++++++-------- 5 files changed, 42 insertions(+), 33 deletions(-) diff --git a/inventory/locale/en/LC_MESSAGES/django.po b/inventory/locale/en/LC_MESSAGES/django.po index 20b01934..5d9459d6 100644 --- a/inventory/locale/en/LC_MESSAGES/django.po +++ b/inventory/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-03 19:21+0200\n" +"POT-Creation-Date: 2024-04-11 00:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -141,3 +141,11 @@ msgstr "Loan applications" #: inventory/templates/inventory/loan_applications.html:8 msgid "Oversikt over lånesøknader" msgstr "Overview of loan applications" + +#: inventory/views/item_loan.py:107 +msgid "Lånesøknaden er avslått" +msgstr "Loan applications is denied" + +#: inventory/views/item_loan.py:124 +msgid "Lånesøknaden er lukket" +msgstr "Loan application is closed" diff --git a/inventory/locale/nb/LC_MESSAGES/django.po b/inventory/locale/nb/LC_MESSAGES/django.po index 071e077c..0ff2a267 100644 --- a/inventory/locale/nb/LC_MESSAGES/django.po +++ b/inventory/locale/nb/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-03 19:21+0200\n" +"POT-Creation-Date: 2024-04-11 00:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -136,3 +136,11 @@ msgstr "" #: inventory/templates/inventory/loan_applications.html:8 msgid "Oversikt over lånesøknader" msgstr "" + +#: inventory/views/item_loan.py:107 +msgid "Lånesøknaden er avslått" +msgstr "" + +#: inventory/views/item_loan.py:124 +msgid "Lånesøknaden er lukket" +msgstr "" diff --git a/inventory/views/item_loan.py b/inventory/views/item_loan.py index a61f1357..864cbdf9 100644 --- a/inventory/views/item_loan.py +++ b/inventory/views/item_loan.py @@ -7,13 +7,10 @@ from django.shortcuts import get_object_or_404 from django.urls import reverse, reverse_lazy from django.utils import timezone -from django.views.generic import ( - CreateView, - DeleteView, - DetailView, - ListView, - TemplateView, -) +from django.utils.translation import gettext as _ +from django.views.generic import CreateView, DetailView, ListView, TemplateView +from django.views.generic.dates import BaseDetailView +from django.views.generic.edit import DeletionMixin from inventory.models.item import Item from inventory.models.item_loan import ItemLoan @@ -97,12 +94,12 @@ def get(self, request, pk=None, **kwargs): ) -class ItemLoanDeclineView(PermissionRequiredMixin, DeleteView): +class ItemLoanDeclineView(BaseDetailView, PermissionRequiredMixin, DeletionMixin): """Endpoint for deleting/rejecting loans""" model = ItemLoan permission_required = "inventory.delete_itemloan" - success_message = "Lånesøknaden er avslått" + success_message = _("Lånesøknaden er avslått") success_url = reverse_lazy("inventory:loans") def get_success_url(self): @@ -114,12 +111,12 @@ def get(self, request, *args, **kwargs): return self.post(request, *args, **kwargs) -class ItemLoanReturnedView(PermissionRequiredMixin, DeleteView): +class ItemLoanReturnedView(BaseDetailView, PermissionRequiredMixin, DeletionMixin): """Endpoint for returning loans (deletes them)""" model = ItemLoan permission_required = "inventory.delete_itemloan" - success_message = "Lånesøknaden er lukket" + success_message = _("Lånesøknaden er lukket") success_url = reverse_lazy("inventory:loans") def get_success_url(self): diff --git a/news/locale/en/LC_MESSAGES/django.po b/news/locale/en/LC_MESSAGES/django.po index 2b306b8f..c206c967 100644 --- a/news/locale/en/LC_MESSAGES/django.po +++ b/news/locale/en/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-03 19:21+0200\n" +"POT-Creation-Date: 2024-04-11 00:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -259,31 +259,31 @@ msgstr "Done" msgid "Lagre og publiser arrangement" msgstr "Save and publish event" -#: news/templates/news/edit_event.html:269 +#: news/templates/news/edit_event.html:270 msgid "Kunne ikke hente flere resultater" msgstr "The results could not be loaded" -#: news/templates/news/edit_event.html:270 +#: news/templates/news/edit_event.html:271 msgid "Vennligst skriv inn flere tegn" msgstr "Please add more characters" -#: news/templates/news/edit_event.html:271 +#: news/templates/news/edit_event.html:272 msgid "Vennligst skriv inn færre tegn" msgstr "Please remove characters" -#: news/templates/news/edit_event.html:272 +#: news/templates/news/edit_event.html:273 msgid "Laster flere resultater" msgstr "Loading more results" -#: news/templates/news/edit_event.html:273 +#: news/templates/news/edit_event.html:274 msgid "Du kan ikke velge flere" msgstr "You cannot choose more" -#: news/templates/news/edit_event.html:274 +#: news/templates/news/edit_event.html:275 msgid "Ingen resultater" msgstr "No results found" -#: news/templates/news/edit_event.html:275 +#: news/templates/news/edit_event.html:276 msgid "Fjern alle" msgstr "Remove all" @@ -302,7 +302,6 @@ msgid "" msgstr "" "This event is open to all students regardless of Hackerspace membership" -#: news/templates/news/event.html:49 #: news/templates/news/event.html:49 msgid "Fra" msgstr "From" @@ -529,6 +528,3 @@ msgstr "Attendance Not Registered" #: news/templates/news/skills_form.html:87 msgid "Save" msgstr "Save" - -#~ msgid "Arrangementansvarlig" -#~ msgstr "Event organizer" diff --git a/news/locale/nb/LC_MESSAGES/django.po b/news/locale/nb/LC_MESSAGES/django.po index 0fd02f57..ccf69132 100644 --- a/news/locale/nb/LC_MESSAGES/django.po +++ b/news/locale/nb/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-03 19:21+0200\n" +"POT-Creation-Date: 2024-04-11 00:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -261,31 +261,31 @@ msgstr "" msgid "Lagre og publiser arrangement" msgstr "" -#: news/templates/news/edit_event.html:269 +#: news/templates/news/edit_event.html:270 msgid "Kunne ikke hente flere resultater" msgstr "" -#: news/templates/news/edit_event.html:270 +#: news/templates/news/edit_event.html:271 msgid "Vennligst skriv inn flere tegn" msgstr "" -#: news/templates/news/edit_event.html:271 +#: news/templates/news/edit_event.html:272 msgid "Vennligst skriv inn færre tegn" msgstr "" -#: news/templates/news/edit_event.html:272 +#: news/templates/news/edit_event.html:273 msgid "Laster flere resultater" msgstr "" -#: news/templates/news/edit_event.html:273 +#: news/templates/news/edit_event.html:274 msgid "Du kan ikke velge flere" msgstr "" -#: news/templates/news/edit_event.html:274 +#: news/templates/news/edit_event.html:275 msgid "Ingen resultater" msgstr "" -#: news/templates/news/edit_event.html:275 +#: news/templates/news/edit_event.html:276 msgid "Fjern alle" msgstr ""