Пример #1
0
    def post(self, request):
        ctx = {'seats': []}
        req = request.POST
        session = req.get('session')
        amount = 0

        try:
            amount = int(req.get('amount_seats'))
        except:
            return HttpResponse(json.dumps(ctx),
                                content_type="application/json")

        session = Session.objects.get(id=session)
        seats = search_seats(session, amount)
        if seats:
            ctx['seats'] = seats
        else:
            ctx['error'] = _(
                "Not found contiguous seats, please, select manually using the green button"
            )

        if not amount:
            ctx['fail_silently'] = True

        return HttpResponse(json.dumps(ctx), content_type="application/json")
Пример #2
0
    def internal_ws_autoseats(self, client, session, amount, user):
        session = Session.objects.get(id=session)
        seats = search_seats(session, int(amount))
        data = {
            'action': 'autoseat',
            'session': session.id,
            'seats': seats,
        }

        for s in seats:
            layout = SeatLayout.objects.get(id=s['layout'])
            seat = '{}-{}'.format(s['row'], s['col'])

            d2 = {
                'action': 'hold',
                'session': session.id,
                'layout': layout.id,
                'row': s['row'],
                'col': s['col'],
            }
            sh = TicketSeatHold(client=user,
                                layout=layout,
                                seat=seat,
                                session=session)
            sh.save()
            self.server.send_message_to_all(json.dumps(d2))

        if not seats:
            data['error'] = _(
                'Not found contiguous seats, please, select manually using the green button'
            )

        self.server.send_message(client, json.dumps(data))
Пример #3
0
    def internal_ws_autoseats(self, client, session, amount, user):
        session = Session.objects.get(id=session)
        seats = search_seats(session, int(amount))
        data = {
            'action': 'autoseat',
            'session': session.id,
            'seats': seats,
        }

        for s in seats:
            layout = SeatLayout.objects.get(id=s['layout'])
            seat = '{}-{}'.format(s['row'], s['col'])

            d2 = {
                'action': 'hold',
                'session': session.id,
                'layout': layout.id,
                'row': s['row'],
                'col': s['col'],
            }
            sh = TicketSeatHold(client=user,
                                layout=layout,
                                seat=seat,
                                session=session)
            sh.save()
            self.server.send_message_to_all(json.dumps(d2))

        if not seats:
            data['error'] = _('Not found contiguous seats, please, select manually using the green button')

        self.server.send_message(client, json.dumps(data))
Пример #4
0
    def post(self, request):
        ctx = {"seats": []}
        req = request.POST
        session = req.get("session")
        amount = 0

        try:
            amount = int(req.get("amount_seats"))
        except:
            return HttpResponse(json.dumps(ctx), content_type="application/json")

        session = Session.objects.get(id=session)
        seats = search_seats(session, amount)
        if seats:
            ctx["seats"] = seats
        else:
            ctx["error"] = _("Not found contiguous seats, please, select manually using the green button")

        if not amount:
            ctx["fail_silently"] = True

        return HttpResponse(json.dumps(ctx), content_type="application/json")