コード例 #1
0
ファイル: views.py プロジェクト: kewaimai/DiningHouse
def index(request):
    """
    首页
    :param request:
    :return:
    """
    context = meal_service.getCategoryAndList()
    return render(request, 'DiningServer/index.html', context)
コード例 #2
0
ファイル: views.py プロジェクト: kewaimai/DiningHouse
def indextest(request):
    """
    测试test
    :param request:
    :return:
    """
    context = meal_service.getCategoryAndList()
    print(context)
    return HttpResponse(str(context))
コード例 #3
0
ファイル: views.py プロジェクト: wangjc888/Xiangeqwd
def index(request):
	"""
	首页
	:param request:
	:return:
	"""

	user = getUserFromOpenid(request)
	if user:
		request.session['openid'] = user.openid
		openid = user.openid
		print('openid(from user) in index:',user.openid) 
	else:
		openid = request.session.get('openid',None)
		print('openid(from session) in index:',openid)    
	
	context = meal_service.getCategoryAndList(request)
	
	# 判断当前是否为营业时间
	now_time = datetime.datetime.now().strftime('%X') 
	print('now_time:',now_time)
	if 'house' in context:
		house_open_time = context['house']['open_time']
		house_close_time = context['house']['close_time']
		
		tpl_msg_data.welcom_data['keyword1']['value'] = '家家长沙米粉'+'('+context['house']['name']+')'

		if now_time < house_open_time.strftime('%X')  or now_time > house_close_time.strftime('%X') :
			return render_to_response('DiningServer/rest.html',{
															'open_time':house_open_time,
															'close_time':house_close_time})

	# touser = request.session['openid']
	# template_id = 'X-1HSV69BTa03E5gj-ySu7sao7_N9Cx9EuLIlZzIYDI'
	# url = ''
	# data = tpl_msg_data.welcom_data
	# weixin_service.sendTplMsg(request, touser, template_id, url, data)

	print('request method:', request.method)
	if 'house' in context:
		request.session['house_id'] = context['house']['house_id']
		print('house_id in session:',request.session['house_id'])
	
	return render(request, 'DiningServer/index.html', context)