def columns(self, request): """ List all tax lot columns --- parameters: - name: organization_id description: The organization_id for this user's organization required: true paramType: query - name: used_only description: Determine whether or not to show only the used fields. Ones that have been mapped type: boolean required: false paramType: query """ organization_id = int(request.query_params.get('organization_id')) organization = Organization.objects.get(pk=organization_id) only_used = json.loads(request.query_params.get('only_used', 'false')) columns = Column.retrieve_all(organization_id, 'taxlot', only_used) unitted_columns = [ add_pint_unit_suffix(organization, x) for x in columns ] return JsonResponse({'status': 'success', 'columns': unitted_columns})
def list(self, request): """ Retrieves all columns for the user's organization including the raw database columns. Will return all the columns across both the Property and Tax Lot tables. The related field will be true if the column came from the other table that is not the 'inventory_type' (which defaults to Property) """ organization_id = self.get_organization(self.request) inventory_type = request.query_params.get('inventory_type', 'property') only_used = json.loads(request.query_params.get('only_used', 'false')) columns = Column.retrieve_all(organization_id, inventory_type, only_used) organization = Organization.objects.get(pk=organization_id) if json.loads(request.query_params.get('display_units', 'true')): columns = [add_pint_unit_suffix(organization, x) for x in columns] return JsonResponse({ 'status': 'success', 'columns': columns, })