Esempio n. 1
0
def allItems(request, page):
	itemCount = Item.objects.raw('select id, count(*) count from Item')[0].count

	#pageが数字なら
	try:
		page = int(request.GET['page'])
		page = pager.pagerInt(page, itemCount)['page']
		start_id = pager.pagerInt(page, itemCount)['start_id']
		prevNext = pager.pagerInt(page, itemCount)['prevNext']
		
	#pageが数字じゃなかったら			
	except:
		page = pager.pagerNotInt()['page']
		start_id = pager.pagerNotInt()['start_id']
		prevNext = pager.pagerNotInt()['prevNext']

	itemList = Item.objects.raw('select id, itemName, itemPrice, mediumImageUrls from Item ORDER BY itemPrice DESC limit %s, 30;' % start_id)

	c = Context({'typicalCategories':typicalCategories, 'searchForm':searchForm, 'itemList':itemList, 'itemCount':itemCount/30 + 1, 'prevNext':prevNext, 'page': page,})

	if parse(request.META['HTTP_USER_AGENT']).is_mobile:
		t = loader.get_template('rakuten/spAllItem.html')
	else:
		t = loader.get_template('rakuten/allItem.html')

	return HttpResponse(t.render(c))
Esempio n. 2
0
def index(request, page):

	#ページネーション作成
	#itemをcount
	itemCount = Item.objects.raw('select id, count(*) count from Item where genreId in (510914, 294456, 101480,204122,506438,511121,101483,563353,200164,511068,204030,101467,511073,511018,563381,204064,506475,510927,204049,563350,204078,204262,204119,204088,204260,563379,511191,302804,563490,563378,101479,204081,204055,563455,563355,200045,563477,563373,204069,204084,101469,553329,204072,511248,204279,511026,563377,101484,511009,563349,101478,511046,204283,302801,510930,563380,563451,563364,563481,204263,200044,507977,204120,101476,553328,506498,506443,204130,204091,200048,510943,563406,201318,563461,204027,204086,204068,511199,204121,563359,101481,302800,510923,563463,506439,204071,204034,510973,563452,563387,204060,204061,563391,511182,511025,204080,563358,563474,563402,511155,511013,563356,563469,511072,563457,563352,204085,563489,563454,511048,200041,563375,204118,204275,204089,563398,563362,510993,510947,204039,563460,204036,511156,563482,563401,511111,511091,204048,563371,511134,510989,553310,510974,563465,511104,511187,200040,563464,101477,563486,101472,506454,204135,204092,204259,511069,204131,506497,510985,563483,563383,563466,510939,563470,204037,510938,200049,563453,563476,563366,511001,204065,302803,204265,506484,511021,204052,563456,204271,511178,563475,204083,563405,511129,204042,511057,563478,511249,302802,204063,204075,511194,563473,510922,563365,563497,553315,511163,511198,204051,511122,563479,511125,511160,563462,563459,511171,511110,511060,553314,511190,510931,511168,563392,204074,563496,563390,511099,510977,204266,506449,511130,510935,204126,511183,511233,563360,511076,563363,563393,511002,563385,563399,510997,506468,101468,511092,204123,511222,511221,506494,563374,511038,511042,563351,204127,510994,563416,563492,563491,563415,563369,510981,511037,101473,302807,511041,510986,506495,563493,204046,510982,510978,511022,511077,511264,204133,204066,563495,563376,511195,563446,506453,511126,511214,511283,511164,511159,511179,563494,511049,563458,511252,511237,511279,511151,506444,563370,511238,563386,302806,511053,511251,204134,506458,302805,511271,511089,506485,511066,510942,511229,511065,511005,506459,563372,511276,563357,506480,563346,511218,511100,511140,563485,510946,553319,563421,563480,510971,511056,204128,511275,511288,553299,563472,563394,204136,511259,510926,553309,563354,563467,563445,511209,511210,506469,511230,563468,511203,204077,506489,506479,511010,511267,511272,511136,511061,511284,511170,510918,511225,553321,563471,510934,511268,553320,204132,511186,511119,563345,563361);')[0].count

	#pageが数字なら
	try:
		page = int(request.GET['page'])
		page = pager.pagerInt(page, itemCount)['page']
		start_id = pager.pagerInt(page, itemCount)['start_id']
		prevNext = pager.pagerInt(page, itemCount)['prevNext']
		
	#pageが数字じゃなかったら			
	except:
		page = pager.pagerNotInt()['page']
		start_id = pager.pagerNotInt()['start_id']
		prevNext = pager.pagerNotInt()['prevNext']

	itemList = Item.objects.raw('select id, itemName, itemPrice, mediumImageUrls from Item where genreId in (510914, 294456, 101480,204122,506438,511121,101483,563353,200164,511068,204030,101467,511073,511018,563381,204064,506475,510927,204049,563350,204078,204262,204119,204088,204260,563379,511191,302804,563490,563378,101479,204081,204055,563455,563355,200045,563477,563373,204069,204084,101469,553329,204072,511248,204279,511026,563377,101484,511009,563349,101478,511046,204283,302801,510930,563380,563451,563364,563481,204263,200044,507977,204120,101476,553328,506498,506443,204130,204091,200048,510943,563406,201318,563461,204027,204086,204068,511199,204121,563359,101481,302800,510923,563463,506439,204071,204034,510973,563452,563387,204060,204061,563391,511182,511025,204080,563358,563474,563402,511155,511013,563356,563469,511072,563457,563352,204085,563489,563454,511048,200041,563375,204118,204275,204089,563398,563362,510993,510947,204039,563460,204036,511156,563482,563401,511111,511091,204048,563371,511134,510989,553310,510974,563465,511104,511187,200040,563464,101477,563486,101472,506454,204135,204092,204259,511069,204131,506497,510985,563483,563383,563466,510939,563470,204037,510938,200049,563453,563476,563366,511001,204065,302803,204265,506484,511021,204052,563456,204271,511178,563475,204083,563405,511129,204042,511057,563478,511249,302802,204063,204075,511194,563473,510922,563365,563497,553315,511163,511198,204051,511122,563479,511125,511160,563462,563459,511171,511110,511060,553314,511190,510931,511168,563392,204074,563496,563390,511099,510977,204266,506449,511130,510935,204126,511183,511233,563360,511076,563363,563393,511002,563385,563399,510997,506468,101468,511092,204123,511222,511221,506494,563374,511038,511042,563351,204127,510994,563416,563492,563491,563415,563369,510981,511037,101473,302807,511041,510986,506495,563493,204046,510982,510978,511022,511077,511264,204133,204066,563495,563376,511195,563446,506453,511126,511214,511283,511164,511159,511179,563494,511049,563458,511252,511237,511279,511151,506444,563370,511238,563386,302806,511053,511251,204134,506458,302805,511271,511089,506485,511066,510942,511229,511065,511005,506459,563372,511276,563357,506480,563346,511218,511100,511140,563485,510946,553319,563421,563480,510971,511056,204128,511275,511288,553299,563472,563394,204136,511259,510926,553309,563354,563467,563445,511209,511210,506469,511230,563468,511203,204077,506489,506479,511010,511267,511272,511136,511061,511284,511170,510918,511225,553321,563471,510934,511268,553320,204132,511186,511119,563345,563361) ORDER BY itemPrice DESC limit %s, 30;' % start_id)

	c = Context({'typicalCategories':typicalCategories, 'searchForm':searchForm, 'itemList':itemList, 'itemCount':itemCount/30 + 1, 'prevNext':prevNext, 'page': page,})

	if parse(request.META['HTTP_USER_AGENT']).is_mobile:
		t = loader.get_template('rakuten/spIndex.html')
	else:
		t = loader.get_template('rakuten/index.html')

	return HttpResponse(t.render(c))
