Esempio n. 1
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)
Esempio n. 2
0
 def post_contact_us(self, x):
     feedback = x.feedback
     print 'contact_us'
     try:
         xss_db.insert('feedback', content=feedback)
     except Exception as error:
         return utils.json_response(207, str(error))
     return utils.json_response(206)
Esempio n. 3
0
 def post_regiest(self, x):
     passwd = x.passwd
     email = x.email
     print "in regiest", email, passwd
     pwhash = hashlib.md5(passwd).hexdigest()
     try:
         xss_db.insert("user", name=email, email=email, pwhash=pwhash)
     except Exception as error:
         return utils.json_response(106, str(error))
     myvar = {"email": email, "pwhash": pwhash}
     t = xss_db.select("user", myvar, what="id", where="email=$email and pwhash=$pwhash")
     userid = t[0]["id"]
     web.ctx.session.user = email
     web.ctx.session.email = email
     web.ctx.session.userid = userid
     raise web.seeother("/today")
Esempio n. 4
0
 def post_add(self, x):
     title = None if 'title' not in x.keys() else x.title
     content = x.content
     atime = x.date
     userid = web.ctx.session.userid
     source = 'web'
     def format_atime(atime):
         a = [str(i) for i in atime.split('/')]
         if len(a[0]) == 1: a[0] = '0'+a[0]
         if len(a[1]) == 1: a[1] = '0'+a[1]
         b = ':'.join(a[::-1])
         return b + ' 12:00:00'
     atime = format_atime(atime)
     if not title:
         title = atime
     if not content or not atime:
         return utils.json_response(201, 'content or date is null')
     try:
         xss_db.insert('docu', title=title, content=content, userid=userid, source=source, atime=atime)
     except Exception as error:
         return utils.json_response(201, str(error))
     return utils.json_response(200)