Certains ical annoncent une heure UTC mais sont en fait des heures Europe/Pari
This commit is contained in:
		@@ -145,6 +145,8 @@ def run_recurrent_import_internal(rimport, downloader, req_id):
 | 
			
		||||
        extractor = ICALNoBusyExtractor()
 | 
			
		||||
    elif rimport.processor == RecurrentImport.PROCESSOR.ICALNOVC:
 | 
			
		||||
        extractor = ICALNoVCExtractor()
 | 
			
		||||
    elif rimport.processor == RecurrentImport.PROCESSOR.ICALNAIVETZ:
 | 
			
		||||
        extractor = ICALNaiveTimezone()
 | 
			
		||||
    elif rimport.processor == RecurrentImport.PROCESSOR.LACOOPE:
 | 
			
		||||
        extractor = lacoope.CExtractor()
 | 
			
		||||
    elif rimport.processor == RecurrentImport.PROCESSOR.LACOMEDIE:
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ logger = get_task_logger(__name__)
 | 
			
		||||
class ICALExtractor(Extractor):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        super().__init__()
 | 
			
		||||
        self.naive_timezone = False
 | 
			
		||||
        self.to_timezone = pytz.timezone("Europe/Paris")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -54,7 +55,8 @@ class ICALExtractor(Extractor):
 | 
			
		||||
 | 
			
		||||
        if item is not None:
 | 
			
		||||
            if isinstance(item, datetime):
 | 
			
		||||
                item = self.to_timezone.normalize(item)
 | 
			
		||||
                if not self.naive_timezone:
 | 
			
		||||
                    item = self.to_timezone.normalize(item)
 | 
			
		||||
                day = item.date()
 | 
			
		||||
                time = item.time()
 | 
			
		||||
            elif isinstance(item, date):
 | 
			
		||||
@@ -290,3 +292,8 @@ class ICALNoVCExtractor(ICALExtractor):
 | 
			
		||||
            image,
 | 
			
		||||
            image_alt,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
class ICALNaiveTimezone(ICALExtractor):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        super().__init__()
 | 
			
		||||
        self.naive_timezone = True
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
# Generated by Django 4.2.9 on 2025-02-23 10:59
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('agenda_culturel', '0148_alter_recurrentimport_source'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AlterField(
 | 
			
		||||
            model_name='recurrentimport',
 | 
			
		||||
            name='processor',
 | 
			
		||||
            field=models.CharField(choices=[('ical', 'ical'), ('icalnobusy', 'ical no busy'), ('icalnovc', 'ical no VC'), ('ical naive tz', 'ical naive timezone'), ('lacoope', 'lacoope.org'), ('lacomedie', 'la comédie'), ('lefotomat', 'le fotomat'), ('lapucealoreille', "la puce à l'oreille"), ('Plugin wordpress MEC', 'Plugin wordpress MEC'), ('Facebook events', "Événements d'une page FB"), ('Billetterie CF', 'Billetterie Clermont-Ferrand'), ('arachnee', 'Arachnée concert'), ('rio', 'Le Rio'), ('raymonde', 'La Raymonde'), ('apidae', 'Agenda apidae tourisme'), ('iguana', 'Agenda iguana (médiathèques)'), ('Mille formes', 'Mille formes'), ('Amis cerises', 'Les Amis du Temps des Cerises'), ('Mobilizon', 'Mobilizon')], default='ical', max_length=20, verbose_name='Processor'),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -2147,6 +2147,7 @@ class RecurrentImport(models.Model):
 | 
			
		||||
        ICAL = "ical", _("ical")
 | 
			
		||||
        ICALNOBUSY = "icalnobusy", _("ical no busy")
 | 
			
		||||
        ICALNOVC = "icalnovc", _("ical no VC")
 | 
			
		||||
        ICALNAIVETZ = "ical naive tz", _("ical naive timezone")
 | 
			
		||||
        LACOOPE = "lacoope", _("lacoope.org")
 | 
			
		||||
        LACOMEDIE = "lacomedie", _("la comédie")
 | 
			
		||||
        LEFOTOMAT = "lefotomat", _("le fotomat")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user