Example #1
0
    def test_assets_rows(self):
        rows = [item for item in get_assets_rows()]

        self.assertListEqual(
            rows,
            [
                [
                    'id', 'niw', 'barcode', 'sn', 'model__category__name',
                    'model__manufacturer__name', 'model__name',
                    'user__username', 'user__first_name', 'user__last_name',
                    'owner__username', 'owner__first_name',
                    'owner__last_name', 'status', 'service_name__name',
                    'property_of', 'warehouse__name', 'invoice_date',
                    'invoice_no', 'region__name',
                ],
                [
                    self.asset.id, 'niw=666', 'br-666',
                    '1111-1111-1111-1111', 'Subcategory', 'Manufacturer1',
                    'Model1', 'user', 'Elmer', 'Stevens', 'owner', 'Eric',
                    'Brown', 1, None, None, 'Warehouse',
                    datetime.date(2014, 4, 28), 'invoice-6666',
                    'Default region',
                ],
            ]
        )
Example #2
0
 def handle(self, *args, **options):
     only_licences = options['only_licences']
     only_assets = options['only_assets']
     filter_type = options['filter_type']
     only_assigned_licences = options['only_assigned_licences']
     if not any((only_licences, only_assets)):
         self.stdout.write(
             'Arguments required, type --help for more informations\n', )
     output = cStringIO.StringIO()
     writer = csv.writer(output)
     if only_assets and not only_licences:
         for row in get_assets_rows(filter_type):
             writer.writerow([smart_str(item) for item in row])
         self.stdout.write(output.getvalue())
     elif only_licences and not only_assets:
         for row in get_licences_rows(filter_type, only_assigned_licences):
             writer.writerow([smart_str(item) for item in row])
         self.stdout.write(output.getvalue())
Example #3
0
 def handle(self, *args, **options):
     only_licences = options['only_licences']
     only_assets = options['only_assets']
     filter_type = options['filter_type']
     only_assigned_licences = options['only_assigned_licences']
     if not any((only_licences, only_assets)):
         self.stdout.write(
             'Arguments required, type --help for more informations\n',
         )
     output = cStringIO.StringIO()
     writer = csv.writer(output)
     if only_assets and not only_licences:
         for row in get_assets_rows(filter_type):
             writer.writerow([smart_str(item) for item in row])
         self.stdout.write(output.getvalue())
     elif only_licences and not only_assets:
         for row in get_licences_rows(filter_type, only_assigned_licences):
             writer.writerow([smart_str(item) for item in row])
         self.stdout.write(output.getvalue())
Example #4
0
    def test_assets_rows(self):
        rows = [item for item in get_assets_rows()]

        self.assertEqual(rows, [
            [
                'id',
                'niw',
                'barcode',
                'sn',
                'model__category__name',
                'model__manufacturer__name',
                'model__name',
                'user__username',
                'user__first_name',
                'user__last_name',
                'owner__username',
                'owner__first_name',
                'owner__last_name',
                'status',
                'service_name__name',
                'property_of',
                'warehouse__name',
            ],
            [
                1,
                'niw=666',
                'br-666',
                '1111-1111-1111-1111',
                'Subcategory',
                'Manufacturer1',
                'Model1',
                'user',
                'Elmer',
                'Stevens',
                'owner',
                'Eric',
                'Brown',
                1,
                None,
                None,
                'Warehouse',
            ],
        ])
Example #5
0
    def test_assets_rows(self):
        rows = [item for item in get_assets_rows()]

        self.assertEqual(
            rows,
            [
                [
                    'id', 'niw', 'barcode', 'sn', 'model__category__name',
                    'model__manufacturer__name', 'model__name',
                    'user__username', 'user__first_name', 'user__last_name',
                    'owner__username', 'owner__first_name',
                    'owner__last_name', 'status', 'service_name__name',
                    'property_of', 'warehouse__name',
                ],
                [
                    1, 'niw=666', 'br-666', '1111-1111-1111-1111',
                    'Subcategory', 'Manufacturer1', 'Model1', 'user',
                    'Elmer', 'Stevens', 'owner', 'Eric', 'Brown', 1, None,
                    None, 'Warehouse',
                ],
            ]
        )
Example #6
0
 def get_result(self, *args, **kwargs):
     filter_type = kwargs.get('mode')
     return list(get_assets_rows(filter_type=filter_type))
Example #7
0
 def get_result(self, *args, **kwargs):
     filter_type = kwargs.get('mode')
     return list(get_assets_rows(filter_type=filter_type))