--- /dev/null
+(function() {
+
+ function update_fuseau() {
+ var pays = $('select[name=pays]').val();
+ $('select[name=fuseau]').load('options_fuseau_horaire/?pays=' + pays);
+ }
+ $(document).ready(function() {
+ $('select[name=pays]').change(update_fuseau);
+ update_fuseau();
+ });
+})();
(function() {
- function getTimezoneName() {
- tmSummer = new Date(Date.UTC(2005, 6, 30, 0, 0, 0, 0));
- so = -1 * tmSummer.getTimezoneOffset();
- tmWinter = new Date(Date.UTC(2005, 12, 30, 0, 0, 0, 0));
- wo = -1 * tmWinter.getTimezoneOffset();
-
- if (-660 == so && -660 == wo) return 'Pacific/Midway';
- if (-600 == so && -600 == wo) return 'Pacific/Tahiti';
- if (-570 == so && -570 == wo) return 'Pacific/Marquesas';
- if (-540 == so && -600 == wo) return 'America/Adak';
- if (-540 == so && -540 == wo) return 'Pacific/Gambier';
- if (-480 == so && -540 == wo) return 'America/Anchorage';
- if (-480 == so && -480 == wo) return 'Pacific/Pitcairn';
- if (-420 == so && -480 == wo) return 'America/Vancouver';
- if (-420 == so && -420 == wo) return 'America/Phoenix';
- if (-360 == so && -420 == wo) return 'America/Edmonton';
- if (-360 == so && -360 == wo) return 'America/Guatemala';
- if (-360 == so && -300 == wo) return 'Pacific/Easter';
- if (-300 == so && -360 == wo) return 'America/Winnipeg';
- if (-300 == so && -300 == wo) return 'America/Bogota';
- if (-240 == so && -300 == wo) return 'America/Montreal';
- if (-240 == so && -240 == wo) return 'America/Caracas';
- if (-240 == so && -180 == wo) return 'America/Santiago';
- if (-180 == so && -240 == wo) return 'America/Moncton';
- if (-180 == so && -180 == wo) return 'America/Montevideo';
- if (-180 == so && -120 == wo) return 'America/Sao_Paulo';
- if (-150 == so && -210 == wo) return 'America/St_Johns';
- if (-120 == so && -180 == wo) return 'America/Godthab';
- if (-120 == so && -120 == wo) return 'America/Noronha';
- if (-60 == so && -60 == wo) return 'Atlantic/Cape_Verde';
- if (0 == so && -60 == wo) return 'Atlantic/Azores';
- if (0 == so && 0 == wo) return 'Africa/Casablanca';
- if (60 == so && 0 == wo) return 'Europe/London';
- if (60 == so && 60 == wo) return 'Africa/Algiers';
- if (60 == so && 120 == wo) return 'Africa/Windhoek';
- if (120 == so && 60 == wo) return 'Africa/Algiers';
- if (120 == so && 120 == wo) return 'Africa/Harare';
- if (180 == so && 120 == wo) return 'Africa/Cairo';
- if (180 == so && 180 == wo) return 'Africa/Nairobi';
- if (240 == so && 180 == wo) return 'Europe/Moscow';
- if (240 == so && 240 == wo) return 'Asia/Dubai';
- if (270 == so && 210 == wo) return 'Asia/Tehran';
- if (270 == so && 270 == wo) return 'Asia/Kabul';
- if (300 == so && 240 == wo) return 'Asia/Baku';
- if (300 == so && 300 == wo) return 'Asia/Karachi';
- if (330 == so && 330 == wo) return 'Asia/Kolkata';
- if (345 == so && 345 == wo) return 'Asia/Kathmandu';
- if (360 == so && 300 == wo) return 'Asia/Yekaterinburg';
- if (360 == so && 360 == wo) return 'Asia/Colombo';
- if (390 == so && 390 == wo) return 'Asia/Rangoon';
- if (420 == so && 360 == wo) return 'Asia/Almaty';
- if (420 == so && 420 == wo) return 'Asia/Bangkok';
- if (480 == so && 420 == wo) return 'Asia/Krasnoyarsk';
- if (480 == so && 480 == wo) return 'Australia/Perth';
- if (540 == so && 480 == wo) return 'Asia/Irkutsk';
- if (540 == so && 540 == wo) return 'Asia/Tokyo';
- if (570 == so && 570 == wo) return 'Australia/Darwin';
- if (570 == so && 630 == wo) return 'Australia/Adelaide';
- if (600 == so && 540 == wo) return 'Asia/Yakutsk';
- if (600 == so && 600 == wo) return 'Australia/Brisbane';
- if (600 == so && 660 == wo) return 'Australia/Sydney';
- if (630 == so && 660 == wo) return 'Australia/Lord_Howe';
- if (660 == so && 600 == wo) return 'Asia/Vladivostok';
- if (660 == so && 660 == wo) return 'Pacific/Guadalcanal';
- if (690 == so && 690 == wo) return 'Pacific/Norfolk';
- if (720 == so && 660 == wo) return 'Asia/Magadan';
- if (720 == so && 720 == wo) return 'Pacific/Fiji';
- if (720 == so && 780 == wo) return 'Pacific/Auckland';
- if (765 == so && 825 == wo) return 'Pacific/Chatham';
- if (780 == so && 780 == wo) return 'Pacific/Enderbury'
- if (840 == so && 840 == wo) return 'Pacific/Kiritimati';
- return 'GMT';
- }
-
$(document).ready(function() {
//Register review form submition function
$.datepicker.setDefaults($.datepicker.regional['fr']);
$('input:text.date').datepicker();
- // Sélectionner automatiquement le fuseau horaire
- $('select[name=fuseau]').each(function() {
- $(this).val(getTimezoneName())
- })
-
// S'assurer qu'on tient compte de ce qui se trouve dans le champ de
// recherche par mots-clés lorsqu'on choisit une région ou une
// discipline.
self.readonly_fields.append('listsets')
super(RecordAdmin, self).__init__(*args, **kwargs)
- # Recherche par mots-clés
+ def queryset(self, request):
+ return Record.all_objects.all()
# Présentation de l'information
list_display = ('titre', 'source', 'date', 'visible')
actions = ['rendre_visible', 'rendre_invisible', 'assigner_regions', 'assigner_disciplines']
+ def queryset(self, request):
+ return Actualite.all_objects.all()
+
# actions
def rendre_visible(self, request, queryset):
selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
list_filter = ('approuve', 'regions', 'discipline', 'discipline_secondaire')
list_display = ('titre', 'debut', 'fin', 'lieu', 'approuve')
fields = ['titre', 'discipline', 'discipline_secondaire', 'mots_cles',
- 'type', 'fuseau', 'debut', 'fin', 'lieu', 'piece_jointe', 'regions',
+ 'type', 'pays', 'fuseau', 'debut', 'fin', 'lieu', 'piece_jointe', 'regions',
'description', 'contact', 'url', 'approuve']
actions = ['assigner_regions', 'assigner_disciplines']
+ def queryset(self, request):
+ return Evenement.all_objects.all()
+
def assigner_regions(self, request, queryset):
selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
return HttpResponseRedirect(url('assigner_regions', kwargs=dict(app_name='savoirs', model_name='evenement')) + '?ids=' + ','.join(selected))
Q(titre__icontains=region.nom) |
Q(mots_cles__icontains=region.nom) |
Q(description__icontains=region.nom) |
+ Q(pays__region=region) |
Q(lieu__icontains=region.nom)).distinct()
-def build_time_zone_choices():
+def build_time_zone_choices(pays=None):
fr_names = set()
- tzones = []
+ timezones = pytz.country_timezones[pays] if pays else pytz.common_timezones
+ result = []
now = datetime.datetime.now()
- for tzname in pytz.common_timezones:
+ for tzname in timezones:
tz = pytz.timezone(tzname)
fr_name = get_timezone_name(tz, locale='fr_FR')
if fr_name in fr_names:
seconds = offset.seconds + offset.days * 86400
(hours, minutes) = divmod(seconds // 60, 60)
offset_str = 'UTC%+d:%d' % (hours, minutes) if minutes else 'UTC%+d' % hours
- tzones.append((seconds, tzname, '%s - %s' % (offset_str, fr_name)))
- tzones.sort()
- return [(tz[1], tz[2]) for tz in tzones]
+ result.append((seconds, tzname, '%s - %s' % (offset_str, fr_name)))
+ result.sort()
+ return [(x[1], x[2]) for x in result]
class Evenement(models.Model):
TYPE_CHOICES = ((u'Colloque', u'Colloque'),
lieu = models.TextField()
debut = models.DateTimeField(default=datetime.datetime.now)
fin = models.DateTimeField(default=datetime.datetime.now)
+ pays = models.ForeignKey(Pays, related_name='evenements', null=True, blank=True)
fuseau = models.CharField(max_length=100, choices=TIME_ZONE_CHOICES, verbose_name='fuseau horaire')
description = models.TextField(blank=True, null=True)
contact = models.TextField(blank=True, null=True)
# -*- encoding: utf-8 -*-
-import datetime, simplejson, copy, vobject
+import copy
+import pytz
+import simplejson
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import Context, RequestContext
from lib import sep
from lib.calendrier import evenements, evenement_info, combine
from savoirs.globals import configuration
+from savoirs.models import build_time_zone_choices
import backend_config
from forms import *
from models import *
return render_to_response(template, dict(form=form),
context_instance=RequestContext(request))
+def options_fuseau_horaire(request):
+ pays = request.GET.get('pays')
+ choices = build_time_zone_choices(request.GET.get('pays'))
+ if len(choices) > 1:
+ choices = [('', '---------')] + choices
+ return render_to_response('savoirs/options_fuseau_horaire.html', dict(choices=choices),
+ context_instance=RequestContext(request))
+
@login_required
def evenement_moderation(request):
events = Evenement.objects.filter(approuve = False)
evenement.save()
return HttpResponseRedirect(reverse('savoirs.views.evenement_moderation'))
-
@login_required
def json_get (request):
uri = request.GET.get ("uri")
--- /dev/null
+ALTER TABLE `savoirs_evenement` ADD COLUMN `pays_id` varchar(2);
{% block extra-script %}
{{ form.media.js }}
+<script type="text/javascript" src="{{ MEDIA_URL }}js/agenda.js"></script>
{% endblock %}
{% block extra-style %}
--- /dev/null
+{% for choice in choices %}
+<option value="{{ choice.0 }}">{{ choice.1 }}</option>
+{% endfor %}
(r'^agenda/evenements/moderer/$', 'savoirs.views.evenement_moderation'),
(r'^agenda/evenements/moderer/(.+)/accepter/$', 'savoirs.views.evenement_accepter'),
(r'^agenda/evenements/moderer/(.+)/refuser/$', 'savoirs.views.evenement_refuser'),
+ (r'^agenda/evenements/utilisation/$', 'savoirs.views.evenement_utilisation'),
+ (r'^agenda/evenements/creer/$', 'savoirs.views.evenement_ajout'),
+ (r'^agenda/evenements/creer/options_fuseau_horaire/$', 'savoirs.views.options_fuseau_horaire'),
# sous-menu droite
(r'^a-propos/$', 'savoirs.views.a_propos'),
(r'^accounts/change_password/$', 'chercheurs.views.change_password'),
(r'^accounts/send_password/$', 'chercheurs.views.send_password'),
- # agenda
- (r'^agenda/evenements/utilisation/$', 'savoirs.views.evenement_utilisation'),
- (r'^agenda/evenements/creer/$', 'savoirs.views.evenement_ajout'),
-
# section par discipline et/ou région
(r'^discipline/(?P<discipline>\d+)/', include(sep_patterns)),
(r'^region/(?P<region>\d+)/', include(sep_patterns)),
(r'^rss/(.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict':site_feeds}),
(r'^json/get/$', 'savoirs.views.json_get'),
(r'^json/set/$', 'savoirs.views.json_set'),
+
)
if settings.DEBUG: