def post(self, request): ctx = {} invi_type_id = request.POST.get('invi_type') if invi_type_id: invi_type = get_object_or_404(InvitationType, id=invi_type_id) sessions = invi_type.sessions.all() string = request.POST.get('string', '') try: dic = get_seats_by_str(sessions, string) total = 0 for val in dic.values(): total += len(val) ctx['total'] = total ctx['values'] = dic.__str__() except: ctx['error'] = 'invalid' else: ctx['error'] = _('neccessary select invitation type') return JsonResponse(ctx)
def post(self, request): ctx = {} invi_type_id = request.POST.get("invi_type") if invi_type_id: invi_type = get_object_or_404(InvitationType, id=invi_type_id) sessions = invi_type.sessions.all() string = request.POST.get("string", "") try: dic = get_seats_by_str(sessions, string) total = 0 for val in dic.values(): total += len(val) ctx["total"] = total ctx["values"] = dic.__str__() except: ctx["error"] = "invalid" else: ctx["error"] = _("neccessary select invitation type") return JsonResponse(ctx)
def get_seats(self): return get_seats_by_str(self.type.sessions.all(), self.seats)