Example #1
0
    def run_reserve(self,
                    data,
                    approve_manually,
                    start=None,
                    end=None,
                    group=None,
                    quota=1,
                    dates=None):

        assert (start and end) or group or dates
        assert not (start and end and group and dates)

        email = self.email(data)
        additional_data = self.additional_data(data, add_manager_defaults=True)
        session_id = self.session_id()

        # only store forms defined in the formsets list
        if not self.context.formsets:
            additional_data = {}
        else:
            additional_data = dict((form, additional_data[form])
                                   for form in self.context.formsets
                                   if form in additional_data)

        run_pre_reserve_script(self.context, start, end, additional_data)

        def run():
            if start and end:
                return self.scheduler.reserve(email, (start, end),
                                              data=additional_data,
                                              session_id=session_id,
                                              quota=quota)
            elif group:
                return self.scheduler.reserve(email,
                                              group=group,
                                              data=additional_data,
                                              session_id=session_id,
                                              quota=quota)
            else:
                return self.scheduler.reserve(email,
                                              dates,
                                              data=additional_data,
                                              session_id=session_id,
                                              quota=quota)

        token = throttled(run, 'reserve')()

        if not approve_manually:
            self.scheduler.approve_reservations(token)

        self.flash(
            _(u'Added reservation to your list. '
              u'You have 15 minutes to confirm your reservations.'))
Example #2
0
    def run_reserve(
            self, data, approve_manually, dates=None, group=None, quota=1,
            rrule=None, description=None
    ):

        assert dates or group
        assert not (dates and group)

        email = self.email(data)
        session_id = self.session_id()

        additional_data = self.additional_data(data, add_manager_defaults=True)

        # only store forms defined in the formsets list
        additional_data = dict(
            (
                form, additional_data[form]
            ) for form in self.context.formsets if form in additional_data
        )

        if dates:
            for start, end in utils.pairs(dates):
                run_pre_reserve_script(
                    self.context, start, end, additional_data
                )
        else:
            run_pre_reserve_script(self.context, None, None, additional_data)

        def run():
            if dates:
                return self.scheduler.reserve(
                    email, dates, data=additional_data,
                    session_id=session_id, quota=quota, rrule=rrule,
                    description=description
                )
            else:
                return self.scheduler.reserve(
                    email, group=group,
                    data=additional_data, session_id=session_id, quota=quota,
                    description=description
                )

        token = throttled(run, 'reserve')()

        if approve_manually:
            self.flash(_(u'Added to waitinglist'))
        else:
            self.scheduler.approve_reservation(token)
            self.flash(_(u'Reservation successful'))
Example #3
0
    def run_reserve(
        self, data, approve_manually, start=None, end=None, group=None, quota=1
    ):

        assert (start and end) or group
        assert not (start and end and group)

        email = self.email(data)
        additional_data = self.additional_data(data, add_manager_defaults=True)
        session_id = self.session_id()

        # only store forms defined in the formsets list
        additional_data = dict(
            (
                form, additional_data[form]
            ) for form in self.context.formsets if form in additional_data
        )

        run_pre_reserve_script(self.context, start, end, additional_data)

        def run():
            if start and end:
                return self.scheduler.reserve(
                    email, (start, end),
                    data=additional_data, session_id=session_id, quota=quota
                )
            else:
                return self.scheduler.reserve(
                    email, group=group,
                    data=additional_data, session_id=session_id, quota=quota
                )

        token = throttled(run, 'reserve')()

        if approve_manually:
            self.flash(_(u'Added to waitinglist'))
        else:
            self.scheduler.approve_reservation(token)
            self.flash(_(u'Reservation successful'))
Example #4
0
    def run_reserve(self, data, approve_manually, start=None, end=None, group=None, quota=1, dates=None):

        assert (start and end) or group or dates
        assert not (start and end and group and dates)

        email = self.email(data)
        additional_data = self.additional_data(data, add_manager_defaults=True)
        session_id = self.session_id()

        # only store forms defined in the formsets list
        if not self.context.formsets:
            additional_data = {}
        else:
            additional_data = dict(
                (form, additional_data[form]) for form in self.context.formsets if form in additional_data
            )

        run_pre_reserve_script(self.context, start, end, additional_data)

        def run():
            if start and end:
                return self.scheduler.reserve(
                    email, (start, end), data=additional_data, session_id=session_id, quota=quota
                )
            elif group:
                return self.scheduler.reserve(
                    email, group=group, data=additional_data, session_id=session_id, quota=quota
                )
            else:
                return self.scheduler.reserve(email, dates, data=additional_data, session_id=session_id, quota=quota)

        token = throttled(run, "reserve")()

        if not approve_manually:
            self.scheduler.approve_reservations(token)

        self.flash(_(u"Added reservation to your list. " u"You have 15 minutes to confirm your reservations."))