Exemplo n.º 1
0
def tickets(request):
    tickets = dataaccess.user_tickets(request.user,
                                      settings.CONFERENCE_CONFERENCE,
                                      only_complete=True)
    return {
        'tickets': tickets,
        'refund_form': RefundItemForm(None),
    }
Exemplo n.º 2
0
    def _check_hotel_reservation(self, field_name):
        data = self.cleaned_data.get(field_name, [])
        if not data:
            return []

        checks = []
        for ix, row in enumerate(data):
            f = cmodels.Fare.objects.get(
                conference=settings.CONFERENCE_CONFERENCE, code=row['fare'])
            price = f.calculated_price(**row)
            if not price:
                raise forms.ValidationError('%s:invalid period' % ix)

            checks.append((
                't' + f.code[2],
                row['qty'] * (1 if f.code[1] == 'B' else int(f.code[2])),
                row['period'],
            ))

        # Only partecipants are allowed to buy
        conference_tickets = 0
        for k, v in self.cleaned_data.items():
            if k[0] == 'T' and v:
                conference_tickets += v
        if not conference_tickets:
            from p3.dataaccess import user_tickets
            tickets = user_tickets(self.user.user,
                                   settings.CONFERENCE_CONFERENCE,
                                   only_complete=True)
            for t in tickets:
                if t.fare.code.startswith('T'):
                    conference_tickets += 1
        if not conference_tickets:
            args = []
            for ix, _ in enumerate(data):
                args.append('%s:You need a conference ticket' % ix)
            self._errors[field_name] = self.error_class(args)
            del self.cleaned_data[field_name]

        try:
            models.TicketRoom.objects.can_be_booked(checks)
        except ValueError:
            raise forms.ValidationError((
                '0:Not available in this period '
                '(<a href="/hotel-concession/rooms-not-available" class="trigger-overlay">'
                'info</a>)'))

        return data
Exemplo n.º 3
0
    def _check_hotel_reservation(self, field_name):
        data = self.cleaned_data.get(field_name, [])
        if not data:
            return []

        checks = []
        for ix, row in enumerate(data):
            f = cmodels.Fare.objects.get(conference=settings.CONFERENCE_CONFERENCE, code=row['fare'])
            price = f.calculated_price(**row)
            if not price:
                raise forms.ValidationError('%s:invalid period' % ix)

            checks.append((
                't' + f.code[2],
                row['qty'] * (1 if f.code[1] == 'B' else int(f.code[2])),
                row['period'],
            ))

        # Only partecipants are allowed to buy
        conference_tickets = 0
        for k, v in self.cleaned_data.items():
            if k[0] == 'T' and v:
                conference_tickets += v
        if not conference_tickets:
            from p3.dataaccess import user_tickets
            tickets = user_tickets(self.user.user, settings.CONFERENCE_CONFERENCE, only_complete=True)
            for t in tickets:
                if t.fare.code.startswith('T'):
                    conference_tickets += 1
        if not conference_tickets:
            args = []
            for ix, _ in enumerate(data):
                args.append('%s:You need a conference ticket' % ix)
            self._errors[field_name] = self.error_class(args)
            del self.cleaned_data[field_name]

        try:
            models.TicketRoom.objects.can_be_booked(checks)
        except ValueError:
            raise forms.ValidationError((
                '0:Not available in this period '
                '(<a href="/hotel-concession/rooms-not-available" class="trigger-overlay">'
                'info</a>)'))

        return data
Exemplo n.º 4
0
def tickets(request):
    tickets = dataaccess.user_tickets(request.user, settings.CONFERENCE_CONFERENCE, only_complete=True)
    return {
        'tickets': tickets,
        'refund_form': RefundItemForm(None),
    }
Exemplo n.º 5
0
def on_ticket_for_user(sender, **kwargs):
    from p3 import dataaccess
    tickets = dataaccess.user_tickets(sender.user,
                                      settings.CONFERENCE_CONFERENCE,
                                      only_complete=True)
    map(kwargs['tickets'].append, tickets)
Exemplo n.º 6
0
def on_ticket_for_user(sender, **kwargs):
    from p3 import dataaccess
    tickets = dataaccess.user_tickets(sender.user, settings.CONFERENCE_CONFERENCE, only_complete=True)
    map(kwargs['tickets'].append, tickets)