예제 #1
0
 def POST(self):
     i = web.input()
     uid = int(i.uid)
     user = web.ctx.orm.query(User).get(uid)
     email = i.email.strip()
     url = i.url.strip()
     pw1 = i.get("pw1", "")
     pw2 = i.get("pw2", "")
     if not email:
         msg = "Email is required!"
         return admin_render.profile(user=user, msg=msg)
     if pw1:
         if pw2:
             if pw1 != pw2:
                 msg = "Password is not the same."
                 return admin_render.profile(user=user, msg=msg)
             else:
                 user.password = hashlib.md5(pw1).hexdigest()
         else:
             msg = "You must confirm your password!"
             return admin_render.profile(user=user, msg=msg)
     user.email = email
     user.url = url
     web.ctx.orm.commit()
     msg = "Changes has been saved!"
     return admin_render.profile(user=user, msg=msg)
예제 #2
0
 def GET(self):
     i = web.input()
     uid = i.get("uid", "")
     if uid:
         user = web.ctx.orm.query(User).get(int(uid))
     else:
         user = web.ctx.orm.query(User).get(int(web.ctx.session.uid))
     if not user:
         raise web.notfound()
     return admin_render.profile(user=user)