Esempio n. 3
0
def search(request):
	query = request.GET['query']

	#ページネーション作成
	#itemをcount
	sql = 'select id, count(*) count from Item where itemName like "%%{}%%"'.format(query.encode('utf-8'))
	itemCount = Item.objects.raw(sql)[0].count

	#pageが数字なら
	try:
		page = int(request.GET['page'])
		page = pager.pagerInt(page, itemCount)['page']
		start_id = pager.pagerInt(page, itemCount)['start_id']
		prevNext = pager.pagerInt(page, itemCount)['prevNext']
		
	#pageが数字じゃなかったら			
	except:
		page = pager.pagerNotInt()['page']
		start_id = pager.pagerNotInt()['start_id']
		prevNext = pager.pagerNotInt()['prevNext']

	sql = 'select id, itemName, mediumImageUrls, itemPrice from Item where itemName like "%%{}%%"'.format(query.encode('utf-8'))
	searchedItems = Item.objects.raw(sql + ' limit %s, 30;' % start_id)

	if parse(request.META['HTTP_USER_AGENT']).is_mobile:
		t = loader.get_template('rakuten/spSearch.html')
	else:
		t = loader.get_template('rakuten/search.html')

	c = Context({'typicalCategories':typicalCategories, 'query':query, 'searchedItems':searchedItems, 'searchForm':searchForm, 'itemCount':itemCount/30 + 1, 'page':page, 'start_id':start_id, 'prevNext':prevNext, })
	return HttpResponse(t.render(c))
