Example #1
0
    def tagged_with(self, tag_names, **kwargs):
        '''Returns all Posts that are tagged with any of the given tags.'''
        e = get_entity('tag')
        tags = [e(name=tag) for tag in tag_names]
        posts = self.entity(tags=tags)
        r = self._filter(posts, **kwargs)

        return make_entity(self.entity.type_, r.json(), many=True)
Example #2
0
    def get_by_name(self, name):
        tag = self.entity(name=name)
        r = self._filter(tag)
        e = make_entity(self.entity.type_, r.json(), many=True)

        return single(e)
Example #3
0
    def new(self, name, access_token):
        tag = self.entity(name=name)
        r = self._new(tag, access_token)

        return make_entity(self.entity.type_, r.json())
    def get_by_post(self, post_id, **kwargs):
        post = assemblers.get_entity('post')(id=post_id)
        comments = self.entity(post=post)
        r = self._filter(comments, **kwargs)

        return assemblers.make_entity(self._entity, r.json(), many=True)
    def new(self, content, post_id, user, access_token):
        post = assemblers.get_entity('post')(id=post_id)
        comment = self.entity(id=666, content=content, post=post, user=user)
        r = self._new(comment, access_token)

        return assemblers.make_entity(self._entity, r.json())
Example #6
0
    def get_by_user_id(self, user_id):
        user = self.entity(user_id=user_id)
        r = self._filter(user)

        return single(make_entity('user', r.json(), many=True))
Example #7
0
    def new(self, username: str, access_token: str) -> Entity:
        user = self.entity(username=username)
        r = self._new(user, access_token)

        return make_entity('user', r.json())