Пример #1
0
 def move_to_slot_links(self, day, slot, gate):
     '''
     Returns the url to move the booking in this slot
     '''
     if not self.prenotazioni_view.is_valid_day(day):
         return []
     if self.prenotazioni_view.maximum_bookable_date:
         if day > self.prenotazioni_view.maximum_bookable_date.date():
             return []
     date = day.strftime("%Y-%m-%d")
     params = {
         'form.actions.move': 1,
         'data': self.request.form.get('data', ''),
         'form.gate': gate
     }
     times = slot.get_values_hr_every(300)
     urls = []
     base_url = "/".join((self.context.absolute_url(), 'prenotazione_move'))
     now_str = tznow().strftime("%Y-%m-%d %H:%M")
     for t in times:
         form_booking_date = " ".join((date, t))
         params['form.booking_date'] = form_booking_date
         urls.append({
             'title': t,
             'url': urlify(base_url, params=params),
             'class': t.endswith(':00') and 'oclock' or None,
             'future': (now_str <= form_booking_date),
         })
     return urls
 def move_to_slot_links(self, day, slot, gate):
     '''
     Returns the url to move the booking in this slot
     '''
     if not self.prenotazioni_view.is_valid_day(day):
         return []
     if self.prenotazioni_view.maximum_bookable_date:
         if day > self.prenotazioni_view.maximum_bookable_date.date():
             return []
     date = day.strftime("%Y-%m-%d")
     params = {'form.buttons.action_move': 'Move',
               'data': self.request.form.get('data', ''),
               'form.widgets.gate': gate}
     times = slot.get_values_hr_every(300)
     urls = []
     base_url = "/".join((self.context.absolute_url(),
                          'prenotazione_move'))
     now_str = tznow().strftime("%Y-%m-%d %H:%M")
     for t in times:
         form_booking_date = " ".join((date, t))
         params['form.widgets.booking_date'] = form_booking_date
         urls.append(
             {
                 'title': t,
                 'url': addTokenToUrl(urlify(base_url, params=params)),
                 'class': t.endswith(':00') and 'oclock' or None,
                 'future': (now_str <= form_booking_date),
             }
         )
     return urls
Пример #3
0
 def get_booking_urls(self, day, slot, slot_min_size=0):
     ''' Returns, if possible, the booking urls
     '''
     # we have some conditions to check
     if not self.is_valid_day(day):
         return []
     if self.maximum_bookable_date:
         if day > self.maximum_bookable_date.date():
             return []
     date = day.strftime("%Y-%m-%d")
     params = self.remembered_params.copy()
     times = slot.get_values_hr_every(300, slot_min_size=slot_min_size)
     base_url = self.base_booking_url
     urls = []
     now_str = tznow().strftime("%Y-%m-%d %H:%M")
     for t in times:
         form_booking_date = " ".join((date, t))
         params['form.booking_date'] = form_booking_date
         booking_date = DateTime(
             params['form.booking_date']).asdatetime()  # noqa
         urls.append({
             'title': t,
             'url': urlify(base_url, params=params),
             'class': t.endswith(':00') and 'oclock' or None,
             'booking_date': booking_date,
             'future': (now_str <= form_booking_date),
         })
     return urls
 def get_booking_urls(self, day, slot, slot_min_size=0):
     """ Returns, if possible, the booking urls
     """
     # we have some conditions to check
     if not self.is_valid_day(day):
         return []
     if self.maximum_bookable_date:
         if day > self.maximum_bookable_date.date():
             return []
     date = day.strftime("%Y-%m-%d")
     params = self.remembered_params.copy()
     times = slot.get_values_hr_every(300, slot_min_size=slot_min_size)
     base_url = self.base_booking_url
     urls = []
     now_str = tznow().strftime("%Y-%m-%d %H:%M")
     for t in times:
         form_booking_date = " ".join((date, t))
         params['form.booking_date'] = form_booking_date
         booking_date = DateTime(params['form.booking_date']).asdatetime()  # noqa
         urls.append(
             {
                 'title': t,
                 'url': urlify(base_url, params=params),
                 'class': t.endswith(':00') and 'oclock' or None,
                 'booking_date': booking_date,
                 'future': (now_str <= form_booking_date),
             }
         )
     return urls
Пример #5
0
    def maximum_bookable_date(self):
        ''' Return the maximum bookable date

        return a datetime or None
        '''
        future_days = self.context.getFutureDays()
        if not future_days:
            return
        date_limit = tznow() + timedelta(future_days)
        return date_limit
    def minimum_bookable_date(self):
        """ Return the minimum bookable date

        return a datetime or None
        """
        notbefore_days = self.context.getNotBeforeDays()
        if not notbefore_days:
            return
        date_limit = tznow() + timedelta(notbefore_days)
        return date_limit
    def maximum_bookable_date(self):
        """ Return the maximum bookable date

        return a datetime or None
        """
        future_days = self.context.getFutureDays()
        if not future_days:
            return
        date_limit = tznow() + timedelta(future_days)
        return date_limit
    def minimum_bookable_date(self):
        """ Return the minimum bookable date

        return a datetime or None
        """
        notbefore_days = self.context.getNotBeforeDays()
        if not notbefore_days:
            return
        date_limit = tznow() + timedelta(notbefore_days)
        return date_limit
Пример #9
0
def check_is_future_date(value):
    '''
    Check if this date is in the future
    '''
    if not value:
        return True
    now = tznow()

    if isinstance(value, datetime) and value >= now:
        return True
    raise IsNotfutureDate
 def exceedes_date_limit(self, data):
     '''
     Check if we can book this slot or is it too much in the future.
     '''
     future_days = self.context.getFutureDays()
     if not future_days:
         return False
     booking_date = data.get('booking_date', None)
     if not isinstance(booking_date, datetime):
         return False
     date_limit = tznow() + timedelta(future_days)
     if booking_date <= date_limit:
         return False
     return True
Пример #11
0
 def exceedes_date_limit(self, data):
     '''
     Check if we can book this slot or is it too much in the future.
     '''
     future_days = self.context.getFutureDays()
     if not future_days:
         return False
     booking_date = data.get('booking_date', None)
     if not isinstance(booking_date, datetime):
         return False
     date_limit = tznow() + timedelta(future_days)
     if booking_date <= date_limit:
         return False
     return True
Пример #12
0
def check_is_future_date(value):
    '''
    Check if this date is in the future
    '''
    if not value:
        return True

    if not value.tzinfo:
        value = pytz.utc.localize(value).replace(tzinfo=TZ)
    now = tznow()

    if isinstance(value, datetime) and value >= now:
        return True
    raise IsNotfutureDate