Skip to content

Commit

Permalink
Add note resource example.
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Feb 7, 2020
1 parent fd89cf2 commit 916f1cb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion example/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from app import app
from auth import auth
from models import User, Message, Relationship
from models import User, Message, Note, Relationship


user_auth = UserAuthentication(auth)
Expand Down Expand Up @@ -30,7 +30,19 @@ class RelationshipResource(RestrictOwnerResource):
paginate_by = None


class NoteResource(RestrictOwnerResource):
owner_field = 'user'
include_resources = {
'user': UserResource,
}

def get_query(self):
query = super(NoteResource, self).get_query()
return query.where(Note.status == 1)


# register our models so they are exposed via /api/<model>/
api.register(User, UserResource, auth=admin_auth)
api.register(Relationship, RelationshipResource)
api.register(Message, MessageResource)
api.register(Note, NoteResource)

0 comments on commit 916f1cb

Please sign in to comment.