예제 #1
0
파일: user_info.py 프로젝트: webmiss/base
 def Edit(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 参数
     data = self.Post('data')
     if not data: return self.GetJSON({'code': 4000, 'msg': '参数错误!'})
     param = Util.JsonDecode(data)
     # 数据
     model = UserInfoM()
     info = {
         'nickname': Util.Trim(param['nickname']),
         'name': Util.Trim(param['name']),
         'gender': Util.Trim(param['gender']),
         'birthday': Util.Strtotime(Util.Trim(param['birthday']),
                                    '%Y-%m-%d'),
         'position': Util.Trim(param['position']),
     }
     model.Set(info)
     model.Where('uid=%s', tData['uid'])
     model.Update()
     # 返回
     info['uname'] = tData['uname']
     info['img'] = param['img']
     info['birthday'] = Util.Date('%Y-%m-%d', info['birthday'])
     return self.GetJSON({'code': 0, 'msg': '成功', 'uinfo': info})
예제 #2
0
def json_info(user_id):
    user_id = int(user_id)
    user = Zsite.mc_get(user_id)
    namecard = namecard_get(user_id)
    user_info = UserInfo.get(user_id)
    data = {}
    if user_info:
        if user:
            data['cid'] = user.cid
            data['user_id'] = user_id
            data['self_intro'] = user.txt
            data['name'] = user.name
            data['ico'] = ico_url(user_id) or ''
            data['moto'] = motto.get(user_id)
            data['user_link'] = 'http:%s'%user.link
            data['sex'] = user_info.sex
            data['marry'] = user_info.marry
            data['follower_num'] = follow_count_by_to_id(user_id)
            data['following_num'] = follow_count_by_from_id(user_id)
            data['verify_state'] = user.state
            data['pic'] = ico.get(user_id)
            if namecard:
                if namecard.pid_now:
                    data['place_now_name'] = namecard.place_now
                    data['place_now'] = namecard.pid_now
            if user_info.pid_home:
                data['place_home_name'] = user_info.place_home
                data['place_home'] = user_info.pid_home
    return data
예제 #3
0
    def post(self, id):
        zsite = Zsite.mc_get(id)
        user_info = UserInfo.get(id)

        name = self.get_argument('name', None)
        motto = self.get_argument('motto', None)
        txt = self.get_argument('txt', '')
        sex = self.get_argument('sex', 0)

        if name:
            zsite.name = name
            zsite.save()

        if motto:
            _motto.set(id, motto)

        if txt:
            txt_new(id, txt)

        if sex:
            user_info.sex = sex
            user_info.save()

        search_new(id)
        self.redirect('/zsite/%s' % id)
예제 #4
0
 def Token(self):
   # 验证
   token = self.Post('token')
   msg = ApiToken.Verify(token, '')
   if msg != '' : return self.GetJSON({'code':4001, 'msg':msg})
   # 参数
   uinfo = self.Post('uinfo')
   tData = ApiToken.Token(token)
   if uinfo!='1' : return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time']})
   # 用户信息
   model = UserInfo()
   model.Columns('nickname','position','name','img')
   model.Where('uid=%s',tData['uid'])
   info = model.FindFirst()
   info['uname'] = tData['uname']
   info['img'] = Data.Img(info['img'])
   return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time'], 'uinfo':info})
예제 #5
0
파일: user_info.py 프로젝트: webmiss/base
 def List(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 查询
     model = UserInfoM()
     model.Columns('nickname', 'name', 'gender',
                   'FROM_UNIXTIME(birthday, %s) as birthday', 'position',
                   'img')
     model.Where('uid=%s', '%Y-%m-%d', str(tData['uid']))
     list = model.FindFirst()
     # 数据
     list['img'] = Data.Img(str(list['img']))
     # 返回
     return self.GetJSON({'code': 0, 'msg': '成功', 'list': list})
예제 #6
0
파일: user_info.py 프로젝트: webmiss/base
 def Upimg(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 参数
     base64 = self.Post('base64')
     if not base64: return self.GetJSON({'code': 4000, 'msg': '参数错误!'})
     # 上传
     img = Upload.Base64({'path': self.ImgDir, 'base64': base64})
     if not img: return self.GetJSON({'code': 5000, 'msg': '上传失败!'})
     # 数据
     model = UserInfoM()
     model.Columns('img')
     model.Where('uid=%s', tData['uid'])
     imgData = model.FindFirst()
     model.Set({'img': self.ImgDir + img})
     model.Where('uid=%s', tData['uid'])
     if not model.Update():
         return self.GetJSON({'code': 5000, 'msg': '上传失败!'})
     # 清理
     rmImg = imgData['img']
     FileEo.RemoveAll(rmImg)
     # 返回
     return self.GetJSON({
         'code': 0,
         'msg': '成功',
         'img': Data.Img(self.ImgDir + img)
     })
예제 #7
0
 def get(self, id):
     zsite = Zsite.mc_get(id)
     if zsite:
         info = UserInfo.get(id)
         if info:
             sex = info.sex
         else:
             sex = ''
         txt = txt_get(id)
         self.render(txt=txt, zsite=zsite, sex=sex)
     else:
         self.redirect('/')
예제 #8
0
 def get(self):
     current_user_id = self.current_user_id
     current_user = self.current_user
     motto = _motto.get(current_user_id)
     txt = txt_get(current_user_id)
     o = UserInfo.mc_get(current_user_id) or JsDict()
     c = namecard_get(current_user_id) or JsDict()
     self.render(
         name=current_user.name,
         motto=motto,
         txt=txt,
         birthday='%08d' % (o.birthday or 0),
         marry=o.marry,
         pid_home=o.pid_home or 0,
         pid_now=c.pid_now or 0,
         sex=o.sex
     )
예제 #9
0
    def post(self):

        current_user = self.current_user
        current_user_id = current_user.id
        result = {}
        error = {}


        name = self.get_argument('name', None)
        if not name:
            error['name'] = '请输入姓名'

        sex = None
        info = _UserInfo.mc_get(current_user_id)
        if not (info and info.sex):
            sex = self.get_argument('sex', '0')
            if not(sex and int(sex) in (1, 2)):
                error['sex'] = '请选择性别'

        password = None
        if not UserPassword.get(current_user_id):
            password = self.get_argument('password', None)
            if not password:
                error['password'] = '******'

        if not error:
            if password:
                user_password_new(current_user_id, password)

            if sex:
                user_info_new(current_user_id, sex=sex)

            current_user.name = name
            current_user.save()
        else:
            result['error'] = error

        self.finish(result)
예제 #10
0
    def post(self):
        name = self.get_argument('name', None)
        sex = self.get_argument('sex', '0')
        errtip = Errtip()
        current_user = self.current_user
        current_user_id = current_user.id

        info = _UserInfo.mc_get(current_user_id)
        if not (info and info.sex):
            if not (sex and int(sex) in (1, 2)):
                errtip.sex = '请选择性别'

        password = UserPassword.get(current_user_id)
        if not password:
            password = self.get_argument('password', None)
            if not password:
                errtip.password = '******'
            else:
                user_password_new(current_user_id, password)

        if name:
            current_user.name = name
            current_user.save()

        if not errtip:
            path = '/i/guide'
            user_info_new(current_user.id, sex=sex)
            return self.redirect(path)

        id_list = SHOW_LIST
        zsite_list = filter(bool, Zsite.mc_get_list(id_list))
        return self.render(
            sex=sex,
            name=name,
            errtip=errtip,
            zsite_list=zsite_list,
        )
예제 #11
0
    def post(self):
        name = self.get_argument('name', None)
        sex = self.get_argument('sex', '0')
        errtip = Errtip()
        current_user = self.current_user
        current_user_id = current_user.id

        info = _UserInfo.mc_get(current_user_id)
        if not (info and info.sex):
            if not(sex and int(sex) in (1, 2)):
                errtip.sex = '请选择性别'

        password = UserPassword.get(current_user_id)
        if not password:
            password = self.get_argument('password', None)
            if not password:
                errtip.password = '******'
            else:
                user_password_new(current_user_id, password)

        if name:
            current_user.name = name
            current_user.save()

        if not errtip:
            path = '/i/guide'
            user_info_new(current_user.id, sex=sex)
            return self.redirect(path)

        id_list = SHOW_LIST
        zsite_list = filter(bool, Zsite.mc_get_list(id_list))
        return self.render(
                   sex=sex,
                   name=name,
                   errtip=errtip,
                   zsite_list=zsite_list,
               )