Revision 7ee2f91a
Added by Serghei Mihai over 11 years ago
calebasse/agenda/templates/agenda/ajax-ressource-disponibility-column.html | ||
---|---|---|
1 |
<tr><td class="ressource-{{ ressource_id }} agenda" data-id="{{ ressource_id }}">{{ initials }}</td></tr> |
|
2 |
{% for start_time, quarters in disponibility.items %} |
|
3 |
<tr> |
|
4 |
{% for quarter in quarters %} |
|
5 |
{% for value in quarter %} |
|
6 |
<td class="ressource-{{ value.id }} agenda {{ value.dispo }}" data-id="{{ value.id }}"></td> |
|
7 |
{% endfor %} |
|
8 |
{% endfor %} |
|
9 |
</tr> |
|
10 |
{% endfor %} |
calebasse/agenda/templates/agenda/ajax-worker-disponibility-column.html | ||
---|---|---|
1 |
<tr><td class="worker-{{ worker_id }} agenda" data-id="{{ worker_id }}">{{ initials }}</td></tr> |
|
2 |
{% for start_time, quarters in disponibility.items %} |
|
3 |
<tr> |
|
4 |
{% for quarter in quarters %} |
|
5 |
{% for value in quarter %} |
|
6 |
<td class="worker-{{ value.id }} agenda {{ value.dispo }}" data-id="{{ value.id }}"></td> |
|
7 |
{% endfor %} |
|
8 |
{% endfor %} |
|
9 |
</tr> |
|
10 |
{% endfor %} |
calebasse/agenda/urls.py | ||
---|---|---|
11 | 11 |
UnlockAllView, AgendasTherapeutesView, JoursNonVerrouillesView, |
12 | 12 |
RessourcesView, AjaxWorkerTabView, AjaxWorkerDisponibilityColumnView, |
13 | 13 |
DeleteOccurrenceView, DeleteEventView, UpdatePeriodicEventView, UpdatePeriodicAppointmentView, |
14 |
PeriodicEventsView) |
|
14 |
PeriodicEventsView, AjaxRessourceDisponibilityColumnView)
|
|
15 | 15 |
|
16 | 16 |
agenda_patterns = patterns('', |
17 | 17 |
url(r'^$', |
... | ... | |
74 | 74 |
url(r'^ajax-worker-disponibility-column/(?P<worker_id>\d+)$', |
75 | 75 |
AjaxWorkerDisponibilityColumnView.as_view(), |
76 | 76 |
name='ajax-worker-disponibility-column'), |
77 |
url(r'^ajax-ressource-disponibility-column/(?P<ressource_id>\d+)$', |
|
78 |
AjaxRessourceDisponibilityColumnView.as_view(), |
|
79 |
name='ajax-ressource-disponibility-column'), |
|
77 | 80 |
url(r'^rendez-vous-periodiques/$', |
78 | 81 |
PeriodicEventsView.as_view(), |
79 | 82 |
name='periodic-events'), |
calebasse/agenda/views.py | ||
---|---|---|
523 | 523 |
data = {'type': Room._meta.verbose_name_plural, 'ressources': Room.objects.all() } |
524 | 524 |
context['ressources_types'].append(data) |
525 | 525 |
ressources.extend(data['ressources']) |
526 |
context['disponibility_start_times'] = range(8, 20) |
|
526 | 527 |
|
527 | 528 |
events_ressources = {} |
528 | 529 |
for ressource in ressources: |
... | ... | |
583 | 584 |
|
584 | 585 |
class AjaxWorkerDisponibilityColumnView(TemplateView): |
585 | 586 |
|
586 |
template_name = 'agenda/ajax-worker-disponibility-column.html'
|
|
587 |
template_name = 'agenda/ajax-ressource-disponibility-column.html'
|
|
587 | 588 |
cookies_to_clear = [] |
588 | 589 |
|
589 | 590 |
def get_context_data(self, worker_id, **kwargs): |
... | ... | |
617 | 618 |
holidays_workers = {worker.id: holidays_worker} |
618 | 619 |
|
619 | 620 |
context['initials'] = worker.initials |
620 |
context['worker_id'] = worker.id
|
|
621 |
context['ressource_id'] = worker.id
|
|
621 | 622 |
context['disponibility'] = Event.objects.daily_disponibilities(self.date, |
622 | 623 |
events_workers, [worker], time_tables_workers, holidays_workers) |
623 | 624 |
return context |
624 | 625 |
|
626 |
class AjaxRessourceDisponibilityColumnView(AjaxWorkerDisponibilityColumnView): |
|
627 |
|
|
628 |
def get_context_data(self, ressource_id, **kwargs): |
|
629 |
context = {} |
|
630 |
ressource = Room.objects.get(pk = ressource_id) |
|
631 |
context = {'initials': ressource.name[:3], 'ressource_id': ressource.id} |
|
632 |
disponibility = dict() |
|
633 |
start_datetime = datetime.datetime(self.date.year, |
|
634 |
self.date.month, |
|
635 |
self.date.day, 8, 0) |
|
636 |
end_datetime = datetime.datetime(self.date.year, self.date.month, |
|
637 |
self.date.day, 8, 15) |
|
638 |
events = Event.objects.filter(room__id=ressource_id).today_occurrences(self.date) |
|
639 |
|
|
640 |
while (start_datetime.hour <= 19): |
|
641 |
if start_datetime.hour not in disponibility: |
|
642 |
disponibility[start_datetime.hour] = [[], [], [], []] |
|
643 |
quarter = 0 |
|
644 |
dispo = 'free' |
|
645 |
|
|
646 |
if events: |
|
647 |
event = events[0] |
|
648 |
|
|
649 |
if event.start_datetime <= start_datetime and event.end_datetime >= end_datetime: |
|
650 |
dispo = 'busy' |
|
651 |
|
|
652 |
disponibility[start_datetime.hour][quarter].append({'id': ressource_id, 'dispo': dispo}) |
|
653 |
quarter += 1 |
|
654 |
start_datetime += datetime.timedelta(minutes=15) |
|
655 |
end_datetime += datetime.timedelta(minutes=15) |
|
656 |
context['disponibility'] = disponibility |
|
657 |
return context |
|
658 |
|
|
625 | 659 |
|
626 | 660 |
class PeriodicEventsView(cbv.ListView): |
627 | 661 |
model = EventWithAct |
calebasse/static/js/calebasse.agenda.js | ||
---|---|---|
210 | 210 |
$('a.tab').each(function(a, b) { |
211 | 211 |
table_indexes.push($(b).data('id')); |
212 | 212 |
}); |
213 |
|
|
213 | 214 |
rows = $('td#dispos table tr'); |
214 | 215 |
for (var i=0; i<rows.length; i++) { |
215 | 216 |
tr = $(rows[i]); |
216 | 217 |
t = $.map(table_indexes, |
217 |
function(v, i) { return $('.worker-' + v, tr)[0]; }).filter(
|
|
218 |
function(v, i) { return $('.ressource-' + v, tr)[0]; }).filter(
|
|
218 | 219 |
function(a) { if (a) return true; return false; }); |
219 | 220 |
$('.agenda', tr).detach(); |
220 | 221 |
$(tr).append(t); |
... | ... | |
223 | 224 |
|
224 | 225 |
function toggle_ressource(ressource_selector, ressource) { |
225 | 226 |
|
226 |
var ressource_id = $(ressource_selector).data(ressource + '-id'); |
|
227 |
if (!ressource_id) { |
|
227 |
var ressource_id = $(ressource_selector).data(ressource + '-id');
|
|
228 |
if (!ressource_id) {
|
|
228 | 229 |
return; |
229 | 230 |
} |
230 | 231 |
|
... | ... | |
258 | 259 |
$(tab).detach().appendTo(tab_list); |
259 | 260 |
var url = $("#date-selector").data('url'); |
260 | 261 |
|
261 |
if ($('#tabs-' + ressource + '-' + ressource_id + ' .' + ressource + '-tab-content-placeholder').length) { |
|
262 |
/* load ressource appointments tab */ |
|
263 |
$('#tabs-' + ressource + '-' + ressource_id).load(url + 'ajax-' + ressource + '-tab/' + ressource_id, |
|
264 |
function () { |
|
265 |
$(this).children('div').accordion({active: false, autoHeight: false}); |
|
266 |
enable_events(this); |
|
267 |
} |
|
268 |
); |
|
269 |
/* load ressource disponibility column */ |
|
262 |
var tab_selector = ''; |
|
270 | 263 |
|
264 |
if (ressource == 'worker') { |
|
265 |
tab_selector = '#tabs-' + ressource + '-' + ressource_id + ' .' + ressource + '-tab-content-placeholder'; |
|
266 |
} else { |
|
267 |
tab_selector = '#selector-ressource-' + ressource_id + '.active'; |
|
268 |
url = url.split('/') |
|
269 |
url.splice(4, 1); |
|
270 |
url = url.join('/'); |
|
271 |
} |
|
272 |
|
|
273 |
if ($(tab_selector).length) { |
|
274 |
if(ressource == 'worker') { |
|
275 |
/* load ressource appointments tab */ |
|
276 |
$('#tabs-' + ressource + '-' + ressource_id).load(url + 'ajax-' + ressource + '-tab/' + ressource_id, |
|
277 |
function () { |
|
278 |
$(this).children('div').accordion({active: false, autoHeight: false}); |
|
279 |
enable_events(this); |
|
280 |
} |
|
281 |
); |
|
282 |
}; |
|
283 |
/* load ressource disponibility column */ |
|
271 | 284 |
$.get(url + 'ajax-' + ressource + '-disponibility-column/' + ressource_id, |
272 | 285 |
function(data) { |
273 | 286 |
var dispo_table_rows = $('td#dispos table tr'); |
287 |
all_td = $(data).find('td'); |
|
274 | 288 |
$(data).find('td').each(function(a, b) { |
275 |
$(dispo_table_rows[a]).append(b); |
|
276 |
} |
|
277 |
); |
|
278 |
reorder_disponibility_columns(); |
|
289 |
console.log(b); |
|
290 |
$(dispo_table_rows[a]).append(b); |
|
291 |
}); |
|
279 | 292 |
} |
280 | 293 |
); |
281 | 294 |
} else { |
282 |
reorder_disponibility_columns(); |
|
295 |
// remove hidden ressource availability |
|
296 |
$('td#dispos table tr td.ressource-' + ressource_id + '.agenda').remove(); |
|
283 | 297 |
} |
298 |
|
|
299 |
reorder_disponibility_columns(); |
|
284 | 300 |
return target.find('a.tab'); |
285 | 301 |
} |
286 | 302 |
|
Also available in: Unified diff
agenda: rooms availabilites displayed.
Closes #3690