Пример #1
0
 def post_account_setting(self, x):
     keys = x.keys()
     if "email" in keys:
         email = x.email
         if email.strip():
             userid = web.ctx.session.userid
             try:
                 xss_db.update("user", where="id=$userid", name=email, email=email, vars=locals())
             except Exception as error:
                 return utils.json_response(205, str(error))
             web.ctx.session.user = email
             web.ctx.session.email = email
     if "oldpass" in keys and "newpass" in keys and "confirmpass" in keys:
         passwd = (x.oldpass).strip()
         newpasswd = (x.newpass).strip()
         confirmpasswd = (x.confirmpass).strip()
         if passwd and newpasswd and confirmpasswd:
             pwhash = hashlib.md5(passwd).hexdigest()
             result = xss_db.query(
                 "select count(*) as count from user where id=$userid and pwhash=$pwhash",
                 vars={"userid": web.ctx.session.userid, "pwhash": pwhash},
             )
             if not result[0].count == 1:
                 error = "passwd is error"
                 return utils.json_response(205, str(error))
             web.ctx.session.user = email
             if not newpasswd == confirmpasswd:
                 error = u"两次输入的密码不相同"
                 return utils.json_response(205, str(error))
             web.ctx.session.user = email
             try:
                 xss_db.update("user", where="id=$userid", pwhash=pwhash, vars=locals())
             except Exception as error:
                 return utils.json_response(205, str(error))
     return utils.json_response(204)
Пример #2
0
 def post_email_settings(self, x):
     past = (x.past).strip()
     sendtime = x.sendtime
     userid = web.ctx.session.userid
     try:
         xss_db.update("user", where="id=$userid", sendtime=sendtime, past=past, vars=locals())
     except Exception as error:
         return utils.json_response(107, str(error))
     return utils.json_response(108)
Пример #3
0
 def post_edit(self, x):
     title = None if 'title' not in x.keys() else x.title
     content = None if 'content' not in x.keys() else x.content
     docu_id = x.docu_id
     source = 'web'
     try:
         if title:
             xss_db.update('docu', where='id=$docu_id', title=title, vars=locals())
         if content:
             xss_db.update('docu', where='id=$docu_id', content=content, vars=locals())
     except Exception as error:
         return utils.json_response(199, str(error))
     return utils.json_response(198)
Пример #4
0
 def post_email_frequency(self, x):
     print x
     userid = web.ctx.session.userid
     if x["sendemails"] == u"2":
         if not "days[]" in x.keys():
             return utils.json_response(203, "i need a this key :days[]")
         try:
             xss_db.update(
                 "user", where="id=$userid", frequency=x["sendemails"], weekly=str(x["days[]"]), vars=locals()
             )
         except Exception as error:
             return utils.json_response(203, str(error))
     elif x["sendemails"] == u"1":
         try:
             xss_db.update("user", where="id=$userid", frequency=x["sendemails"], vars=locals())
         except Exception as error:
             return utils.json_response(203, str(error))
     elif x["sendemails"] == u"0":
         try:
             xss_db.update("user", where="id=$userid", frequency=x["sendemails"], vars=locals())
         except Exception as error:
             return utils.json_response(203, str(error))
         try:
             xss_db.insert("feedback", userid=userid, content=x["neverfeedback"])
         except Exception as error:
             return utils.json_response(203, str(error))
     else:
         error = "sendmails 不是预期的的 0,1,2"
         return utils.json_response(203, str(error))
     return utils.json_response(202)