Skip to content
Snippets Groups Projects
Commit ca468556 authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

Merge branch 'feature-auto-availabilites' into 'main'

Allow creating default availabilities in batch room import

Closes #175

See merge request !164
parents 3c3b1070 2af596ae
Branches
No related tags found
No related merge requests found
...@@ -140,6 +140,11 @@ class RoomBatchCreationForm(AdminIntermediateForm): ...@@ -140,6 +140,11 @@ class RoomBatchCreationForm(AdminIntermediateForm):
widget=forms.Textarea, widget=forms.Textarea,
required=True, required=True,
) )
create_default_availabilities = forms.BooleanField(
label=_('Default availabilities?'),
help_text=_('Create default availabilities for all rooms?'),
required=False
)
def clean_rooms(self): def clean_rooms(self):
rooms_raw_text = self.cleaned_data["rooms"] rooms_raw_text = self.cleaned_data["rooms"]
......
...@@ -2,7 +2,7 @@ msgid "" ...@@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-15 20:03+0200\n" "POT-Creation-Date: 2023-05-15 20:19+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -240,7 +240,15 @@ msgstr "" ...@@ -240,7 +240,15 @@ msgstr ""
"Spalten sind \"location\", \"capacity\", und \"url\" for Online-/" "Spalten sind \"location\", \"capacity\", und \"url\" for Online-/"
"HybridräumeTrennzeichen: Semikolon" "HybridräumeTrennzeichen: Semikolon"
#: AKModel/forms.py:149 #: AKModel/forms.py:144
msgid "Default availabilities?"
msgstr "Standardverfügbarkeiten?"
#: AKModel/forms.py:145
msgid "Create default availabilities for all rooms?"
msgstr "Standardverfügbarkeiten für alle Räume anlegen?"
#: AKModel/forms.py:154
msgid "CSV must contain a name column" msgid "CSV must contain a name column"
msgstr "CSV muss eine name-Spalte enthalten" msgstr "CSV muss eine name-Spalte enthalten"
...@@ -1227,26 +1235,26 @@ msgid "Updated {u} slot(s). created {c} new slot(s) and deleted {d} slot(s)" ...@@ -1227,26 +1235,26 @@ msgid "Updated {u} slot(s). created {c} new slot(s) and deleted {d} slot(s)"
msgstr "" msgstr ""
"{u} Slot(s) aktualisiert, {c} Slot(s) hinzugefügt und {d} Slot(s) gelöscht" "{u} Slot(s) aktualisiert, {c} Slot(s) hinzugefügt und {d} Slot(s) gelöscht"
#: AKModel/views/room.py:31 #: AKModel/views/room.py:32
#, python-format #, python-format
msgid "Created Room '%(room)s'" msgid "Created Room '%(room)s'"
msgstr "Raum '%(room)s' angelegt" msgstr "Raum '%(room)s' angelegt"
#: AKModel/views/room.py:37 AKModel/views/status.py:64 #: AKModel/views/room.py:38 AKModel/views/status.py:64
msgid "Import Rooms from CSV" msgid "Import Rooms from CSV"
msgstr "Räume aus CSV importieren" msgstr "Räume aus CSV importieren"
#: AKModel/views/room.py:68 #: AKModel/views/room.py:73
#, python-brace-format #, python-brace-format
msgid "Could not import room {name}: {e}" msgid "Could not import room {name}: {e}"
msgstr "Konnte Raum {name} nicht importieren: {e}" msgstr "Konnte Raum {name} nicht importieren: {e}"
#: AKModel/views/room.py:72 #: AKModel/views/room.py:77
#, python-brace-format #, python-brace-format
msgid "Imported {count} room(s)" msgid "Imported {count} room(s)"
msgstr "{count} Raum/Räume importiert" msgstr "{count} Raum/Räume importiert"
#: AKModel/views/room.py:74 #: AKModel/views/room.py:79
msgid "No rooms imported" msgid "No rooms imported"
msgstr "Keine Räume importiert" msgstr "Keine Räume importiert"
......
...@@ -8,6 +8,7 @@ from django.urls import reverse_lazy ...@@ -8,6 +8,7 @@ from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView from django.views.generic import CreateView
from AKModel.availability.models import Availability
from AKModel.forms import RoomForm, RoomBatchCreationForm from AKModel.forms import RoomForm, RoomBatchCreationForm
from AKModel.metaviews.admin import AdminViewMixin, EventSlugMixin, IntermediateAdminView from AKModel.metaviews.admin import AdminViewMixin, EventSlugMixin, IntermediateAdminView
from AKModel.models import Room from AKModel.models import Room
...@@ -37,10 +38,11 @@ class RoomBatchCreationView(EventSlugMixin, IntermediateAdminView): ...@@ -37,10 +38,11 @@ class RoomBatchCreationView(EventSlugMixin, IntermediateAdminView):
title = _("Import Rooms from CSV") title = _("Import Rooms from CSV")
def get_success_url(self): def get_success_url(self):
return reverse_lazy('admin:event_status', kwargs={'slug': self.event.slug}) return reverse_lazy('admin:event_status', kwargs={'event_slug': self.event.slug})
def form_valid(self, form): def form_valid(self, form):
virtual_rooms_support = False virtual_rooms_support = False
create_default_availabilities = form.cleaned_data["create_default_availabilities"]
created_count = 0 created_count = 0
rooms_raw_dict: csv.DictReader = form.cleaned_data["rooms"] rooms_raw_dict: csv.DictReader = form.cleaned_data["rooms"]
...@@ -62,6 +64,9 @@ class RoomBatchCreationView(EventSlugMixin, IntermediateAdminView): ...@@ -62,6 +64,9 @@ class RoomBatchCreationView(EventSlugMixin, IntermediateAdminView):
if virtual_rooms_support and raw_room["url"] != "": if virtual_rooms_support and raw_room["url"] != "":
VirtualRoom.objects.create(room=r, VirtualRoom.objects.create(room=r,
url=raw_room["url"]) url=raw_room["url"])
if create_default_availabilities:
a = Availability.with_event_length(event=self.event, room=r)
a.save()
created_count += 1 created_count += 1
except django.db.Error as e: except django.db.Error as e:
messages.add_message(self.request, messages.WARNING, messages.add_message(self.request, messages.WARNING,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment