Beispiel #1
0
def add_wenjuan():
    usr = user_model()
    good = goods()
    username = session.get('user')
    family = 'wenjuan'
    title = request.form['title']
    descrip = request.form['descrip']
    money = request.form['money']

    close_date = request.form['close_date']
    people = request.form['people']

    error = None
    usr = user_model()
    temp = usr.query_userAll_info(username)
    user_money = int((temp[0])['money'])

    num = int(people)

    if user_money < int(money) * num:
        error = '余额不足,无法发布!'
        return render_template('add_wenjuan.html', error=error)
    else:
        good.add_goods(family, username, title, descrip, money, close_date,
                       people)
        usr.update_money(username, str(user_money - int(money) * num))
        error = '添加成功'
        return render_template('add_wenjuan.html', error=error)
Beispiel #2
0
def regist():
    error = None
    user = user_model()
    if request.method == 'GET':
        return render_template("regst.html")
    username = request.form.get('username')

    password = request.form.get('password1')
    repassword = request.form.get('password2')
    email = request.form.get('email')

    if request.method == "POST":
        if password == repassword:
            user = user_model()
            user_info = user.query_userAll_info(username)
            if user_info:
                error = '用户名重复,请重新输入!'
                return render_template("regst.html", error=error)
            else:
                user.regist(username, password, email)
                error = '注册成功!'
                return render_template('login.html', error=error)
        elif password != repassword:
            error = "密码不一致,请重新输入!"
            return render_template("regst.html", error=error)
    else:
        return render_template('regst.html', error=error)
Beispiel #3
0
def get_password():
    error = None
    username = request.form['username']
    if username != '':
        user = user_model()
        send_psw = info()
        password = user.query_user_password(username)
        if password[0] != '':
            sender = '*****@*****.**'

            recipients = user.query_user_email(username)
            subject = '你好,这是一封系统自动发送的邮件!(请勿回复)'
            content = 'test'
            email = (recipients[0])['email']
            html = "<b>您的密码是" + (password[0])['password'] + ",请妥善保管</b>"
            import app
            app.send_mail(subject, sender, [email], content, html)
            error = '已发送邮件,请注意查收'
            return render_template('login.html', error=error)
        else:
            error = '请输入正确用户名!'
            return render_template('contact.html', error=error)
    else:
        error = '请输入正确内容!'
        return render_template('contact.html', error=error)
Beispiel #4
0
def post_wenjuan(parm):
    username = session.get('user')
    user = user_model()
    # user_path = user.user_path(username)

    good = goods()
    tag_goods = good.query_all_goods(parm)

    return render_template('wenjuan.html', tag_goods=tag_goods)
Beispiel #5
0
def qingqiu(parm):
    username = parm
    user = user_model()
    sender = '*****@*****.**'
    recipients = user.query_user_email(username)
    subject = '你好,这是一封自动提醒邮件!(请勿回复)'
    content = '您已有一份订单被完成,请登陆确认' + + ''
    html = "<b>" + content + "</b>"
    print(recipients)
    email = (recipients[0])['email']
    app.send_mail(subject, sender, [email], content, html)

    return redirect(url_for('user.usercenter'))
Beispiel #6
0
def login():
    error = None
    if request.method == 'POST':
        username = request.form.get('username')
        password = request.form.get('password')
        user = user_model(username)
        rl_password = user.query_user_password(username)
        new = rl_password[0]
        if new['password'] == str(password):

            session['user'] = username

            return render_template('home.html')
        else:
            error = '密码或用户名错误,请重新输入!'
            return render_template('login.html', error=error)
    elif request.method == "GET":
        return render_template('login.html', error=error)
Beispiel #7
0
def usercenter2():
    username = session.get('user')
    user = user_model()
    user_content = info()
    # user_path = user.user_path(username)
    userAll_info = user.query_userAll_info(username)
    userAll_Done_display = user.query_userAll_display((userAll_info[0])['id'],
                                                      'done')
    userAll_undo_display = user.query_userAll_display((userAll_info[0])['id'],
                                                      'undo')
    userAll_display = user.query_userAll(username)

    chatRoom = user_content.query_TOuser(username)

    # if user_path:
    # user_path = "../static/user_head/200.png"

    return render_template('usercen2.html',
                           chatRoom=chatRoom,
                           userAll_info=userAll_info,
                           userAll_Done_display=userAll_Done_display,
                           userAll_undo_display=userAll_undo_display,
                           userAll_display=userAll_display)
