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

Merge branch 'feature-plan-new-akslots' into 'main'

Allow AKSlot creation via scheduler

Closes #120

See merge request !145
parents 94aa9fd0 d987b13d
No related branches found
No related tags found
1 merge request!145Allow AKSlot creation via scheduler
Pipeline #119553 passed
...@@ -133,7 +133,8 @@ class RoomViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelMix ...@@ -133,7 +133,8 @@ class RoomViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelMix
return Room.objects.filter(event=self.event) return Room.objects.filter(event=self.event)
class AKSlotViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet): class AKSlotViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.CreateModelMixin, mixins.UpdateModelMixin,
mixins.ListModelMixin, viewsets.GenericViewSet):
permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,) permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
serializer_class = AKSlotSerializer serializer_class = AKSlotSerializer
......
...@@ -134,9 +134,19 @@ ...@@ -134,9 +134,19 @@
eventChange: updateEvent, eventChange: updateEvent,
eventReceive: updateEvent, eventReceive: updateEvent,
editable: true, editable: true,
selectable: true,
drop: function (info) { drop: function (info) {
info.draggedEl.parentNode.removeChild(info.draggedEl); info.draggedEl.parentNode.removeChild(info.draggedEl);
}, },
select: function (info) {
console.log(info);
$('#id_start').val(info.startStr);
$('#id_end').val(info.endStr);
$('#id_room').val(info.resource._resource.id);
$('#id_duration').val(Math.abs(info.end-info.start)/1000/60/60);
$('#id_ak').val("");
$('#newAKSlotModal').modal('show');
},
allDaySlot: false, allDaySlot: false,
nowIndicator: true, nowIndicator: true,
now: "{% timestamp_now event.timezone %}", now: "{% timestamp_now event.timezone %}",
...@@ -232,11 +242,63 @@ ...@@ -232,11 +242,63 @@
} }
reloadBtn.click(reload); reloadBtn.click(reload);
function addSlot() {
let ak = $('#id_ak').val();
if(ak === "") {
alert("{% trans "Bitte AK auswählen" %}");
}
else {
$.ajax({
url: "{% url "model:AKSlot-list" event_slug=event.slug %}",
type: 'POST',
data: {
start: $('#id_start').val(),
duration: $('#id_duration').val(),
room: $('#id_room').val(),
ak: ak,
event: "{{ event.pk }}"
},
success: function (response) {
$('#newAKSlotModal').modal('hide');
reload();
},
error: function (response) {
console.error(response);
alert("{% trans 'Could not create slot' %}");
}
});
}
}
$('#newAKSlotModalSubmitButton').click(addSlot);
}); });
</script> </script>
</head> </head>
<body> <body>
<div class="modal" id="newAKSlotModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Add slot" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
{% bootstrap_form akSlotAddForm %}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="newAKSlotModalSubmitButton">{% trans "Add" %}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Cancel" %}</button>
</div>
</div>
</div>
</div>
<div class="box p-3"> <div class="box p-3">
<div class="row header pb-2"> <div class="row header pb-2">
<div class="col"> <div class="col">
......
...@@ -8,6 +8,7 @@ from django.views.generic import ListView, DetailView, UpdateView ...@@ -8,6 +8,7 @@ from django.views.generic import ListView, DetailView, UpdateView
from AKModel.models import AKSlot, AKTrack, Event, AK, AKCategory from AKModel.models import AKSlot, AKTrack, Event, AK, AKCategory
from AKModel.views import AdminViewMixin, FilterByEventSlugMixin, EventSlugMixin, IntermediateAdminView from AKModel.views import AdminViewMixin, FilterByEventSlugMixin, EventSlugMixin, IntermediateAdminView
from AKScheduling.forms import AKInterestForm from AKScheduling.forms import AKInterestForm
from AKSubmission.forms import AKAddSlotForm
class UnscheduledSlotsAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView): class UnscheduledSlotsAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
...@@ -40,6 +41,8 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView): ...@@ -40,6 +41,8 @@ class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
context["start"] = self.event.start context["start"] = self.event.start
context["end"] = self.event.end context["end"] = self.event.end
context["akSlotAddForm"] = AKAddSlotForm(self.event)
return context return context
......
...@@ -186,3 +186,14 @@ class AKOrgaMessageForm(forms.ModelForm): ...@@ -186,3 +186,14 @@ class AKOrgaMessageForm(forms.ModelForm):
'event': forms.HiddenInput, 'event': forms.HiddenInput,
'text': forms.Textarea, 'text': forms.Textarea,
} }
class AKAddSlotForm(forms.Form):
start = forms.CharField(label=_("Start"), disabled=True)
end = forms.CharField(label=_("End"), disabled=True)
duration = forms.CharField(label=_("Duration"), disabled=True)
room = forms.IntegerField(label=_("Room"), disabled=True)
def __init__(self, event):
super().__init__()
self.fields['ak'] = forms.ModelChoiceField(event.ak_set.all(), label=_("AK"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment