Beispiel #1
0
def tickerdash():
    loginform = loginForm()
    buyertic = Product.getbuyer(current_user.email())
    creatortic_raw = Product.getcreator(current_user.email())
    creatortic = []
    for x in creatortic_raw:
        title = x.get('title')
        url = x.get('url')
        temp_ticket_count = 0
        for xx in x.get('orderdict'):
            temp_ticket_count = int(xx.get('much')) + int(temp_ticket_count)
        crawdict = {"url": url, "title": title, "much": temp_ticket_count}
        creatortic.append(crawdict)
    return render_template('tdash.html', **locals())
Beispiel #2
0
def bfreq():
    try:
        cmail =  current_user.email()
    except Exception as e:
        return '無管理權限'
        
    if not dbadm.usercheck(cmail) :
        return '無管理權限'
Beispiel #3
0
def porbill():
    if request.method == 'POST':
        loop1 = [1]
        buydict = request.cookies.get('buydict')
        allmoney = 0
        if buydict is None:
            buyinfo = []
        else:
            buydict = ast.literal_eval(str(buydict))
            buyinfo = []
            for x in buydict:
                title = Product.getdata(
                    str(x).rsplit('-', 1)[0]).get('orderdict')[int(
                        str(x).rsplit('-', 1)[1])].get('name')
                price = Product.getdata(
                    str(x).rsplit('-', 1)[0]).get('orderdict')[int(
                        str(x).rsplit('-', 1)[1])].get('cost')
                url = Product.getdata(str(x).rsplit('-', 1)[0]).get('url')
                tid = Product.getdata(str(x).rsplit(
                    '-',
                    1)[0]).get('orderdict')[int(str(x).rsplit('-',
                                                              1)[1])].get('id')
                much = int(buydict.get(x))
                price = int(price)
                tempinfo = [title, price, much]
                buyinfo.append(tempinfo)
                allmoney = allmoney + (price * much)
                if Product.ticupdate(url, tid, much) == 'NoTic':
                    return render_template('err_tic.html', **locals())

                Product.ticadd(tid, url, title, current_user.name(),
                               current_user.info().get('phone'),
                               current_user.email(), much, int(price * much))
            loginform = loginForm()
            pform = productForm()
        response = make_response(
            render_template('proinfo-shop03.html', **locals()))
        response.set_cookie('num', '', expires=0)
        response.set_cookie('buydict', '', expires=0)
        return response
Beispiel #4
0
def submitpro():
    loginform = loginForm()
    form = submitclassinfo()
    if request.method == 'GET':
        return render_template('lesson.html', **locals())
    elif request.method == 'POST' and form.validate_on_submit() and len(
            list(filter(None, request.form.getlist('ticket[]')))) >= 3:
        address = form.address.data
        link = form.link.data
        flavor = form.organize.data
        organize = current_user.name()
        daterange = form.daterange.data
        labout = form.labout.data
        cover = url_for('serve_picture',
                        sha1=uploadcover(base64.b64decode(
                            form.cover.data[23:])))
        name = form.name.data
        name_pinyin = p.get_pinyin(str(name)).replace('-',
                                                      '').replace(' ',
                                                                  '')[0:14]
        url = str(
            datetime.datetime.now().strftime('%y%m%d%H%M')) + '-' + name_pinyin
        content = form.content.data
        ticket = request.form.getlist('ticket[]')
        count = 0
        dticket = []
        for x, y, z in zip(ticket[0::3], ticket[1::3], ticket[2::3]):
            dtickettemp = {"id": count, "name": x, "cost": y, "much": z}
            count = count + 1
            dticket.append(dtickettemp)
        Product.init(False, current_user.email(), url, False, name, labout,
                     cover, daterange, address, link, flavor, organize,
                     content, "noproddata", dticket)
        return redirect(url_for('classrom.showverinfo'))

    else:
        """偷懶debug區"""
        """不要送任何可以測資讓認證可過即可直接測試"""
        return render_template('reg_err.html', **locals())
Beispiel #5
0
def tickemem(url):
    loginform = loginForm()
    if current_user.email() == Product.geturlcreator(url):
        title = Product.geturlname(url)
        ticitem = Product.getticmem(url)
        return render_template('tmem.html', **locals())
Beispiel #6
0
 def validateEmail(self, email):
     if email.data != current_user.email():
         user = db.students.find({"email": email})
         if user:
             raise ValidationError(
                 "That email is taken. Please choose a different one.")