示例#1
0
文件: entity.py 项目: rlanger/Rondo
 def put(self, schema):
     """Update a profile."""
     try:
         profile = g.entity.profiles.get(schema=schema)
         profile.update_values(request.json)
     except Profile.DoesNotExist:
         profile = Profile(entity=g.entity, schema=schema, **request.json)
     return jsonify(profile.save())
示例#2
0
文件: entity.py 项目: rlanger/Rondo
    def post(self):
        """Create a new profile of the specified type.
        
        This is specific to pytentd, and is similar to PUT /profile/<schema>.

        TODO: Document this!
        TODO: This doesn't appear to be covered by any tests
        """
        if not 'schema' in request.json:
            raise APIBadRequest("A profile schema is required.")
        
        return jsonify(Profile(entity=g.entity, **request.json).save())
示例#3
0
文件: posts.py 项目: rlanger/Rondo
    def put(self, post_id):
        post = g.entity.posts.get_or_404(id=post_id)

        # TODO: Posts have more attributes than this

        if 'content' in request.json:
            post.content = request.json['content']
        if 'schema' in request.json:
            post.schema = request.json['schema']

        # TODO: Versioning.

        return jsonify(post.save())
示例#4
0
文件: posts.py 项目: rlanger/Rondo
    def put(self, post_id):
        post = g.entity.posts.get_or_404(id=post_id)

        # TODO: Posts have more attributes than this

        if 'content' in request.json:
            post.content = request.json['content']
        if 'schema' in request.json:
            post.schema = request.json['schema']

        # TODO: Versioning.

        return jsonify(post.save())
示例#5
0
文件: posts.py 项目: rlanger/Rondo
    def post(self):
        """ Used by apps to create a new post.

        Used by other servers to notify of a mention from a non-followed
        entity.

        TODO: Separate between apps creating a new post and a notification
        from a non-followed entity.
        """
        new_post = Post()
        new_post.entity = g.entity
        new_post.schema = request.json['schema']
        new_post.content = request.json['content']

        new_post.save()

        # TODO: Do this asynchronously?
        for to_notify in g.entity.followers:
            notification_link = follow.get_notification_link(to_notify)
            requests.post(notification_link, data=jsonify(new_post.to_json()))
            # TODO: Handle failed notifications somehow

        return jsonify(new_post)
示例#6
0
文件: posts.py 项目: rlanger/Rondo
    def post(self):
        """ Used by apps to create a new post.

        Used by other servers to notify of a mention from a non-followed
        entity.

        TODO: Separate between apps creating a new post and a notification
        from a non-followed entity.
        """
        new_post = Post()
        new_post.entity = g.entity
        new_post.schema = request.json['schema']
        new_post.content = request.json['content']

        new_post.save()

        # TODO: Do this asynchronously?
        for to_notify in g.entity.followers:
            notification_link = follow.get_notification_link(to_notify)
            requests.post(notification_link, data=jsonify(new_post.to_json()))
            # TODO: Handle failed notifications somehow

        return jsonify(new_post)
示例#7
0
文件: posts.py 项目: rlanger/Rondo
 def get(self, post_id):
     return jsonify(g.entity.posts.get_or_404(id=post_id))
示例#8
0
文件: posts.py 项目: rlanger/Rondo
 def get(self):
     """Gets all posts"""
     return jsonify(g.entity.posts)
示例#9
0
 def put(self, follower_id):
     """Updates a following relationship."""
     return jsonify(
         follow.update_follower(g.entity, follower_id, request.json))
示例#10
0
 def put(self, follower_id):
     """Updates a following relationship."""
     return jsonify(follow.update_follower(
         g.entity, follower_id, request.json))
示例#11
0
def description():
    """Returns information about the server"""
    return jsonify({'description': __doc__, 'version': __version__})
示例#12
0
文件: entity.py 项目: rlanger/Rondo
 def get(self, schema):
     """Get a single profile."""
     return jsonify(g.entity.profiles.get_or_404(schema=schema))
示例#13
0
文件: entity.py 项目: rlanger/Rondo
 def get(self):
     """Return the profiles belonging to the entity"""
     return jsonify({p.schema: p.to_json() for p in g.entity.profiles})
示例#14
0
文件: posts.py 项目: rlanger/Rondo
 def get(self, post_id):
     return jsonify(g.entity.posts.get_or_404(id=post_id))
示例#15
0
 def post(self):
     """Starts following a user, defined by the post data"""
     return jsonify(follow.start_following(g.entity, request.json))
示例#16
0
 def post(self):
     """Starts following a user, defined by the post data"""
     return jsonify(follow.start_following(g.entity, request.json))
示例#17
0
 def get(self, follower_id):
     """Returns the json representation of a follower"""
     return jsonify(g.entity.followers.get_or_404(id=follower_id))
示例#18
0
 def get(self, follower_id):
     """Returns the json representation of a follower"""
     return jsonify(g.entity.followers.get_or_404(id=follower_id))
示例#19
0
文件: __init__.py 项目: rlanger/Rondo
def description():
    """Returns information about the server"""
    return jsonify({"description": __doc__, "version": __version__})
示例#20
0
文件: posts.py 项目: rlanger/Rondo
 def get(self):
     """Gets all posts"""
     return jsonify(g.entity.posts)