Exemplo n.º 1
0
    def post( self ):
        """Endpoint to return several Gifts from table given a date or a range of dates for attached Transactions."""
        gifts = get_gifts_by_date( request.json[ 'date' ] )
        # We are using dump many=True and so if a single gift returned need to put it in a list.

        schema = GiftSchema( many=True )
        result = schema.dump( gifts ).data
        return result, status.HTTP_200_OK
Exemplo n.º 2
0
    def post( self ):
        """Simple endpoint to return several rows from table given a list of ID's."""
        if not request.json[ 'searchable_ids' ]:
            return []

        gifts = get_gifts_by_searchable_ids( request.json[ 'searchable_ids' ] )
        schema = GiftSchema( many=True )
        result = schema.dump( gifts ).data
        return result, status.HTTP_200_OK
Exemplo n.º 3
0
    def get( self ):
        """Simple endpoint to retrieve all rows from table."""

        query_terms = build_filter_from_request_args( request.args )
        link_header_query_terms = None
        # Build the page and sort information from the filter results on the query string.
        # Delete these keys and pass along only the model filter/search terms.
        page_information = {}
        sort_information = []
        if query_terms:
            page_information = {}
            if 'paginate' in query_terms and query_terms[ 'paginate' ]:
                page_information = {
                    'page_number': query_terms[ 'paginate' ][ 'page_number' ],
                    'rows_per_page': query_terms[ 'paginate' ][ 'rows_per_page' ]
                }
                del query_terms[ 'paginate' ]

            link_header_query_terms = copy.deepcopy( query_terms )

            if 'sort' in query_terms and query_terms[ 'sort' ]:
                sort_information = query_terms[ 'sort' ]
                del query_terms[ 'sort' ]

        gifts = get_gifts( query_terms, page_information=page_information, sort_information=sort_information )

        if page_information:
            transformed_data = transform_data(
                'donation/gifts',
                link_header_query_terms,
                gifts,
                GiftSchema
            )
            response = jsonify( transformed_data[ 'page' ] )
            response.headers[ 'Link' ] = transformed_data[ 'link-header' ]
            response.status_code = status.HTTP_200_OK
            return response

        schema = GiftSchema( many=True )
        result = schema.dump( gifts ).data
        return result, status.HTTP_200_OK
Exemplo n.º 4
0
 def post( self ):
     """Endpoint to return several Gifts from table given a given_to."""
     gifts = get_gifts_by_given_to( request.json[ 'given_to' ] )
     schema = GiftSchema( many=True )
     result = schema.dump( gifts ).data
     return result, status.HTTP_200_OK
Exemplo n.º 5
0
 def post( self ):
     """Endpoint to return several Gifts from table given a list of user ID's."""
     gifts = get_gifts_by_user_id( request.json[ 'user_ids' ] )
     schema = GiftSchema( many=True )
     result = schema.dump( gifts ).data
     return result, status.HTTP_200_OK
Exemplo n.º 6
0
 def get( self, user_id ):
     """Endpoint to return several Gifts from table given a user ID."""
     gift = get_gifts_by_user_id( user_id )
     schema = GiftSchema( many=True )
     result = schema.dump( gift ).data
     return result, status.HTTP_200_OK