Esempio n. 1
0
 def confirm_reservations(self, token=None):
     # Remove session_id from all reservations in the current session.
     db.confirm_reservations_for_session(
         plone_session.get_session_id(self.context),
         token,
         utils.get_current_language(self.context, self.request)
     )
Esempio n. 2
0
    def reservations(self):
        """ Returns all reservations in the user's session """
        session_id = plone_session.get_session_id(self.context)

        reservations = db().reservations_by_session(session_id)
        reservations = reservations.order_by(Reservation.created, Reservation.token)

        return reservations.all()
Esempio n. 3
0
    def reservations(self):
        """ Returns all reservations in the user's session """
        session_id = plone_session.get_session_id(self.context)

        reservations = db().reservations_by_session(session_id)
        reservations = reservations.order_by(Reservation.created,
                                             Reservation.token)

        return reservations.all()
    def test_reservation_data(self):
        self.login_manager()

        resource = self.create_resource()
        scheduler = resource.scheduler()

        start = datetime(2012, 12, 10, 8, 0)
        end = datetime(2012, 12, 10, 12, 0)
        dates = (start, end)
        scheduler.allocate(dates, approve_manually=False)

        request = self.portal.REQUEST
        view = YourReservations(resource, request)
        self.assertEqual(0, len(view.reservations()))

        session_id = plone_session.get_session_id(resource)
        scheduler.reserve(
            u'*****@*****.**', dates, data={}, session_id=session_id
        )

        view = YourReservations(resource, request)
        self.assertEqual(1, len(view.reservations()))
Esempio n. 5
0
    def test_reservation_data(self):
        self.login_manager()

        resource = self.create_resource()
        scheduler = resource.scheduler()

        start = datetime(2012, 12, 10, 8, 0)
        end = datetime(2012, 12, 10, 12, 0)
        dates = (start, end)
        scheduler.allocate(dates, approve_manually=False)

        request = self.portal.REQUEST
        view = YourReservations(resource, request)
        self.assertEqual(0, len(view.reservations()))

        session_id = plone_session.get_session_id(resource)
        scheduler.reserve(
            u'*****@*****.**', dates, data={}, session_id=session_id
        )

        view = YourReservations(resource, request)
        self.assertEqual(1, len(view.reservations()))
Esempio n. 6
0
 def remove_reservation(self, token):
     session_id = plone_session.get_session_id(self.context)
     db.remove_reservation_from_session(session_id, token)
Esempio n. 7
0
 def has_reservations(self):
     session_id = plone_session.get_session_id(self.context)
     return bool(db.reservations_by_session(session_id).first())
Esempio n. 8
0
 def reservations(self):
     """ Returns all reservations in the user's session """
     session_id = plone_session.get_session_id(self.context)
     return db.reservations_by_session(session_id).all()
Esempio n. 9
0
 def session_id(self):
     return plone_session.get_session_id(self.context)
Esempio n. 10
0
 def remove_reservation(self, token):
     try:
         session_id = plone_session.get_session_id(self.context)
         db().remove_reservation_from_session(session_id, token)
     except NoResultFound:
         pass  # act idempotent to the user
Esempio n. 11
0
 def confirm_reservations(self, token=None):
     # Remove session_id from all reservations in the current session.
     db().confirm_reservations_for_session(plone_session.get_session_id(self.context), token)
 def test_get_session_id(self):
     context = self.portal
     result1 = plone_session.get_session_id(context)
     result2 = plone_session.get_session_id(context)
     self.assertEqual(result1, result2)
Esempio n. 13
0
 def test_get_session_id(self):
     context = self.portal
     result1 = plone_session.get_session_id(context)
     result2 = plone_session.get_session_id(context)
     self.assertEqual(result1, result2)
Esempio n. 14
0
 def remove_reservation(self, token):
     try:
         session_id = plone_session.get_session_id(self.context)
         db().remove_reservation_from_session(session_id, token)
     except NoResultFound:
         pass  # act idempotent to the user
Esempio n. 15
0
 def confirm_reservations(self, token=None):
     # Remove session_id from all reservations in the current session.
     db().confirm_reservations_for_session(
         plone_session.get_session_id(self.context), token)