Exemple #1
0
def confirm_reservations_for_session(session_id, token=None, language=None):
    """ Confirms all reservations of the given session id. Optionally
    confirms only the reservations with the given token. All if None.

    The langauge given is the language used for the confirmation event (which
    leads to an email sent in this language). Default is the site language.

    """

    assert session_id

    if not language:
        language = utils.get_current_site_language()

    reservations = reservations_by_session(session_id)

    if token:
        reservations = reservations.filter(Reservation.token == token)

    reservations = reservations.all()

    for reservation in reservations:
        reservation.session_id = None

    notify(ReservationsConfirmedEvent(reservations, language))
Exemple #2
0
 def trigger_email(context, reservation, old_time, new_time):
     notify(ReservationTimeChangedEvent(
         reservation=reservation,
         language=utils.get_current_site_language(),
         old_time=old_time,
         new_time=new_time,
         send_email=send_email,
         reason=reason or u'',
     ))
Exemple #3
0
    def revoke_reservation(self, token, reason, id=None, send_email=True):
        """ Revoke a reservation and inform the user of that."""

        reason = reason or u''

        # sending the email first is no problem as it won't work if
        # an exception triggers later in the request

        reservations = self.reservations_by_token(token, id).all()
        notify(ReservationsRevokedEvent(
            reservations, utils.get_current_site_language(), reason, send_email
        ))

        self.remove_reservation(token, id)
Exemple #4
0
    def __init__(self, resource_uuid, is_exposed=None, language=None):

        try:
            self.uuid = UUID(resource_uuid)
        except AttributeError:
            self.uuid = resource_uuid

        self.is_exposed = is_exposed or (lambda allocation: True)

        # the language is used for the events that are being sent
        # if no language is given, then the current site language is used
        if language:
            self.language = language
        else:
            self.language = utils.get_current_site_language()
Exemple #5
0
 def on_reservations_confirmed(self, context, reservations, session_id):
     notify(ReservationsConfirmedEvent(
         reservations, utils.get_current_site_language()
     ))
Exemple #6
0
 def on_reservations_denied(self, context, reservations):
     notify(ReservationsDeniedEvent(
         reservations, utils.get_current_site_language()
     ))
def get_default_language(adapter):
    return utils.get_current_site_language()
def get_default_language(adapter):
    return utils.get_current_site_language()