Exemple #1
0
 def post(self):
         
     data = _parse.parse_args()
     
     user = User.get_user_by_name(data['sender'])
     print(user)
     clip = ClipboardModel(**data, creator=user)
     clip.save_into_db()
     
     return {"message": "Clipboard added successfully", "response": 201}, 201
Exemple #2
0
 def delete(self, user_uuid):
     user = UserModel.get_user_by_uuid(user_uuid)
     if user is None:
         return {"clips": [], "response": 404}, 201
     
     user_id = user_uuid
     [clip.delete_from_db() for clip in ClipboardModel.get_clips_by_sender_id(user_id).all()]
     return {"message": "clip data deleted for user {}".format(user_uuid), "response": 201}, 201
Exemple #3
0
    def get(self, user_uuid, n):
        user = UserModel.get_user_by_uuid(user_uuid)
        if user is None:
            # return {"message": "No user found with UID : {}".format(user_id)}, 404
            return {"clips": [], "response": 404}, 201

        user_id = user_uuid
        
        clips = []
        return {"clips": [clip.json() for clip in ClipboardModel.get_clips_by_sender_id(user_id).limit(n).all()], "response": 201}, 201
Exemple #4
0
    def put(self, user_uuid, n):
        
        user = UserModel.get_user_by_uuid(user_uuid)
        if user is None:
            # return {"message": "No user found with UID : {}".format(user_id)}, 404
            return {"clip": {}, "response": 404}, 201

        elif n is not 1:
            # return {"message": "Post can not be applied on bulk query"}, 400
            return {"clip": {}, "response": 400}, 201

        else:
            
            user_id = user_uuid
        
            clip = ClipboardModel.get_clips_by_reciever_id(user_id).first()
           
            clip.update_db()
            return {"clip": clip.json(), "response": 201}, 201