示例#1
0
文件: view.py 项目: Waywei/www
def test():
    namefield = k()
    if request.method == "POST":
        csrf_check()
        namefield.text = request.form["name"]
        if not namefield.text or len(namefield.text) > 20:
            namefield.error = u"not empty"

    return render('test.jade',locals())
示例#2
0
文件: user.py 项目: Waywei/www
def forgetpassword():
    form = ForgetForm()
    if form.validate_on_submit():
        email = form.data['email'].lower()
        name = form.data['username'].lower()
        try:
            user = User.query.filter_by(email = email).first()
        except:
            user = None
        if user and user.username == name:
            result = r.get("resetuser:%s" % email)
            if result:
                finished = k()
                finished.title = u"重新设置密码"
                finished.content = u"重新设置密码的功能在24小时只能使用一次"
                return render('finished.jade',locals())

            uuid = uuid4() 
            pipe = r.pipeline()
            pipe.set("reset:%s" % uuid,email)
            pipe.expire("reset:%s" % uuid,60*60*24)
            pipe.set("resetuser:%s" % email,"1")
            pipe.expire("resetuser:%s" % email,60*60*24)
            pipe.execute()

            subject = u"重新设置密码-BEARWAVE"
            reseturl = "http://www.bearwave.com/resetpassword/"+str(uuid) 
            text = '''

            这是一封系统自动发送的邮件,不能直接回复。
            如果当前操作不是您本人的所为,请忽略这个邮件,但这类操作意味着可能有人对您的隐私有兴趣。

            修改密码可以访问下面的连接
            '''
            msg = text+reseturl
            send_email(email,subject,msg)
            finished = k()
            finished.title = u"重新设置密码"
            finished.content = u"邮件已发送,请注意垃圾邮件箱"
            return render('finished.jade',locals())
        else:
            error = u"邮箱与用户名不匹配"

    return render('/forgetpassword.jade',locals())
示例#3
0
文件: view.py 项目: Waywei/www
def topic_atom():
    xml = r.get("feed:topic")
    if not xml:
        topics = Topic.query\
                .order_by(Topic.create_time.desc()).limit(10).all()
        site = k()
        site.title= u"bearwave 话题"
        site.subtitle = u"最近的话题"
        site.url = u"http://www.bearwave.com"
        site.atomurl = u"http://www.bearwave.com/atom.xml"
        site.topics = topics
        site.time = datetime.now()
        xml =  render('/feed/topic.xml',locals())
        r.setex("feed:topic",xml,60*60)
    return Response(xml, mimetype='text/xml')
示例#4
0
文件: view.py 项目: Waywei/www
def interview_atom():
    xml = r.get("feed:interview")
    if not xml:
        interviews = Interview.query\
                .order_by(Interview.create_time.desc()).limit(10).all()
        site = k()
        site.title= u"bearwave 访谈"
        site.subtitle = u"不同的生活经历,得到不同的生活经验,把他们留给年轻人是一件非常有意义的事情"
        site.url = u"http://www.bearwave.com/interview"
        site.atomurl = u"http://www.bearwave.com/interview/atom.xml"
        site.topics = interviews
        site.time = datetime.now()
        xml =  render('/feed/interview.xml',locals())
        r.setex("feed:interview",xml,60*60)
    return Response(xml, mimetype='text/xml')