示例#1
0
def log(request):
    if request.user.is_authenticated():
        if request.user.user_profile.is_active:
            pwd_forms = ChangeForm()
            sql = 'select c.asin,a.integral,a.createtime,CASE  WHEN status= 0 THEN "未检测"  ELSE "成功" END AS review_status,CASE  WHEN a.`option`= 0 THEN "自导"  ELSE "系统" END AS option_type,b.name from cart_log a left join account b on a.account_id= b.id left join cart c on a.cart_id = c.id where a.createuser_id=%s order by a.id desc' % request.user.id
            cursor = connection.cursor()
            cursor.execute(sql)
            results = cursor.fetchall()
            print connection.queries
            columns = [column[0] for column in cursor.description]
            datas = []
            for row in results:
                datas.append(dict(zip(columns, row)))

            items = []
            for data in datas:
                for k, v in data.iteritems():
                    if isinstance(v, datetime):
                        data[k] = v.strftime('%Y-%m-%d %H:%M:%S')
                items.append(data)
            template = loader.get_template('cart_log.html')
            context = {
                "cart_log": "active",
                "pwd_forms": pwd_forms,
                "username": request.user.username,
                "logs": items
            }
            return HttpResponse(template.render(context, request))
        else:
            return HttpResponseRedirect('/notice/')
    else:
        return HttpResponseRedirect('/login/')
示例#2
0
文件: views.py 项目: starletty/review
def tutorial_bak(request):
    if request.user.is_authenticated():
        pwd_forms = ChangeForm()
        template = loader.get_template('tutorial/review.html')
        context = {
            "course_task": "active",
            "pwd_forms": pwd_forms,
            "username": request.user.username
        }
        return HttpResponse(template.render(context, request))
    else:
        return HttpResponseRedirect('/login/')
示例#3
0
def index_bak(request):
    pwd_forms = ChangeForm()
    forms = AccountForm()
    tags = Tag.objects.all()
    template = loader.get_template('account.html')
    context = {
        "account": "active",
        "forms": forms,
        "tags": tags,
        "username": request.user.username,
        "pwd_forms": pwd_forms
    }
    return HttpResponse(template.render(context, request))
示例#4
0
文件: views.py 项目: starletty/review
def daily_buyer(request):
    if request.user.is_authenticated():
        if request.user.user_profile.is_active:
            pwd_forms = ChangeForm()
            template = loader.get_template('daily_buyer.html')
            context = {
                "daily_buyer": "active",
                "pwd_forms": pwd_forms,
                "username": request.user.username
            }
            return HttpResponse(template.render(context, request))
        else:
            return HttpResponseRedirect('/notice/')
    else:
        return HttpResponseRedirect('/login/')
示例#5
0
文件: views.py 项目: starletty/review
def index(request):
    if request.user.is_authenticated():
        if request.user.user_profile.is_active:
            forms = TaskForm()
            pwd_forms = ChangeForm()
            template = loader.get_template('review.html')
            context = {
                "task": "active",
                "forms": forms,
                "pwd_forms": pwd_forms,
                "username": request.user.username
            }
            return HttpResponse(template.render(context, request))
        else:
            return HttpResponseRedirect('/notice/')
    else:
        return HttpResponseRedirect('/login/')
示例#6
0
def index(request):
    if request.user.is_authenticated():
        if request.user.user_profile.is_active:
            pwd_forms = ChangeForm()
            forms = AccountForm()
            tags = Tag.objects.all()
            template = loader.get_template('account.html')
            context = {
                "account": "active",
                "forms": forms,
                "tags": tags,
                "username": request.user.username,
                "pwd_forms": pwd_forms
            }
            return HttpResponse(template.render(context, request))
        else:
            return HttpResponseRedirect('/notice/')
    else:
        return HttpResponseRedirect('/login/')
示例#7
0
文件: views.py 项目: starletty/review
def index(request):
    if request.user.is_authenticated():
        if request.user.user_profile.is_active:
            forms = Ab2Form()
            cursor = connection.cursor()
            sql = "select count(id) from ab3_log where msg like \"加购成功%%\" and createtime between %s and %s"
            params = []
            params.append(
                (datetime.datetime.now() +
                 datetime.timedelta(hours=0)).strftime('%Y-%m-%d 00:00:00'))
            params.append(
                (datetime.datetime.now() +
                 datetime.timedelta(hours=0)).strftime('%Y-%m-%d 23:59:59'))
            cursor.execute(sql, params)
            d1_count = cursor.fetchall()[0][0]
            sql = "select count(id) from ab3_log where msg like \"加购成功%%\" and createtime between %s and %s"
            params = []
            params.append(
                (datetime.datetime.now() +
                 datetime.timedelta(hours=0)).strftime('%Y-%m-%d %H:00:00'))
            params.append(
                (datetime.datetime.now() +
                 datetime.timedelta(hours=0)).strftime('%Y-%m-%d %H:59:59'))
            cursor.execute(sql, params)
            h1_count = cursor.fetchall()[0][0]
            pwd_forms = ChangeForm()
            tags = Tag.objects.all()
            template = loader.get_template('ab2.html')
            context = {
                "ab2": "active",
                "forms": forms,
                "pwd_forms": pwd_forms,
                "username": request.user.username,
                "tags": tags,
                "d1_count": d1_count,
                "h1_count": h1_count
            }
            return HttpResponse(template.render(context, request))
        else:
            return HttpResponseRedirect('/notice/')
    else:
        return HttpResponseRedirect('/login/')