Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Routes with prefilters #126

Open
ludusrusso opened this issue Sep 15, 2017 · 0 comments
Open

Create Routes with prefilters #126

ludusrusso opened this issue Sep 15, 2017 · 0 comments

Comments

@ludusrusso
Copy link

Hi,
I'm try to understand if there is a way to define a Route on a Resource equivalent to a filtered query.

Here is an example:

I've a reource ExampleResource that has a filed example, an i'd like to create a Get custom route '/example' that returns only the elements having example == True

    class ExampleResource(PrincipalResource):
        class Schema:
            author = fields.ToOne('user')

        class Meta:
            model = Code
            read_only_fields = ['author']
            permissions = {
                'create': 'yes',
                'read': 'user:author',
                'update': 'read',
                'delete': 'update'
            }

        @Route.GET
        def examples(self):
             # Return equivalent to filter example == True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant