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

Merge branch 'fix-room-add' into 'main'

Fix room adding form

See merge request !140
parents 15e6489c 1bacaa70
No related branches found
No related tags found
No related merge requests found
...@@ -7,18 +7,20 @@ ...@@ -7,18 +7,20 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
{% bootstrap_javascript jquery='slim' %} {% bootstrap_javascript jquery='slim' %}
{% include "AKModel/load_fullcalendar_availabilities.html" %} {% if original.event %}
{% include "AKModel/load_fullcalendar_availabilities.html" %}
<script> <script>
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
createAvailabilityEditors( createAvailabilityEditors(
'{{ original.event.timezone }}', '{{ original.event.timezone }}',
'{{ LANGUAGE_CODE }}', '{{ LANGUAGE_CODE }}',
'{{ original.event.start | timezone:original.event.timezone | date:"Y-m-d H:i:s" }}', '{{ original.event.start | timezone:original.event.timezone | date:"Y-m-d H:i:s" }}',
'{{ original.event.end | timezone:original.event.timezone | date:"Y-m-d H:i:s" }}' '{{ original.event.end | timezone:original.event.timezone | date:"Y-m-d H:i:s" }}'
); );
}); });
</script> </script>
{% endif %}
{% endblock %} {% endblock %}
...@@ -586,25 +586,32 @@ class RoomBatchCreationView(EventSlugMixin, IntermediateAdminView): ...@@ -586,25 +586,32 @@ class RoomBatchCreationView(EventSlugMixin, IntermediateAdminView):
def form_valid(self, form): def form_valid(self, form):
from django.apps import apps from django.apps import apps
VIRTUAL_ROOMS_SUPPORT = False virtual_rooms_support = False
if apps.is_installed("AKOnline"):
VIRTUAL_ROOMS_SUPPORT = True
from AKOnline.models import VirtualRoom
created_count = 0 created_count = 0
rooms_raw_dict: csv.DictReader = form.cleaned_data["rooms"] rooms_raw_dict: csv.DictReader = form.cleaned_data["rooms"]
if apps.is_installed("AKOnline") and "url" in rooms_raw_dict.fieldnames:
virtual_rooms_support = True
from AKOnline.models import VirtualRoom
for raw_room in rooms_raw_dict: for raw_room in rooms_raw_dict:
name = raw_room["name"] name = raw_room["name"]
location = raw_room["location"] if "location" in rooms_raw_dict.fieldnames else "" location = raw_room["location"] if "location" in rooms_raw_dict.fieldnames else ""
capacity = raw_room["capacity"] if "capacity" in rooms_raw_dict.fieldnames else -1 capacity = raw_room["capacity"] if "capacity" in rooms_raw_dict.fieldnames else -1
url = raw_room["url"] if "url" in rooms_raw_dict.fieldnames else ""
try: try:
if VIRTUAL_ROOMS_SUPPORT and url != "": if virtual_rooms_support and raw_room["url"] != "":
VirtualRoom.objects.create(name=name, location=location, capacity=capacity, url=url, event=self.event) VirtualRoom.objects.create(name=name,
location=location,
capacity=capacity,
url=raw_room["url"],
event=self.event)
else: else:
Room.objects.create(name=name, location=location, capacity=capacity, event=self.event) Room.objects.create(name=name,
location=location,
capacity=capacity,
event=self.event)
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.
Finish editing this message first!
Please register or to comment