Exemple #1
0
 def POST(self, uid):
     if web.input('m', _method='GET'):
         return self.POST_password(uid)
     
     form = forms.userinfo()
     i = web.input()
     if form.validates(i):
         i.pop('submit')
         db.update('users', where='id=$uid', vars=locals(), **i)
         helpers.set_msg('User information updated.')
         raise web.seeother('/%s' % uid)
     else:
         return self.GET(uid, info_form=form)
Exemple #2
0
 def GET(self, uid, info_form=None, password_form=None):
     try:
         user = db.select('users', where='id=$uid', vars=locals())[0]
     except IndexError:     
         raise web.notfound
     
     info_form = info_form or forms.userinfo()
     if not password_form:
         password_form = get_password_form(user)
         
     info_form.fill(**user)
     msg, msg_type = helpers.get_delete_msg()
     return render.userpage(uid, info_form, password_form, msg)
Exemple #3
0
    def POST(self, uid):
        i = web.input('m', _method='GET')
        if i.m == 'password':
            return self.POST_password(uid)

        form = forms.userinfo()
        i = web.input(_method='POST')
        if form.validates(i):
            if 'submit' in i: i.pop('submit')
            db.update('users', where='id=$uid', vars=locals(), **i)
            helpers.set_msg('User information updated.')
            raise web.seeother('/%s/preferences' % uid)
        else:
            return self.GET(uid, info_form=form)
Exemple #4
0
    def GET(self, uid, info_form=None, password_form=None):
        check_permission(uid)
        try:
            user = db.select('users', where='id=$uid', vars=locals())[0]
        except IndexError:
            raise web.notfound()

        info_form = info_form or forms.userinfo()
        if not password_form:
            password_form = get_password_form(user)

        info_form.fill(**user)
        msg, msg_type = helpers.get_delete_msg()
        return render.userpage(uid, info_form, password_form, msg)
Exemple #5
0
    def POST(self, uid):
        i = web.input("m", _method="GET")
        if i.m == "password":
            return self.POST_password(uid)

        form = forms.userinfo()
        i = web.input(_method="POST")
        if form.validates(i):
            if "submit" in i:
                i.pop("submit")
            db.update("users", where="id=$uid", vars=locals(), **i)
            helpers.set_msg("User information updated.")
            raise web.seeother("/%s/preferences" % uid)
        else:
            return self.GET(uid, info_form=form)
Exemple #6
0
def edit_info(req):
    #信息
    info = []
    info.append(req.user.username)
    info.append(req.user.email)
    message = []
    form = userinfoF()
    #存在用户信息
    if userinfo.objects.all().filter(user=req.user):
            sinfo = userinfo.objects.get(user=req.user)
            info.append(sinfo.pothon)
            info.append(sinfo.qq)
            info.append((sinfo.sign))
            # form = userinfoF(qq=sinfo.qq,sign=sinfo.sign,pothon=sinfo.pothon)
            if req.method == "POST":
                form = userinfoF(req.POST)
                sinfo.qq = form.cleaned_data['qq']
                sinfo.sign = form.cleaned_data['sign']
                sinfo.pothon = form.cleaned_data['pothon']
                sinfo.save()
                message.append('信息修改成功')
            return render(req,'edit_info.html',{'form':form,'info':info,'message':message,'loged':1,'tag':gettag(req)})
    else:
        if req.method=='POST':
            form = userinfoF(req.POST)
            if form.is_valid():
                usinfo = userinfo()
                usinfo.qq = form.cleaned_data['qq']
                usinfo.sign = form.cleaned_data['sign']
                usinfo.pothon = form.cleaned_data['pothon']
                usinfo.user = req.user
                usinfo.save()
                message.append('信息添加成功!!!')
        else:
            form = userinfoF()
        return render(req,'edit_info.html',{'form':form,'message':message,'loged':1,'info':info,'tag':gettag(req)})