Example #1
0
 def delete(self, userId):
     if userId == "me":
         valid, req = oauth.verify_request([])
         if not valid:
             raise AuthorizationRequired()
         unfollow = followParser.parse_args()["otherUser"].split(",")
         others = [User.get_by_id(u) for u in unfollow]
         req.user.unfollow(others)
         return {"success": True}
Example #2
0
 def post(self, userId):
     if userId == "me":
         valid, req = oauth.verify_request([])
         follow = followParser.parse_args()["otherUser"].split(",")
         if not valid:
             raise AuthorizationRequired()
         user = req.user
         others = [User.get_by_id(f) for f in follow]
         user.follow(others)
         return {"success": True}
Example #3
0
    def delete(self, userId):
        """Unsubscribe the user from a podcast."""
        podcast = podcastsParser.parse_args()["podcast"]
        if userId == "me":
            valid, req = oauth.verify_request([])
            if not valid:
                raise AuthorizationRequired()
            user = req.user
        else:
            user = User.get_by_id(userId)

        return user.unsubscribe_by_url(podcast)
Example #4
0
 def get(self, userId):
     """Get all the user's subscriptions."""
     if userId == "me":
         valid, req = oauth.verify_request([])
         if not valid:
             raise AuthorizationRequired()
         user = req.user
     else:
         user = User.get_by_id(userId)
     if not user:
         abort(404, message="User not found.")
         return
     return user.get_subscriptions()
Example #5
0
    def get(self, userId):
        """Get a user."""
        if userId == "me":
            valid, req = oauth.verify_request(["publicuserinfo/read"])
            if not valid:
                raise AuthorizationRequired()
            user = req.user
        else:
            user = User.get_by_id(userId)

        if not user:
            abort(404, message="User not found: %s." % userId)
            return

        # make sure the client is authorized to get the user's email.
        valid, req = oauth.verify_request(["userinfo/email"])
        if not (valid and (userId == "me" or userId == req.user.id)):
            return AttributeHider(user, ["primary_email"])
        return user
Example #6
0
 def get_node(cls, id):
     cls.from_db_user(DBUser.get_by_id(id))
Example #7
0
 def get(self, userId):
     user = User.get_by_id(userId)
     return user.following
Example #8
0
 def user(self):
     return User.get_by_id(self.user_id)