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

more information in scheduling calendar

parent 95ee00c2
No related branches found
No related tags found
No related merge requests found
...@@ -245,6 +245,16 @@ class AK(models.Model): ...@@ -245,6 +245,16 @@ class AK(models.Model):
return self.short_name return self.short_name
return self.name return self.name
@property
def details(self):
return f"""{self.name}{" (R)" if self.reso else ""}:
{self.owners_list}
{_("Requirements")}: {", ".join(str(r) for r in self.requirements.all())}
{_("Conflicts")}: {", ".join(str(c) for c in self.conflicts.all())}
{_("Prerequisites")}: {", ".join(str(p) for p in self.prerequisites.all())}"""
@property @property
def owners_list(self): def owners_list(self):
return ", ".join(str(owner) for owner in self.owners.all()) return ", ".join(str(owner) for owner in self.owners.all())
......
...@@ -42,8 +42,8 @@ class EventsView(LoginRequiredMixin, EventSlugMixin, ListView): ...@@ -42,8 +42,8 @@ class EventsView(LoginRequiredMixin, EventSlugMixin, ListView):
return JsonResponse( return JsonResponse(
[{ [{
"slotID": slot.pk, "slotID": slot.pk,
"title": slot.ak.short_name, "title": f'{slot.ak.short_name}: \n{slot.ak.owners_list}',
"description": slot.ak.name, "description": slot.ak.details,
"resourceId": slot.room.id, "resourceId": slot.room.id,
"start": timezone.localtime(slot.start, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"), "start": timezone.localtime(slot.start, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"),
"end": timezone.localtime(slot.end, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"), "end": timezone.localtime(slot.end, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"),
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{% load static %} {% load static %}
{% load tags_AKPlan %} {% load tags_AKPlan %}
{% block title %}{% trans "Scheduling for" %} {{event}}{% endblock %} {% block title %}{% trans "Scheduling for" %} {{ event }}{% endblock %}
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
...@@ -21,10 +21,14 @@ ...@@ -21,10 +21,14 @@
{% endwith %} {% endwith %}
<style> <style>
.unscheduled-slot { .unscheduled-slot {
cursor: move; cursor: move;
} }
.fc-v-event, .tooltip {
white-space: pre-line;
}
</style> </style>
<script> <script>
...@@ -45,14 +49,16 @@ ...@@ -45,14 +49,16 @@
} }
return cookieValue; return cookieValue;
} }
const csrftoken = getCookie('csrftoken'); const csrftoken = getCookie('csrftoken');
function csrfSafeMethod(method) { function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection // these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
} }
$.ajaxSetup({ $.ajaxSetup({
beforeSend: function(xhr, settings) { beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) { if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken); xhr.setRequestHeader("X-CSRFToken", csrftoken);
} }
...@@ -64,7 +70,7 @@ ...@@ -64,7 +70,7 @@
var containerEl = document.getElementById('unscheduled-slots'); var containerEl = document.getElementById('unscheduled-slots');
new FullCalendar.Draggable(containerEl, { new FullCalendar.Draggable(containerEl, {
itemSelector: '.unscheduled-slot', itemSelector: '.unscheduled-slot',
}); });
// Calendar // Calendar
...@@ -72,7 +78,7 @@ ...@@ -72,7 +78,7 @@
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',
center: 'title', center: 'title',
right: 'resourceTimelineDayVert,resourceTimelineDayHoriz,resourceTimelineEventVert,resourceTimelineEventHoriz' right: 'resourceTimelineDayVert,resourceTimelineDayHoriz,resourceTimelineEventVert,resourceTimelineEventHoriz'
...@@ -115,12 +121,12 @@ ...@@ -115,12 +121,12 @@
} }
}, },
// Show full AK title as tooltip for each AK (needs to be removed and newly placed when AK is moved) // Show full AK title as tooltip for each AK (needs to be removed and newly placed when AK is moved)
eventDidMount : function(info) { eventDidMount: function (info) {
if(info.event.extendedProps.description !== undefined) { if (info.event.extendedProps.description !== undefined) {
$(info.el).tooltip({title: info.event.extendedProps.description, trigger: 'hover'}); $(info.el).tooltip({title: info.event.extendedProps.description, trigger: 'hover'});
} }
}, },
eventWillUnmount : function(info) { eventWillUnmount: function (info) {
$(info.el).tooltip('dispose'); $(info.el).tooltip('dispose');
}, },
...@@ -129,7 +135,7 @@ ...@@ -129,7 +135,7 @@
eventReceive: updateEvent, eventReceive: updateEvent,
editable: true, editable: true,
dropable: true, dropable: true,
drop: function(info) { drop: function (info) {
info.draggedEl.parentNode.removeChild(info.draggedEl); info.draggedEl.parentNode.removeChild(info.draggedEl);
}, },
allDaySlot: false, allDaySlot: false,
...@@ -140,9 +146,9 @@ ...@@ -140,9 +146,9 @@
resourceAreaHeaderContent: '{% trans "Room" %}', resourceAreaHeaderContent: '{% trans "Room" %}',
resources: '{% url "model:scheduling-resources-list" event_slug=event.slug %}', resources: '{% url "model:scheduling-resources-list" event_slug=event.slug %}',
eventSources: [ eventSources: [
'{% url "model:scheduling-events" event_slug=event.slug %}', '{% url "model:scheduling-events" event_slug=event.slug %}',
'{% url "model:scheduling-room-availabilities" event_slug=event.slug %}' '{% url "model:scheduling-room-availabilities" event_slug=event.slug %}'
], ],
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source', schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
dayMinWidth: 100, dayMinWidth: 100,
}); });
...@@ -160,10 +166,11 @@ ...@@ -160,10 +166,11 @@
end: plan.formatIso(changeInfo.event.end), end: plan.formatIso(changeInfo.event.end),
roomId: room.id, roomId: room.id,
}, },
success: function(response) {}, success: function (response) {
error: function(response) { },
error: function (response) {
changeInfo.revert(); changeInfo.revert();
alert("ERROR. Did not update "+changeInfo.event.title) alert("ERROR. Did not update " + changeInfo.event.title)
} }
}); });
} }
...@@ -181,7 +188,7 @@ ...@@ -181,7 +188,7 @@
{% for slot in slots_unscheduled %} {% for slot in slots_unscheduled %}
<div class="unscheduled-slot badge badge-primary" style='background-color: {{ slot.ak.category.color }}' <div class="unscheduled-slot badge badge-primary" style='background-color: {{ slot.ak.category.color }}'
data-event='{ "title": "{{ slot.ak.short_name }}", "duration": {"hours": "{{ slot.duration|unlocalize }}"}, "description": "{{ slot.ak.name }}", "slotID": "{{ slot.pk }}"}'>{{ slot.ak.short_name }} 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) ({{ slot.duration }} h)<br>{{ slot.ak.owners_list }}
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
......
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