예제 #1
0
    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)

        Note that this is the same results as calling /api/v2/<inventory_type>/columns/?organization_id={}

        Example:
            /api/v2/columns/?inventory_type=(property|taxlot)&organization_id={}
        ---
        type:
            status:
                required: true
                type: string
                description: Either success or error
            columns:
                required: true
                type: array[column]
                description: Returns an array where each item is a full column structure.
        parameters:
            - name: organization_id
              description: The organization_id for this user's organization
              required: true
              paramType: query
            - name: inventory_type
              description: Which inventory type is being matched (for related fields and naming).
                property or taxlot
              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 = request.query_params.get('organization_id', None)
        inventory_type = request.query_params.get('inventory_type', 'property')
        only_used = request.query_params.get('only_used', False)

        columns = Column.retrieve_all(organization_id, inventory_type,
                                      only_used)

        # for c in Column.objects.filter(organization=org).order_by('table_name', 'column_name'):
        #     columns.append(c.to_dict())

        return JsonResponse({
            'status': 'success',
            'columns': columns,
        })
예제 #2
0
    def retrieve_all(self, request):
        """
        Retrieves all columns for the user's organization including the raw database columns

        Example:
            /api/v2/columns/retrieve_all/?inventory_type=(property|taxlot)
        ---
        type:
            status:
                required: true
                type: string
                description: Either success or error
            columns:
                required: true
                type: array[column]
                description: Returns an array where each item is a full column structure.
        parameters:
            - name: organization_id
              description: The organization_id for this user's organization
              required: true
              paramType: query
            - name: inventory_type
              description: Which inventory type is being matched (for related fields and naming).
                property or taxlot
              required: true
              paramType: query
        """
        organization_id = request.query_params.get('organization_id', None)
        inventory_type = request.query_params.get('inventory_type', 'property')

        columns = Column.retrieve_all(organization_id, inventory_type)

        # for c in Column.objects.filter(organization=org).order_by('table_name', 'column_name'):
        #     columns.append(c.to_dict())

        return JsonResponse({
            'status': 'success',
            'columns': columns,
        })