add check for copy task for 1 month before
This commit is contained in:
@@ -45,9 +45,18 @@ class caldav_sync_manager(models.Model):
|
||||
|
||||
def init_task_management(self):
|
||||
today = datetime.now()
|
||||
|
||||
o_caldav_sync_management = caldav_sync_manager.objects.filter(dtDate=today.date())
|
||||
if not o_caldav_sync_management.exists():
|
||||
self.copy_caldav_data()
|
||||
self.copy_caldav_data(today)
|
||||
print(f"synced events")
|
||||
else:
|
||||
print("pas de copy, sync déjà fait")
|
||||
|
||||
last_month = today - relativedelta(months=1)
|
||||
o_caldav_sync_management = caldav_sync_manager.objects.filter(dtDate=last_month.date())
|
||||
if not o_caldav_sync_management.exists():
|
||||
self.copy_caldav_data(last_month)
|
||||
print(f"synced events")
|
||||
else:
|
||||
print("pas de copy, sync déjà fait")
|
||||
@@ -56,12 +65,12 @@ class caldav_sync_manager(models.Model):
|
||||
|
||||
|
||||
|
||||
def copy_caldav_data(self,):
|
||||
def copy_caldav_data(self, today):
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
today = datetime.now()
|
||||
|
||||
seeked_date = today + relativedelta(months=1)
|
||||
sync_date = today + relativedelta(months=1, days=1)
|
||||
modified_url = caldav_cfg["task_config"] + f"&start={int(today.timestamp())}&end={int(sync_date.timestamp())}&expand=1"
|
||||
|
Reference in New Issue
Block a user