def handle(self, *args, **options): try: conference = args[0] except IndexError: raise CommandError('conference code is missing') cmdargs = settings.TICKET_BADGE_PROG_ARGS tickets = settings.CONFERENCE_TICKETS(conference, ticket_type=options['type'], fare_code=options['fare']) if options['names']: q = Q() for n in options['names'].split(','): q |= Q(name__icontains=n) tickets = tickets.filter(q) cmdargs.extend(['-e', '0', '-p', 'A4', '-n', '4']) if options['ids']: tickets = tickets.filter(id__in=options['ids'].split(',')) cmdargs.extend(['-e', '0', '-p', 'A4', '-n', '4']) print >> sys.stderr, '* %d tickets' % tickets.count() files = utils.render_badge(tickets, cmdargs=cmdargs, stderr=None) name, f, input_data = files[0] if options['input_data']: file(options['input_data'], 'w').write(input_data) print name, f
def handle(self, *args, **options): try: conference, output = args except IndexError: raise CommandError('conference code is missing') cmdargs = [] bank_limit = datetime.now() - timedelta(days=30) tickets = models.Ticket.objects\ .filter(fare__conference=conference, fare__ticket_type='conference')\ .filter( Q(orderitem__order___complete=True) | Q(orderitem__order__method='bank', orderitem__order__created__gte=bank_limit))\ .select_related('orderitem__order') if options['names']: q = Q() for n in options['names'].split(','): q |= Q(name__icontains=n) tickets = tickets.filter(q) cmdargs.extend(['-e', '0', '-p', 'A4', '-n', '4']) files = utils.render_badge(tickets, cmdargs=cmdargs) files[0].seek(0) with file(output, 'w') as f: while True: chunk = files[0].read(16 * 1024) if not chunk: break f.write(chunk) with file(output + '.check', 'w') as f: for t in tickets: if not t.orderitem.order._complete: f.write('Ticket: %s(%d) - Order: %s\n' % (t.name.encode('utf-8'), t.id, t.orderitem.order.code.encode('utf-8')))
def handle(self, *args, **options): try: conference = args[0] except IndexError: raise CommandError('conference code is missing') cmdargs = settings.TICKET_BADGE_PROG_ARGS tickets = settings.CONFERENCE_TICKETS( conference, ticket_type=options['type'], fare_code=options['fare']) if options['names']: q = Q() for n in options['names'].split(','): q |= Q(name__icontains=n) tickets = tickets.filter(q) cmdargs.extend(['-e', '0', '-p', 'A4', '-n', '4']) if options['ids']: tickets = tickets.filter(id__in=options['ids'].split(',')) cmdargs.extend(['-e', '0', '-p', 'A4', '-n', '4']) print >>sys.stderr, '* %d tickets' % tickets.count() files = utils.render_badge(tickets, cmdargs=cmdargs, stderr=None) name, f, input_data = files[0] if options['input_data']: file(options['input_data'], 'w').write(input_data) print name, f
def do_ticket_badge(self, request, qs): output = utils.render_badge(qs, cmdargs=settings.TICKET_BADGE_PROG_ARGS_ADMIN) name, output_dir, _ = output[0] tar = utils.archive_dir(output_dir) response = http.HttpResponse(tar, mimetype="application/x-gzip") response['Content-Disposition'] = 'attachment; filename=badge-%s.tar.gz' % name return response
def handle(self, *args, **options): try: conference, output = args except IndexError: raise CommandError('conference code is missing') cmdargs = [] bank_limit = datetime.now() - timedelta(days=30) tickets = models.Ticket.objects\ .filter(fare__conference=conference, fare__ticket_type='conference')\ .filter( Q(orderitem__order___complete=True) | Q(orderitem__order__method='bank', orderitem__order__created__gte=bank_limit))\ .select_related('orderitem__order') if options['names']: q = Q() for n in options['names'].split(','): q |= Q(name__icontains=n) tickets = tickets.filter(q) cmdargs.extend(['-e', '0', '-p', 'A4', '-n', '4']) files = utils.render_badge(tickets, cmdargs=cmdargs) files[0].seek(0) with file(output, 'w') as f: while True: chunk = files[0].read(16*1024) if not chunk: break f.write(chunk) with file(output + '.check', 'w') as f: for t in tickets: if not t.orderitem.order._complete: f.write('Ticket: %s(%d) - Order: %s\n' % (t.name.encode('utf-8'), t.id, t.orderitem.order.code.encode('utf-8')))
def do_ticket_badge(self, request, qs): output = utils.render_badge( qs, cmdargs=settings.TICKET_BADGE_PROG_ARGS_ADMIN) name, output_dir, _ = output[0] tar = utils.archive_dir(output_dir) response = http.HttpResponse(tar, mimetype="application/x-gzip") response[ 'Content-Disposition'] = 'attachment; filename=badge-%s.tar.gz' % name return response