Пример #1
0
def bulk_order_zip(request, bo_id):
    bo = get_object_or_404(NYCDOTBulkOrder, id=bo_id)
    response = HttpResponse(mimetype='application/zip')
    filename = bulkorder.make_filename(bo, 'zip')
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    bulkorder.make_zip(bo, response)
    return response
Пример #2
0
    def handle(self, *args, **options):
        if len(args) < 2:
            raise optparse.OptParseError("Need a borough name and a community board number")

        logger.debug('starting handle')
        from fixcity.bmabr.models import NYCDOTBulkOrder
        from fixcity.bmabr.models import CommunityBoard
        from django.contrib.auth.models import User

        # What user? Ugh, hardcode this for now.
        try:
            user = User.objects.get(username='******')
        except User.DoesNotExist:
            user = User.objects.filter(is_superuser=True)[0] # ugh!!!

        borough, cb_number = args[0], int(args[1])
        cb = CommunityBoard.objects.get(borough__boroname=borough,
                                        board=cb_number)
        bulk_order, created = NYCDOTBulkOrder.objects.get_or_create(
            communityboard=cb, user=user, organization='OpenPlans',
            rationale='just testing')
        logger.info('Creating new bulk order' if created
                    else"Existing bulk order")
        bulk_order.approve()
        bulk_order.save()

        from fixcity.bmabr import bulkorder
        filename = bulkorder.make_filename(bulk_order, 'zip')
        outfile = open(filename, 'w')
        bulkorder.make_zip(bulk_order, outfile)
        outfile.close()
        logger.info( "Output written to %s" % filename)
        # Stashing this here so tests can clean up... ugh.
        self._filename = filename
Пример #3
0
def bulk_order_pdf(request, bo_id):
    from fixcity.bmabr import bulkorder
    bo = get_object_or_404(NYCDOTBulkOrder, id=bo_id)
    response = HttpResponse(mimetype='application/pdf')
    filename = bulkorder.make_filename(bo, 'pdf')
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    bulkorder.make_pdf(bo, response)
    return response
Пример #4
0
def bulk_order_csv(request, bo_id):
    bo = get_object_or_404(NYCDOTBulkOrder, id=bo_id)
    cb = bo.communityboard
    response = HttpResponse(mimetype='text/csv')
    filename = bulkorder.make_filename(bo, 'csv')
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    bulkorder.make_csv(bo, response)
    return response