0001-event-refresh-event-list-every-30s-40021.patch
chrono/manager/static/js/chrono_events.manager.js | ||
---|---|---|
1 |
function autorefresh() { |
|
2 |
var pathname = window.location.pathname.replace(/^\/+/, '/'); |
|
3 |
$.ajax({ |
|
4 |
url: pathname + '?ajax=true', |
|
5 |
success: function(html) { |
|
6 |
$('#event_details').html(html); |
|
7 |
}, |
|
8 |
}); |
|
9 |
} |
|
10 | ||
11 |
$(function() { |
|
12 |
/* refresh every 30 seconds (idle_id) after any user activity |
|
13 |
* on inactivity for more than 5 minutes (longidle_id), stop refreshing (clear idle_id) |
|
14 |
*/ |
|
15 |
var idle_id = null; |
|
16 |
var longidle_id = null; |
|
17 |
$(window).on('mousemove keydown mousedown touchstart', function() { |
|
18 |
/* if refresh timer exists, clear it */ |
|
19 |
if (idle_id) window.clearInterval(idle_id); |
|
20 |
/* if stop refreshing timer exists, clear it */ |
|
21 |
if (longidle_id) window.clearTimeout(longidle_id); |
|
22 |
/* launch timer to refresh every 30 seconds */ |
|
23 |
idle_id = setInterval(autorefresh, 30000); |
|
24 |
/* launch timer to stop refreshing after 5 minutes idle */ |
|
25 |
longidle_id = setTimeout(function () { |
|
26 |
if (idle_id) idle_id = window.clearInterval(idle_id); |
|
27 |
longidle_id = undefined; |
|
28 |
}, 300 * 1000); |
|
29 |
}); |
|
30 |
}); |
chrono/manager/templates/chrono/manager_event_detail.html | ||
---|---|---|
1 | 1 |
{% extends "chrono/manager_home.html" %} |
2 |
{% load i18n %} |
|
2 |
{% load staticfiles i18n %} |
|
3 | ||
4 |
{% block extrascripts %} |
|
5 |
{{ block.super }} |
|
6 |
<script src="{% static 'js/chrono_events.manager.js' %}"></script> |
|
7 |
{% endblock %} |
|
3 | 8 | |
4 | 9 |
{% block page-title-extra-label %} |
5 | 10 |
- {% firstof agenda.label object.label %} |
... | ... | |
24 | 29 |
{% endblock %} |
25 | 30 | |
26 | 31 |
{% block content %} |
27 | ||
28 |
{% if object.description or object.pricing or object.url %} |
|
29 |
<div class="section"> |
|
30 |
<div> |
|
31 |
{% if object.description %}<p>{{ object.description }}</p>{% endif %} |
|
32 |
{% if object.pricing %}<p>{% trans "Pricing:" %} {{ object.pricing }}</p>{% endif %} |
|
33 |
{% if object.url %}<p><a href="{{ object.url }}">{{ object.url|truncatechars:100 }}</a>{% endif %} |
|
32 |
<div id="event_details"> |
|
33 |
{% include "chrono/manager_event_detail_fragment.html" %} |
|
34 | 34 |
</div> |
35 |
</div> |
|
36 |
{% endif %} |
|
37 | ||
38 |
<div class="section"> |
|
39 |
<h3>{% trans "Bookings" %} ({{booked|length}}/{{object.places}})</h3> |
|
40 |
<div> |
|
41 | ||
42 |
{% if event.booked_places > event.places %} |
|
43 |
<div class="errornotice"><p>{% trans "This event is overbooked." %}</p></div> |
|
44 |
{% endif %} |
|
45 | ||
46 |
<ul class="objects-list single-links"> |
|
47 |
{% for booking in booked %} |
|
48 |
<li><a {% if booking.backoffice_url %}href="{{ booking.backoffice_url }}"{% endif %}>{% if booking.user_name %}{{ booking.user_name }}{% else %}{% trans "Unknown" %}{% endif %}, |
|
49 |
{{ booking.creation_datetime|date:"DATETIME_FORMAT" }}</a></li> |
|
50 |
{% endfor %} |
|
51 |
</ul> |
|
52 |
</div> |
|
53 |
</div> |
|
54 | ||
55 |
{% if object.waiting_list_places %} |
|
56 |
<div class="section"> |
|
57 |
<h3>{% trans "Waiting List" %} ({{waiting|length}}/{{object.waiting_list_places}})</h3> |
|
58 |
<div> |
|
59 |
<ul class="objects-list single-links"> |
|
60 |
{% for booking in waiting %} |
|
61 |
<li><a {% if booking.backoffice_url %}href="{{ booking.backoffice_url }}"{% endif %}>{% if booking.user_name %}{{ booking.user_name }}{% else %}{% trans "Unknown" %}{% endif %}, |
|
62 |
{{ booking.creation_datetime|date:"DATETIME_FORMAT" }}</a></li> |
|
63 |
{% endfor %} |
|
64 |
</ul> |
|
65 |
</div> |
|
66 |
</div> |
|
67 |
{% endif %} |
|
68 | 35 | |
69 | 36 |
{% endblock %} |
chrono/manager/templates/chrono/manager_event_detail_fragment.html | ||
---|---|---|
1 |
{% load i18n %} |
|
2 |
{% if object.description or object.pricing or object.url %} |
|
3 |
<div class="section"> |
|
4 |
<div> |
|
5 |
{% if object.description %}<p>{{ object.description }}</p>{% endif %} |
|
6 |
{% if object.pricing %}<p>{% trans "Pricing:" %} {{ object.pricing }}</p>{% endif %} |
|
7 |
{% if object.url %}<p><a href="{{ object.url }}">{{ object.url|truncatechars:100 }}</a>{% endif %} |
|
8 |
</div> |
|
9 |
</div> |
|
10 |
{% endif %} |
|
11 | ||
12 |
<div class="section"> |
|
13 |
<h3>{% trans "Bookings" %} ({{booked|length}}/{{object.places}})</h3> |
|
14 |
<div> |
|
15 | ||
16 |
{% if event.booked_places > event.places %} |
|
17 |
<div class="errornotice"><p>{% trans "This event is overbooked." %}</p></div> |
|
18 |
{% endif %} |
|
19 | ||
20 |
<ul class="objects-list single-links"> |
|
21 |
{% for booking in booked %} |
|
22 |
<li><a {% if booking.backoffice_url %}href="{{ booking.backoffice_url }}"{% endif %}>{% if booking.user_name %}{{ booking.user_name }}{% else %}{% trans "Unknown" %}{% endif %}, |
|
23 |
{{ booking.creation_datetime|date:"DATETIME_FORMAT" }}</a></li> |
|
24 |
{% endfor %} |
|
25 |
</ul> |
|
26 |
</div> |
|
27 |
</div> |
|
28 | ||
29 |
{% if object.waiting_list_places %} |
|
30 |
<div class="section"> |
|
31 |
<h3>{% trans "Waiting List" %} ({{waiting|length}}/{{object.waiting_list_places}})</h3> |
|
32 |
<div> |
|
33 |
<ul class="objects-list single-links"> |
|
34 |
{% for booking in waiting %} |
|
35 |
<li><a {% if booking.backoffice_url %}href="{{ booking.backoffice_url }}"{% endif %}>{% if booking.user_name %}{{ booking.user_name }}{% else %}{% trans "Unknown" %}{% endif %}, |
|
36 |
{{ booking.creation_datetime|date:"DATETIME_FORMAT" }}</a></li> |
|
37 |
{% endfor %} |
|
38 |
</ul> |
|
39 |
</div> |
|
40 |
</div> |
|
41 |
{% endif %} |
chrono/manager/views.py | ||
---|---|---|
704 | 704 | |
705 | 705 | |
706 | 706 |
class EventDetailView(ViewableAgendaMixin, DetailView): |
707 |
template_name = 'chrono/manager_event_detail.html' |
|
708 | 707 |
model = Event |
709 | 708 |
pk_url_kwarg = 'event_pk' |
710 | 709 | |
710 |
def get_template_names(self): |
|
711 |
if self.request.is_ajax(): |
|
712 |
return ['chrono/manager_event_detail_fragment.html'] |
|
713 |
return ['chrono/manager_event_detail.html'] |
|
714 | ||
711 | 715 |
def get_context_data(self, **kwargs): |
712 | 716 |
context = super(EventDetailView, self).get_context_data(**kwargs) |
713 | 717 |
context['user_can_manage'] = self.agenda.can_be_managed(self.request.user) |
714 |
- |