def get(self,key): user_key = self.get_secure_cookie("user_key") pinHate = PinHate() l_key = hashlib.md5("%s%s" % (user_key,key)).hexdigest() res = {} res['code'] = 0 res['msg'] = "成功" pinHate.delete(l_key) res_str = json.dumps(res) self.write(res_str)
def get(self,key): user_key = self.get_secure_cookie("user_key") pinHate = PinHate() l_key = hashlib.md5("%s%s" % (user_key,key)).hexdigest() l_data = pinHate.get(l_key) res = {} if l_data: res['code'] = 1 res['msg'] = "您已讨厌过" else : pinHate.key = l_key pinHate.data['user'] = user_key pinHate.data['pin'] = key pinHate.data['createTime'] = int(time.time()) pinHate.post() pin =Pin() data = pin.get(key) pin.key = key pin.data = data pin.data['hate'] = int(data['hate']) - 1 pin.put() dump(data) res['code'] = 0 res['msg'] = "成功" res_str = json.dumps(res) self.write(res_str)
def get(self,key): pin = Pin() pin_data = pin.getPinDetail(key) user_key = self.get_secure_cookie("user_key") _l_data = {} _h_data = {} if user_key: pinLike = PinLike() pinHate = PinHate() l_key = hashlib.md5("%s%s" % (user_key,key)).hexdigest() h_key = l_key l_data = pinLike.get(l_key) h_data = pinHate.get(h_key) if l_data: _l_data['str'] = "取消喜欢" _l_data['rel'] = 1 else: _l_data['str'] = "喜欢" _l_data['rel'] = 0 if h_data: _h_data['str'] = "取消讨厌" _h_data['rel'] = 1 else: _h_data['str'] = "讨厌" _h_data['rel'] = 0 else: _l_data['str'] = "喜欢" _l_data['rel'] = 0 _h_data['str'] = "讨厌" _h_data['rel'] = 0 #print pin_data self.render('mark_template.html',user=self.currentUserInfo(),mark=pin_data,like = _l_data,hate = _h_data)