Skip to content
Snippets Groups Projects
Commit 2ed7a465 authored by Benjamin Hättasch's avatar Benjamin Hättasch Committed by Nadja Geisler
Browse files

Scheduling: Allow to place previously unscheduled slots

parent 2750e2f8
No related branches found
No related tags found
1 merge request!53Drag and drop based plan for scheduling
Pipeline #8811 passed
...@@ -91,8 +91,8 @@ class EventSerializer(serializers.ModelSerializer): ...@@ -91,8 +91,8 @@ class EventSerializer(serializers.ModelSerializer):
roomId = serializers.IntegerField(source='room.pk') roomId = serializers.IntegerField(source='room.pk')
def update(self, instance, validated_data): def update(self, instance, validated_data):
start = timezone.make_aware(timezone.make_naive(validated_data.get('start', instance.start)), instance.event.timezone) start = timezone.make_aware(timezone.make_naive(validated_data.get('start')), instance.event.timezone)
end = timezone.make_aware(timezone.make_naive(validated_data.get('end', instance.end)), instance.event.timezone) end = timezone.make_aware(timezone.make_naive(validated_data.get('end')), instance.event.timezone)
instance.start = start instance.start = start
instance.room = get_object_or_404(Room, pk=validated_data.get('room')["pk"]) instance.room = get_object_or_404(Room, pk=validated_data.get('room')["pk"])
diff = end - start diff = end - start
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
{% load tags_AKModel %} {% load tags_AKModel %}
{% load i18n %} {% load i18n %}
{% load l10n %}
{% load tz %} {% load tz %}
{% load static %} {% load static %}
{% load tags_AKPlan %} {% load tags_AKPlan %}
...@@ -19,6 +20,13 @@ ...@@ -19,6 +20,13 @@
<script src="{% static locale_file %}"></script> <script src="{% static locale_file %}"></script>
{% endwith %} {% endwith %}
<style>
.unscheduled-slot {
cursor: move;
}
</style>
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
// CSRF Protection/Authentication // CSRF Protection/Authentication
...@@ -62,7 +70,7 @@ ...@@ -62,7 +70,7 @@
// Calendar // Calendar
var planEl = document.getElementById('planCalendar'); var planEl = document.getElementById('planCalendar');
var plan = new FullCalendar.Calendar(planEl, { plan = new FullCalendar.Calendar(planEl, {
timeZone: '{{ event.timezone }}', timeZone: '{{ event.timezone }}',
headerToolbar : { headerToolbar : {
left: 'today prev,next', left: 'today prev,next',
...@@ -118,7 +126,12 @@ ...@@ -118,7 +126,12 @@
// React to event changes (moving or change of duration) // React to event changes (moving or change of duration)
eventChange: updateEvent, eventChange: updateEvent,
eventReceive: updateEvent,
editable: true, editable: true,
dropable: true,
drop: function(info) {
info.draggedEl.parentNode.removeChild(info.draggedEl);
},
allDaySlot: false, allDaySlot: false,
nowIndicator: true, nowIndicator: true,
eventTextColor: '#fff', eventTextColor: '#fff',
...@@ -160,7 +173,17 @@ ...@@ -160,7 +173,17 @@
{% block content %} {% block content %}
<div id="planCalendar" style="margin-bottom: 50px;"></div> <div class="row" style="margin-bottom: 50px;">
<div class="col-md-10 col-lg-11">
<div id="planCalendar" ></div>
</div>
<div class="col-md-2 col-lg-1" id="unscheduled-slots">
{% for slot in slots_unscheduled %}
<div class="unscheduled-slot badge badge-primary" data-event='{ "title": "{{ slot.ak.short_name }}", "duration": {"hours": "{{ slot.duration|unlocalize }}"}, "description": "{{ slot.ak.name }}", "slotID": "{{ slot.pk }}"}'>{{ slot.ak.short_name }} ({{ slot.duration }} h)</div>
{% endfor %}
</div>
</div>
<a href="{% url 'admin:event_status' event.slug %}">{% trans "Event Status" %}</a> <a href="{% url 'admin:event_status' event.slug %}">{% trans "Event Status" %}</a>
{% endblock %} {% endblock %}
...@@ -23,7 +23,10 @@ class UnscheduledSlotsAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView ...@@ -23,7 +23,10 @@ class UnscheduledSlotsAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView
class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView): class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
template_name = "admin/AKScheduling/scheduling.html" template_name = "admin/AKScheduling/scheduling.html"
model = AKSlot model = AKSlot
context_object_name = "akslots" context_object_name = "slots_unscheduled"
def get_queryset(self):
return super().get_queryset().filter(start__isnull=True)
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs) context = super().get_context_data(object_list=object_list, **kwargs)
......
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