示例#1
0
def mytest_index(request):

    ip_address = ip_address_handler.get_client_ip(request)
    ip_address_handler.save_access_information(ip_address)

    request.session['ip'] = ip_address

    goods_getter = GoodsGetter()
    designers_getter = DesignersGetter()

    recommend_num = 3
    designer_num = 3

    index_goods_list = goods_getter.get_recommend_goods(recommend_num)
    index_designers_list = designers_getter.get_recommend_designers(
            designer_num)
    customer = None
    if request.user.is_authenticated():
        try:
            customer = Customer.objects.get(user_id=request.user.id)
        except ObjectDoesNotExist:
            customer = None
    conf = {'goods_list':
            index_goods_list,
            'all_designer':
            index_designers_list,
            'customer': customer,
            'goods_server_path': adminer_website.goods_server_path,
            }

    return render(request, website.v1_1_index, conf)
示例#2
0
def new_index(request):

    goods_getter = GoodsGetter()
    designers_getter = DesignersGetter()

    recommend_num = 7
    designer_num = 5

    index_goods_list = goods_getter.get_recommend_goods(recommend_num)
    index_designers_list = designers_getter.get_recommend_designers(
            designer_num)
    customer = None
    if request.user.is_authenticated():
        try:
            customer = Customer.objects.get(user_id=request.user.id)
        except ObjectDoesNotExist:
            customer = None
    conf = {'goods_list':
            index_goods_list,
            'all_designer':
            index_designers_list,
            'customer': customer
            }

    return render(request, website.new_index, conf)
示例#3
0
def new_all_goods(request):
    goods_getter = GoodsGetter()
    goods_list = goods_getter.get_all_goods()
    conf = {'goods_list':
            goods_list
            }
    return render(request, website.all_goods, conf)
示例#4
0
def goods_detail(request):
    # for test
    # goods_id = 1

    # goods_id = request.GET.get('goods_id', None)
    goods_id = request.GET['goods_id']
    goods = Goods.objects.get(id=goods_id)
    imgs = get_goods_imgs(goods)
    designer_id = goods.designer_id
    designer = Customer.objects.get(id=designer_id)
    designer_has_marked = False
    customer = None

    goods_getter = GoodsGetter()
    goods_list = goods_getter.get_all_goods()

    if request.user.is_authenticated():
        try:
            customer = Customer.objects.get(user_id=request.user.id)
            if designer in customer.marked_customer.all():
                designer_has_marked = True
        except ObjectDoesNotExist:
            designer_has_marked = False

    context = {'goods': goods,
               'designer': designer,
               'imgs': imgs,
               'designer_has_marked': designer_has_marked,
               'customer': customer,
               'goods_list3': goods_list[3],
               'goods_list7': goods_list[7],
               'goods_list5': goods_list[5],
               }

    return render(request, website.v1_1_detail, context)
示例#5
0
def test_goods_list(request):
    '''
    tests the goods list
    This is a temparory page

    Return: The static goods list page
    '''

    goods_getter = GoodsGetter()
    goods_list = goods_getter.get_all_goods()
    customer = get_customer(request)
    conf = {'goods_list':
            goods_list,
	    'customer':
            customer,
            }
    return render(request, 'shopping_home/v1_1/list.html', conf)