Beispiel #8
0
def add_info(to_username):
    user = user_model()
    username = session.get('user')
    content = request.form['info']
    tag = ''
    if tag == 'yes':
        sender = '*****@*****.**'
        recipients = [user.query_user_email(to_username)]
        subject = '你好,这是一封自动提醒邮件!(请勿回复)'
        html = "<b>" + content + "</b>"
        infomation = info()
        email = (recipients[0])['email']
        import app
        app.send_mail(subject, sender, [email], content, html)

        infomation.insert_info(username, to_username, content)

        return redirect(url_for('info.show_info'))

    else:
        infomation = info()
        infomation.insert_info(username, to_username, content)

        return redirect(url_for('info.show_info'))
Beispiel #9
0
def home():
    username = session.get('user')
    user = user_model()
    user_path = user.user_path(username)

    return render_template('home.html', user_path=user_path)
Beispiel #10
0
def shoping(tag):
    error = None
    infoma = info()
    if tag == 'task':

        error = None
        username = session.get('user')

        goods_id = request.form['goods_id']
        good = goods()

        to_username = good.query_goodsByid(goods_id)

        user = user_model()

        sender = '*****@*****.**'
        recipients = user.query_user_email(username)
        email_temp = user.query_user_email((to_username[0])['username'])
        email = (email_temp[0])['email']
        subject = '你好,这是一封自动提醒邮件!(请勿回复)'
        to_email = (recipients[0])['email']
        content = '注意,您的一份订单已被用户' + email + '关注,请及时联系对方!'
        html = "<b>" + content + "</b>"
        import app
        app.send_mail(subject, sender, [to_email], content, html)
        error = '已成功向对方发送提醒邮件,请及时与对方联系!'
        return render_template('user_center.html', error=error)
        '''
        username = session.get('user')
        goods_id = request.form['goods_id']
        usr = user_model()
        good = goods()
        temp = usr.query_userAll_info(username)
        temp1 = good.query_money(goods_id)
        temp2 = good.query_user(goods_id)
        user_money = int((temp[0])['money'])
        goods_money = int((temp1[0])['money'])
        goods_user = str((temp2[0])['username'])
        id = int(goods_id)
        do =infoma.query_tagdo(id)

        do_tag = (do[0])['tag']
        if do_tag == 'done':
            error = '已成功向对方发送完成提醒邮件,请及时与对方联系!'
            money=user_money
            usr.update_money(username, money)

            return redirect(url_for('user.usercener',error=error))
        else:
            error='订单还未完成,请尽快完成'
            return redirect(url_for('user.usercener',error=error))
        '''
    elif tag == 'wenjuan':
        '''
        error = None
        username = session.get('user')
        goods_id = request.form['goods_id']
        usr = user_model()
        good = goods()
        temp = usr.query_userAll_info(username)
        temp1 = good.query_money(goods_id)
        temp2 = good.query_user(goods_id)
        user_money = int((temp[0])['money'])
        goods_money = int((temp1[0])['money'])
        goods_user = str((temp2[0])['username'])
        temp3 = usr.query_userAll_info(goods_user)
        goods_user_money = int((temp3[0])['money'])

        if user_money < goods_money:
            error = '错误,你的余额不足!'
            return render_template('', error=error)
        else:
            money = user_money - goods_money
            goods_user_money = goods_user_money + goods_money
            usr.update_money(username, money)
            usr.update_money(goods_user, goods_user_money)

            return redirect(url_for('user.usercenter', error=error))
        '''

    elif tag == 'second':
        error = None
        username = session.get('user')

        goods_id = request.form['goods_id']
        good = goods()

        to_username = good.query_goodsByid(goods_id)

        user = user_model()

        sender = '*****@*****.**'
        recipients = user.query_user_email(username)
        email_temp = user.query_user_email((to_username[0])['username'])
        email = (email_temp[0])['email']
        subject = '你好,这是一封自动提醒邮件!(请勿回复)'
        to_email = (recipients[0])['email']
        content = '注意,您的一份商品已被用户' + email + '关注,请及时联系对方!'
        html = "<b>" + content + "</b>"
        import app
        app.send_mail(subject, sender, [to_email], content, html)
        error = '已成功向对方发送提醒邮件,请及时与对方联系!'
        return render_template('user_center.html', error=error)
        '''