def handleApply(self, action): data, errors = self.extractData() if errors: self.status = EditForm.formErrorsMessage return wrapper = getSAWrapper('gites_wallons') session = wrapper.session config = data.get('calendarConfig') all_hebs = getHebergementsForProprio( self.context, session, only_active=False, ) for heb in all_hebs: oldConfig = heb.heb_calendrier_proprio heb.heb_calendrier_proprio = config # mise à jour dernière date de modification du calendrier heb.heb_calendrier_proprio_date_maj = date.today() session.add(heb) if oldConfig != config: if config == u'non actif': hebBlockHist = HebergementBlockingHistory() hebBlockHist.heb_blockhistory_blocked_dte = date.today() hebBlockHist.heb_blockhistory_heb_pk = heb.heb_pk session.add(hebBlockHist) else: blockHist = self.getBlockedInfo(session, heb.heb_pk) if blockHist is not None: blockHist.heb_blockhistory_activated_dte = date.today() blockedDate = blockHist.heb_blockhistory_activated_dte - blockHist.heb_blockhistory_blocked_dte blockHist.heb_blockhistory_days = blockedDate.days session.add(blockHist) session.flush() session.expunge_all() self.status = ""
def isBlocked(self): """ See if proprio calendars are blocked (due to 40 days delay) """ cal = self.request.get('form.widgets.calendarConfig') if cal is not None: return (cal == ['bloque']) wrapper = getSAWrapper('gites_wallons') session = wrapper.session for heb in getHebergementsForProprio(self.context, session): if heb.heb_calendrier_proprio == 'bloque': return True return False
def hasActiveConfiguration(self): """ Does the proprio activated the calendar ? """ cal = self.request.get('form.widgets.calendarConfig') if cal is not None: if cal == ['non actif'] or cal == ['bloque']: return False else: return True wrapper = getSAWrapper('gites_wallons') session = wrapper.session for heb in getHebergementsForProprio(self.context, session): return (heb.heb_calendrier_proprio != 'non actif')