Merge branch 'new-team-number'
This commit is contained in:
@@ -8,6 +8,7 @@ class InitTaskSync(CronJobBase):
|
||||
RUN_EVERY_MIN = 1
|
||||
|
||||
schedule = Schedule(run_at_times=RUN_AT_TIMES,)
|
||||
#schedule = Schedule(run_every_mins=RUN_EVERY_MIN,)
|
||||
code = 'reskreen.init_sync_task' # Un code unique pour votre tâche cron
|
||||
|
||||
def do(self):
|
||||
|
@@ -45,23 +45,33 @@ 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")
|
||||
print("Aujourd'hui: pas de copy, sync déjà fait")
|
||||
|
||||
last_month = today - relativedelta(months=1)
|
||||
print(f"test du mois précédant: {last_month.strftime("%d/%m/%Y")}")
|
||||
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("Mois précédant: pas de copy, sync déjà fait")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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"
|
||||
|
@@ -8,6 +8,12 @@ BASES_CHOICES = [
|
||||
('1', 'Monthey'),
|
||||
('2', 'Uvrier'),
|
||||
]
|
||||
TEAM_NUMBER = [
|
||||
('1', 'Équipe 1'),
|
||||
('2', 'Equipe 2'),
|
||||
('3', 'Equipe 3'),
|
||||
('4', 'Equipe 4'),
|
||||
]
|
||||
STATUS_CHOICES = [
|
||||
('1', 'Opérationnel'),
|
||||
('2', 'Réserve'),
|
||||
@@ -33,6 +39,7 @@ class Vehicles(models.Model):
|
||||
nType = models.CharField('Type', max_length=1, choices=VHC_CHOICES, default=1)
|
||||
bLucas = models.BooleanField("Lucas", default=0)
|
||||
nOrder = models.IntegerField("Ordre", default=0)
|
||||
nTeam = models.CharField('Équipe', max_length=1, choices=TEAM_NUMBER, default=1)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
Reference in New Issue
Block a user