Esempio n. 4
0
def category(request, category_id, page):

	# 現在の階層を確認
	nowCategory = Rakutencategory.objects.raw('select * from RakutenCategory where Category_id = %s' % category_id)

	# パンくず作成
	now_lft = createBreadCrumb.makeBreadCrumb(nowCategory)['now_lft']
	now_rgt = createBreadCrumb.makeBreadCrumb(nowCategory)['now_rgt']
	now_diff_lr = createBreadCrumb.makeBreadCrumb(nowCategory)['now_diff_lr']
	breadCrumb = createBreadCrumb.makeBreadCrumb(nowCategory)['breadCrumb']
	bottomCategories = createBreadCrumb.makeBreadCrumb(nowCategory)['bottomCategories']

	#itemをcount
	itemCount = Item.objects.raw('select i.id, count(*) count from Item i inner join RakutenCategory r on i.genreId = r.Category_id where lft >= %s and rgt<= %s;', (now_lft, now_rgt))[0].count

	#ページネーション作成
	#pageが数字なら
	try:
		page = int(request.GET['page'])
		page = pager.pagerInt(page, itemCount)['page']
		start_id = pager.pagerInt(page, itemCount)['start_id']
		prevNext = pager.pagerInt(page, itemCount)['prevNext']
		
	#pageが数字じゃなかったら			
	except:
		page = pager.pagerNotInt()['page']
		start_id = pager.pagerNotInt()['start_id']
		prevNext = pager.pagerNotInt()['prevNext']

	categoryItemList = Item.objects.raw('select i.id, i.itemName, i.mediumImageUrls, i.itemPrice from Item i inner join RakutenCategory r on i.genreId = r.Category_id where lft >= %s and rgt <= %s limit %s, 30;', (now_lft, now_rgt, start_id))

	if parse(request.META['HTTP_USER_AGENT']).is_mobile:
		t = loader.get_template('rakuten/spCategory.html')
	else:
		t = loader.get_template('rakuten/category.html')

	c = Context({'typicalCategories':typicalCategories, 'nowCategory':nowCategory, 'category_id':category_id, 'bottomCategories':bottomCategories, 'now_diff_lr':now_diff_lr, 'breadCrumb':breadCrumb, 'searchForm':searchForm, 'prevNext':prevNext, 'categoryItemList':categoryItemList, 'itemCount':itemCount/30 + 1, 'page':page, 'start_id':start_id, } )
	return HttpResponse(t.render(c))