Esempio n. 1
0
 def update_user_profile(cls, email: str, data: dict) -> dict:
     print(
         f"[PROFILE SERVICE] Updating profile [email:{email}, data:{data}]")
     user_ins = User.get().where(User.email == email)
     try:
         Profile.update(username=data.get("username"),
                        grade=data.get("grade"),
                        contact_info=data.get("contact_info"),
                        avatar_id=data.get("avatar_id")).where(
                            Profile.id == user_ins.profile_id).execute()
     except:
         return {"status": False, "message": "Profile update failed"}
Esempio n. 2
0
 def add_avatar(cls, email, content, file_format):
     user_id = User.get().where(User.email == email).id
     query = Image.select().where(
         Image.user_id == user_id & Image.type == "avatar")
     if query.exists():
         image_id = query.get().id
     else:
         image_id = None
     avatar_id = Image.add(user_id=user_id,
                           content=content,
                           type="avatar",
                           image_id=image_id,
                           image_format=file_format)
     return avatar_id