Пример #1
0
def page_designers(request):
    '''
    deisgner's page

    '''
    designers_getter = DesignersGetter()
    designers_temp_list = designers_getter.get_all_designers()
    show_num = 100
    page_num = int(request.POST['page'])
    start_num = (page_num - 1) * show_num
    end_num = min(start_num + show_num,len(designers_temp_list))
    designers_list = designers_temp_list[start_num:end_num]
    page_list = []
    for designer in designers_list:
        goods_list = []
        for goods in designer.goods_list:
            goods_temp = (goods.id,goods.thumbnail_1)
            goods_list.append(goods_temp)
        designer_list = (designer.id,designer.icon,designer.name,designer.work_number,goods_list,designer.scan_number)
        page_list.append(designer_list)

    conf = {
        'page_list':page_list,
        'goods_server_path': adminer_website.goods_server_path,
        }

    return HttpResponse(json.dumps(conf))
Пример #2
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)
Пример #3
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)
Пример #4
0
def new_all_designer(request):
    designers_getter = DesignersGetter()
    designer_list = designers_getter.get_all_designers()

    conf = {
            'all_designer':
            designer_list
            }
    return render(request, website.all_designer, conf)
Пример #5
0
def get_chatView(request):
    user = request.user
    if user.is_authenticated():
        try:
            designer_getter = DesignersGetter()
            friends = designer_getter.get_all_designers()
        except Exception, e:
            print(e)
            raise e
Пример #6
0
def mytest_all_designer(request):
    designers_getter = DesignersGetter()
    designer_list = designers_getter.get_all_designers()
    customer = get_customer(request)

    #import pdb; pdb.set_trace()
    conf = {
                'length':len(designer_list),
                'all_designer':designer_list,
                'goods_server_path': adminer_website.goods_server_path,
		'customer': customer,
            }

    return render(request, website.mytest_all_designer, conf)
Пример #7
0
def sort_of_property(request):
    designers_getter = DesignersGetter()
    designer_list = designers_getter.get_all_designers()
    list_len = len(designer_list)
    new_list = []
    flag = []
    for i in range(list_len + 10):
        flag.append(0)
    for designer in designer_list:
        id = random.randint(0, list_len - 1)
        while flag[id] == 1:
            id = random.randint(0, list_len - 1)
        flag[id] = 1
        new_list.append(designer_list[id])
    designers_sort_dict = get_sort_list(new_list)
    return HttpResponse(json.dumps(designers_sort_dict))
Пример #8
0
def get_chatView(request):
    user = request.user
    designer_getter = DesignersGetter()
    friends = designer_getter.get_all_designers()

    user_ip = get_client_ip(request)
    chat_time = datetime.now()
    nickname_in_ip = user_ip.replace('.','')

    unique_user_name = user_ip + str(chat_time)
    unique_user_name = unique_user_name.replace(' ','')
    #pdb.set_trace()

    if user.username:
        nick_name = Customer.objects.get(user_id=user.id).nickname
        user_name = user.username
        return render(request, website.chat_to_designer, {'friends': friends, 'user_name': user_name, 'nick_name':nick_name })
    else:
        return render(request, website.chat_to_designer, {'friends': friends, 'user_name': unique_user_name, 'nick_name': "user"+nickname_in_ip})