def get(request): """ 响应GET """ id = request.GET['id'] is_pc = request.GET.get('isPC', None) expend = 0 auth_appid_info = None share_page_desc = '' thumbnails_url = '/static_v2/img/thumbnails_lottery.png' cache_key = 'apps_egg_%s_html' % id record = None member = request.member if 'new_app:' in id: project_id = id activity_status = u"未开始" else: if not is_pc: #从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: print 'redis---return' return HttpResponse(cache_data) try: record = app_models.Egg.objects.get(id=id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('egg/templates/webapp/m_egg.html', c) expend = record.expend share_page_desc = record.name activity_status, record = update_egg_status(record) project_id = 'new_app:egg:%s' % record.related_page_id request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'expend_integral': expend, 'record_id': id, 'activity_status': activity_status, 'page_title': record.name if record else u'砸金蛋', 'page_html_content': html, 'app_name': "egg", 'resource': "egg", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': True if is_pc else False, 'auth_appid_info': auth_appid_info, 'share_page_desc': share_page_desc, 'share_img_url': thumbnails_url }) response = render_to_string('egg/templates/webapp/m_egg.html', c) if not is_pc: SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ record_id = request.GET['id'] code = request.GET.get('scan_code', '') name = request.GET.get('name', None) phone = request.GET.get('phone', None) is_user_input = request.GET.get('is_user_input', '0') auth_appid_info = None share_page_desc = '' thumbnails_url = '/static_v2/img/thumbnails_lottery.png' cache_key = 'apps_scanlottery_%s_html' % record_id record = None member = request.member is_pc = False if member else True try: record = app_models.Scanlottery.objects.get(id=record_id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'scanlottery/templates/webapp/m_scanlottery.html', c) share_page_desc = record.name activity_status, record = update_scanlottery_status(record) project_id = 'new_app:scanlottery:%s' % record.related_page_id request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'record_id': record_id, 'activity_status': activity_status, 'page_title': record.name if record else u'扫码抽奖', 'page_html_content': html, 'app_name': "scanlottery", 'resource': "scanlottery", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': is_pc, 'auth_appid_info': auth_appid_info, 'share_page_desc': share_page_desc, 'share_img_url': thumbnails_url, 'code': code, 'name': name, 'phone': phone, 'is_hide_weixin_option_menu': True, 'isUserInput': is_user_input }) response = render_to_string( 'scanlottery/templates/webapp/m_scanlottery.html', c) return HttpResponse(response)
def get(request): """ 响应GET """ if 'id' in request.GET: id = request.GET['id'] participance_data_count = 0 if 'new_app:' in id: project_id = id activity_status = u"未开启" else: #termite类型数据 record = app_models.feedback.objects.get(id=id) activity_status = record.status_text now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:feedback:%s' % record.related_page_id if request.member: participance_data_count = app_models.feedbackParticipance.objects(belong_to=id, member_id=request.member.id).count() if participance_data_count == 0 and request.webapp_user: participance_data_count = app_models.feedbackParticipance.objects(belong_to=id, webapp_user_id=request.webapp_user.id).count() request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext(request, { 'record_id': id, 'activity_status': activity_status, 'is_already_participanted': (participance_data_count > 0), 'page_title': '用户调研', 'page_html_content': html, 'app_name': "feedback", 'resource': "feedback", 'hide_non_member_cover': True #非会员也可使用该页面 }) return render_to_response('workbench/wepage_webapp_page.html', c) else: record = None c = RequestContext(request, { 'record': record, 'app_name': "feedback", 'resource': "feedback" }); return render_to_response('feedback/templates/webapp/m_feedback.html', c)
def get(request): """ 渲染评价页面 """ param = request.GET owner_id = param.get('woid', request.webapp_owner_id) template_type = 'ordinary' records = app_models.EvaluateTemplateSetting.objects( owner_id=int(owner_id)) if records.count() > 0 and 'ordinary' != records.first().template_type: project_id = 'new_app:evaluate:%s' % records.first( ).related_page_id request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) template_type = 'custom' else: #读取组件页面 component_file = open( os.path.join(settings.PROJECT_HOME, '..', 'termite', 'static', 'termite_js', 'app', 'component', 'appkit', 'evaluatedescription', 'evaluatedescription.html'), 'r') html = component_file.read() html = html[html.index('<!--R-->') + 8:html.rindex('<!--R-->')] component_file.close() c = RequestContext( request, { 'page_title': "商品评价", 'page_html_content': html, 'app_name': "evaluate", 'resource': "m_evaluate", 'is_hide_weixin_option_menu': True, 'template_type': template_type, 'order_has_product_id': param.get('order_has_product_id', '1'), 'order_id': param.get('order_id', '1'), 'product_id': param.get('product_id', '1'), 'product_model_name': param.get('product_model_name', 'test'), 'isPC': False if request.member else True }) return render_to_response('evaluate/templates/webapp/m_evaluate.html', c)
def get(request): project_id = request.GET['project_id'] html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'page_html_content': html, 'project_id': project_id, 'app_name': request.GET.get('app_name', '') }) return render_to_response('termite2/wepage_design_page.html', c) # @login_required # def api_post(request): # response = pagecreater.create_page(request) # return response
def get(request): """ 响应GET """ if 'id' in request.GET: id = request.GET['id'] ###############重构之后,访问老数据,直接重定向到重构调研########## try: related_page_id = app_models.survey.objects.get( id=id).related_page_id m_marketapp_url = 'http://{}/m/apps/survey/m_survey/?woid={}&page_id={}'.format( settings.MARKET_MOBILE_DOMAIN, request.webapp_owner_id, related_page_id) return HttpResponseRedirect(m_marketapp_url) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('workbench/wepage_webapp_page.html', c) ############################################################### isPC = request.GET.get('isPC', 0) isMember = False qrcode_url = None permission = '' share_page_desc = '' thumbnails_url = '/static_v2/img/thumbnails_survey.png' if not isPC: isMember = request.member and request.member.is_subscribed if not isMember: if hasattr(request, "webapp_owner_info" ) and request.webapp_owner_info and hasattr( request.webapp_owner_info, "qrcode_img"): qrcode_url = request.webapp_owner_info.qrcode_img else: qrcode_url = get_mp_qrcode_img(request.webapp_owner_id) participance_data_count = 0 if 'new_app:' in id: project_id = id activity_status = u"未开始" else: #termite类型数据 try: record = app_models.survey.objects.get(id=id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'workbench/wepage_webapp_page.html', c) activity_status = record.status_text share_page_desc = record.name now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if record.status <= 1: if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:survey:%s' % record.related_page_id if request.member: participance_data_count = app_models.surveyParticipance.objects( belong_to=id, member_id=request.member.id).count() pagestore = pagestore_manager.get_pagestore('mongo') page = pagestore.get_page(record.related_page_id, 1) permission = page['component']['components'][0]['model'][ 'permission'] is_already_participanted = (participance_data_count > 0) if is_already_participanted: try: survey_detail, result_list = Msurvey.get_result(request) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'survey/templates/webapp/result_survey.html', c) c = RequestContext( request, { 'survey_detail': survey_detail, 'record_id': id, 'page_title': '用户调研', 'app_name': "survey", 'resource': "survey", 'q_survey': result_list, 'hide_non_member_cover': True, #非会员也可使用该页面 'isMember': isMember, 'qrcode_url': qrcode_url }) return render_to_response( 'survey/templates/webapp/result_survey.html', c) else: request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'record_id': id, 'activity_status': activity_status, 'is_already_participanted': (participance_data_count > 0), 'page_title': '用户调研', 'page_html_content': html, 'app_name': "survey", 'resource': "survey", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': False if request.member else True, 'isMember': isMember, 'qrcode_url': qrcode_url, 'permission': permission, 'share_page_desc': share_page_desc, 'share_img_url': thumbnails_url }) return render_to_response('workbench/wepage_webapp_page.html', c) else: record = None c = RequestContext(request, {'record': record}) return render_to_response('survey/templates/webapp/m_survey.html', c)
def get(request): """ 响应GET """ record_id = request.GET.get('id', 'id') fid = request.GET.get('fid', None) ###############重构之后,访问老数据,直接重定向到重构微助力########## try: related_page_id = app_models.PowerMe.objects.get( id=record_id).related_page_id m_marketapp_url = 'http://{}/m/apps/powerme/m_powerme/?woid={}&page_id={}&id={}'.format( settings.MARKET_MOBILE_DOMAIN, request.webapp_owner_id, related_page_id, record_id) if fid: m_marketapp_url += '&fid={}'.format(fid) return HttpResponseRedirect(m_marketapp_url) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('workbench/wepage_webapp_page.html', c) ############################################################### mpUserPreviewName = '' activity_status = u"未开始" member = request.member fid = 0 user_id = request.webapp_owner_info.user_profile.user_id username = User.objects.get(id=user_id).username if 'new_app:' in record_id: project_id = record_id record_id = 0 record = None elif member: member_id = member.id fid = request.GET.get('fid', None) if not fid: new_url = url_helper.add_query_part_to_request_url( request.get_full_path(), 'fid', member_id) response = HttpResponseRedirect(new_url) response.set_cookie('fid', member_id, max_age=60 * 60 * 24 * 365) return response cache_key = 'apps_powerme_%s_html' % record_id # 从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: print 'redis---return' return HttpResponse(cache_data) record = app_models.PowerMe.objects(id=record_id) if record.count() > 0: record = record.first() # 获取公众号昵称 mpUserPreviewName = request.webapp_owner_info.auth_appid_info.nick_name # 获取活动状态 activity_status = record.status_text now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:powerme:%s' % record.related_page_id # 检查所有当前参与用户是否取消关注,清空其助力值同时设置为未参与 # clear_non_member_power_info(record_id) else: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'powerme/templates/webapp/m_powerme.html', c) else: record = app_models.PowerMe.objects(id=record_id) if record.count() > 0: record = record.first() # 获取活动状态 activity_status = record.status_text now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:powerme:%s' % record.related_page_id else: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'powerme/templates/webapp/m_powerme.html', c) request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) params_qrcode_url = False params_qrcode_name = False try: params_qrcode_url = record.qrcode['ticket'] params_qrcode_name = record.qrcode['name'] except: pass c = RequestContext( request, { 'record_id': record_id, 'activity_status': activity_status, 'page_title': record.name if record else u"微助力", 'page_html_content': html, 'app_name': "powerme", 'resource': "powerme", 'hide_non_member_cover': True, # 非会员也可使用该页面 'isPC': False if request.member else True, 'share_page_title': mpUserPreviewName, 'share_img_url': record.material_image if record else '', 'share_page_desc': record.name if record else u"微助力", 'params_qrcode_url': params_qrcode_url, 'params_qrcode_name': params_qrcode_name, 'reply_content': record.reply_content if record else '', 'mpUserPreviewName': mpUserPreviewName, 'share_to_timeline_use_desc': True, # 分享到朋友圈的时候信息变成分享给朋友的描述 'username': username }) response = render_to_string('powerme/templates/webapp/m_powerme.html', c) if request.member: SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ try: if 'id' in request.GET: id = request.GET['id'] ###############重构之后,访问老数据,直接重定向到重构活动报名########## try: related_page_id = app_models.event.objects.get( id=id).related_page_id m_marketapp_url = 'http://{}/m/apps/event/m_event/?woid={}&page_id={}'.format( settings.MARKET_MOBILE_DOMAIN, request.webapp_owner_id, related_page_id) return HttpResponseRedirect(m_marketapp_url) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'workbench/wepage_webapp_page.html', c) ############################################################### isPC = request.GET.get('isPC', 0) participance_data_count = 0 isMember = False auth_appid_info = None permission = '' share_page_desc = '' description2 = '' description_is_empty = False thumbnails_url = '/static_v2/img/thumbnails_event.png' if not isPC: isMember = request.member and request.member.is_subscribed # if not isMember: # from weixin.user.util import get_component_info_from # component_info = get_component_info_from(request) # auth_appid = weixin_models.ComponentAuthedAppid.objects.filter(component_info=component_info, user_id=request.GET['webapp_owner_id'])[0] # auth_appid_info = weixin_models.ComponentAuthedAppidInfo.objects.filter(auth_appid=auth_appid)[0] if 'new_app:' in id: project_id = id activity_status = u"未开始" else: #termite类型数据 try: record = app_models.event.objects.get(id=id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'workbench/wepage_webapp_page.html', c) activity_status = record.status_text share_page_desc = record.name now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime( '%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') data_status = record.status if data_status <= 1: if data_start_time <= now_time and now_time < data_end_time: record.update( set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:event:%s' % record.related_page_id if request.member: participance_data_count = app_models.eventParticipance.objects( belong_to=id, member_id=request.member.id).count() pagestore = pagestore_manager.get_pagestore('mongo') page = pagestore.get_page(record.related_page_id, 1) permission = page['component']['components'][0]['model'][ 'permission'] description2 = page['component']['components'][1][ 'model'].get('description2', '') description_is_empty = False if description2 else True is_already_participanted = (participance_data_count > 0) if is_already_participanted: try: event_detail, activity_status = get_result( id, request.member.id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'event/templates/webapp/is_already_participanted.html', c) c = RequestContext( request, { 'event_detail': event_detail, 'record_id': id, 'activity_status': activity_status, 'page_title': '活动报名', 'app_name': "event", 'resource': "event", 'description2': description2, 'hide_non_member_cover': True #非会员也可使用该页面 }) return render_to_response( 'event/templates/webapp/is_already_participanted.html', c) else: request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'record_id': id, 'activity_status': activity_status, 'is_already_participanted': (participance_data_count > 0), 'page_title': '活动报名', 'page_html_content': html, 'app_name': "event", 'resource': "event", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': False if request.member else True, 'isMember': isMember, 'auth_appid_info': auth_appid_info, 'permission': permission, 'share_page_desc': share_page_desc, 'share_img_url': thumbnails_url, 'description_is_empty': description_is_empty }) return render_to_response( 'workbench/wepage_webapp_page.html', c) else: record = None c = RequestContext(request, {'record': record}) return render_to_response( 'event/templates/webapp/m_event.html', c) except: pass
def get(request): """ 响应GET """ record_id = request.GET.get('id','id') mpUserPreviewName = '' mpUserHeadImg = '' activity_status = u"未开始" member = request.member fid = 0 if 'new_app:' in record_id: project_id = record_id record_id = 0 record = None elif member: member_id = member.id fid = request.GET.get('fid', None) if not fid: new_url = url_helper.add_query_part_to_request_url(request.get_full_path(), 'fid', member_id) response = HttpResponseRedirect(new_url) response.set_cookie('fid', member_id, max_age=60*60*24*365) return response cache_key = 'apps_red_packet_%s_html' % record_id # 从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: print 'redis---return' return HttpResponse(cache_data) record = app_models.RedPacket.objects(id=record_id) if record.count() > 0: record = record.first() #获取公众号昵称 mpUserPreviewName = request.webapp_owner_info.auth_appid_info.nick_name #获取公众号头像 mpUserHeadImg = request.webapp_owner_info.auth_appid_info.head_img #获取活动状态 activity_status = record.status_text now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:red_packet:%s' % record.related_page_id else: c = RequestContext(request, { 'is_deleted_data': True }) return render_to_response('red_packet/templates/webapp/m_red_packet.html', c) else: record = app_models.RedPacket.objects(id=record_id) if record.count() >0: record = record.first() #获取活动状态 activity_status = record.status_text now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:red_packet:%s' % record.related_page_id else: c = RequestContext(request, { 'is_deleted_data': True }) return render_to_response('red_packet/templates/webapp/m_red_packet.html', c) request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) params_qrcode_url = False params_qrcode_name = False try: params_qrcode_url = record.qrcode['ticket'] params_qrcode_name = record.qrcode['name'] except: pass c = RequestContext(request, { 'record_id': record_id, 'activity_status': activity_status, 'page_title': record.name if record else u"返利活动", 'page_html_content': html, 'app_name': "red_packet", 'resource': "red_packet", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': False if request.member else True, 'share_page_title': mpUserPreviewName, 'share_img_url': record.material_image if record else '', 'share_page_desc': record.name if record else u"返利活动", 'params_qrcode_url': params_qrcode_url, 'params_qrcode_name': params_qrcode_name, 'reply_content': record.reply_content if record else '', 'mpUserPreviewName': mpUserPreviewName, 'mpUserHeadImg': mpUserHeadImg, 'share_to_timeline_use_desc': True #分享到朋友圈的时候信息变成分享给朋友的描述 }) response = render_to_string('red_packet/templates/webapp/m_red_packet.html', c) if request.member: SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ if 'id' in request.GET: id = request.GET['id'] isPC = request.GET.get('isPC', 0) isMember = False qrcode_url = None permission = '' share_page_desc = '' thumbnails_url = '/static_v2/img/thumbnails_survey.png' product_id2product_name = [] if not isPC: isMember = request.member and request.member.is_subscribed if not isMember: if hasattr(request, "webapp_owner_info" ) and request.webapp_owner_info and hasattr( request.webapp_owner_info, "qrcode_img"): qrcode_url = request.webapp_owner_info.qrcode_img else: qrcode_url = get_mp_qrcode_img(request.webapp_owner_id) participance_data_count = 0 if 'new_app:' in id: project_id = id activity_status = u"未开始" else: #termite类型数据 try: record = app_models.exsurvey.objects.get(id=id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'workbench/wepage_webapp_page.html', c) activity_status = record.status_text share_page_desc = record.name now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if record.status <= 1: if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' project_id = 'new_app:exsurvey:%s' % record.related_page_id # if request.member: # participance_data_count = app_models.exsurveyParticipance.objects(belong_to=id, member_id=request.member.id).count() # # pagestore = pagestore_manager.get_pagestore('mongo') # page = pagestore.get_page(record.related_page_id, 1) # permission = page['component']['components'][0]['model']['permission'] # is_already_participanted = (participance_data_count > 0) # if is_already_participanted: # member_id = request.member.id # try: # exsurvey_detail,result_list = get_result(id,member_id) # except: # c = RequestContext(request,{ # 'is_deleted_data': True # }) # return render_to_response('exsurvey/templates/webapp/result_exsurvey.html', c) # c = RequestContext(request, { # 'exsurvey_detail': exsurvey_detail, # 'record_id': id, # 'page_title': '用户调研', # 'app_name': "exsurvey", # 'resource': "exsurvey", # 'q_survey': result_list, # 'hide_non_member_cover': True, #非会员也可使用该页面 # 'isMember': isMember, # 'qrcode_url': qrcode_url # }) # return render_to_response('exsurvey/templates/webapp/result_exsurvey.html', c) # else: pagestore = pagestore_manager.get_pagestore('mongo') page = pagestore.get_page(record.related_page_id, 1) permission = page['component']['components'][0]['model'][ 'permission'] participance_datas = None member_id = 0 orderhasproduct_ids = [] webapp_owner_id = 0 if not isPC: webapp_owner_id = request.GET['webapp_owner_id'] if request.member: member_id = request.member.id participance_datas = app_models.exsurveyParticipance.objects( member_id=request.member.id) if participance_datas: for p in participance_datas: termite_data = p.termite_data for title, value in termite_data.items(): if value['type'] == 'appkit.dropdownbox' and value[ 'value']: orderhasproduct_ids.append( value['value']['orderhasproduct_id']) webappusers = WebAppUser.objects.filter(member_id=member_id) webapp_user_ids = [wau.id for wau in webappusers] #获取上2个月的时间 cur_time = date.today() cur_year = cur_time.year cur_month = cur_time.month cur_month_days = calendar.monthrange(cur_year, cur_month)[1] last_month_time = cur_time - timedelta(days=cur_month_days) last_month_year = last_month_time.year last_month_month = last_month_time.month last_month_days = calendar.monthrange(last_month_year, last_month_month)[1] last_last_month_time = last_month_time - timedelta( days=last_month_days) #两个月前的那天 start_date = last_last_month_time.strftime("%Y-%m-%d %H:%M:%S") #现在的时间 end_date = cur_time.strftime("%Y-%m-%d 23:59:59") #获取当前会员2个月内所下单已发货和已完成的id orders = Order.objects.filter( webapp_user_id__in=webapp_user_ids, origin_order_id__in=[0, -1], created_at__gte=start_date, created_at__lte=end_date, status__in=[ ORDER_STATUS_PAYED_SHIPED, ORDER_STATUS_SUCCESSED, ORDER_STATUS_PAYED_NOT_SHIP ]) webapp = WebApp.objects.filter(owner_id=webapp_owner_id) if webapp.count() > 0: orders.filter(webapp_id=webapp[0].appid) order_ids = [order.id for order in orders] #根据订单id获取商品id的dict product_id2product = { ohp.product_id: ohp for ohp in OrderHasProduct.objects.filter( order_id__in=order_ids).exclude( id__in=orderhasproduct_ids).order_by('-created_at') } #根据商品id获取到商品名称 for p in Product.objects.filter( id__in=product_id2product.keys()): product_id2product_name.append({ "orderhasproduct_id": product_id2product[p.id].id, "product_id": p.id, "order_id": product_id2product[p.id].order.order_id, "product_name": p.name, "product_supplier_id": p.supplier, "product_owner_id": p.owner_id }) product_id2product_name = sorted( product_id2product_name, key=lambda product: product['orderhasproduct_id']) request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'record_id': id, 'activity_status': activity_status, 'is_already_participanted': False, 'page_title': '用户反馈', 'page_html_content': html, 'app_name': "exsurvey", 'resource': "exsurvey", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': False if request.member else True, 'isMember': isMember, 'qrcode_url': qrcode_url, 'permission': permission, 'share_page_desc': share_page_desc, 'share_img_url': thumbnails_url, 'product_dict': json.dumps(product_id2product_name) }) return render_to_response( 'exsurvey/templates/webapp/m_exsurvey.html', c) else: record = None c = RequestContext(request, {'record': record}) return render_to_response( 'exsurvey/templates/webapp/m_survey.html', c)
def get(request): """ 响应GET """ id = request.GET['id'] code = request.GET.get('ex_code', None) # expend = 0 auth_appid_info = None share_page_desc = '' thumbnails_url = '/static_v2/img/thumbnails_lottery.png' cache_key = 'apps_exlottery_%s_html' % id record = None member = request.member is_pc = False if member else True # if not is_pc: # #从redis缓存获取静态页面 # cache_data = GET_CACHE(cache_key) # if cache_data: # print 'redis---return' # return HttpResponse(cache_data) try: record = app_models.Exlottery.objects.get(id=id) exlottery_bg_image = record.exlottery_bg_image except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'exlottery/templates/webapp/m_exlottery.html', c) # expend = record.expend share_page_desc = record.share_description activity_status, record = update_exlottery_status(record) project_id = 'new_app:exlottery:%s' % record.related_page_id request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { # 'expend_integral': expend, 'record_id': id, 'activity_status': activity_status, 'page_title': record.name if record else u'幸运码抽奖', 'page_html_content': html, 'app_name': "exlottery", 'resource': "exlottery", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': is_pc, 'auth_appid_info': auth_appid_info, 'share_page_desc': share_page_desc, 'share_img_url': exlottery_bg_image if exlottery_bg_image else thumbnails_url, 'code': code }) response = render_to_string( 'exlottery/templates/webapp/m_exlottery.html', c) # if not is_pc: # SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ p_id = request.GET.get('id', 'id') ###############重构之后,访问老数据,直接重定向到重构微助力########## try: m_marketapp_url = 'http://{}/m/apps/sign/m_sign/?webapp_owner_id={}'.format( settings.MARKET_MOBILE_DOMAIN, request.webapp_owner_id) return HttpResponseRedirect(m_marketapp_url) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('workbench/wepage_webapp_page.html', c) ############################################################### isPC = request.GET.get('isPC', 0) webapp_owner_id = request.GET.get('webapp_owner_id', None) prize_info = {} if 'new_app' in p_id: project_id = p_id activity_status = u"未开始" record_id = 0 sign_description = "" record = None else: if not webapp_owner_id: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('sign/templates/webapp/m_sign.html', c) cache_key = 'apps_sign_%s_html' % webapp_owner_id if not isPC: #从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: #存入全局变量 print 'redis---return' return HttpResponse(cache_data) record = app_models.Sign.objects(owner_id=webapp_owner_id) if record.count() > 0: record = record[0] prize_settings = record.prize_settings pagestore = pagestore_manager.get_pagestore('mongo') page = pagestore.get_page(record.related_page_id, 1) sign_description = page['component']['components'][0]['model'][ 'description'] activity_status = record.status_text project_id = 'new_app:sign:%s' % record.related_page_id record_id = record.id prize_rules = {} for name in sorted( map(lambda x: (int(x), x), prize_settings.keys())): setting = prize_settings[name[1]] name = name[0] if setting['integral']: p_integral = setting['integral'] else: p_integral = 0 if setting['coupon']['name']: p_coupon = setting['coupon']['name'] else: p_coupon = "" prize_rules[name] = { 'integral': p_integral, 'coupon': p_coupon } prize_info = {'prize_rules': prize_rules} else: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('sign/templates/webapp/m_sign.html', c) request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'record_id': record_id, 'activity_status': activity_status, 'page_title': u"签到", 'page_html_content': html, 'app_name': "sign", 'resource': "sign", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': False if not isPC else True, 'prize_info': json.dumps(prize_info), 'share_page_title': record.share['desc'] if record else '', 'share_img_url': record.share['img'] if record else '', 'share_page_desc': u"签到", 'sign_description': sign_description }) response = render_to_string('sign/templates/webapp/m_sign.html', c) if not isPC: SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ id = request.GET['id'] ###############重构之后,访问老数据,直接重定向到重构微信抽奖########## try: related_page_id = app_models.lottery.objects.get( id=id).related_page_id m_marketapp_url = 'http://{}/m/apps/lottery/m_lottery/?woid={}&page_id={}&id={}'.format( settings.MARKET_MOBILE_DOMAIN, request.webapp_owner_id, related_page_id, id) return HttpResponseRedirect(m_marketapp_url) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response('workbench/wepage_webapp_page.html', c) ############################################################### is_pc = request.GET.get('isPC', None) expend = 0 auth_appid_info = None share_page_desc = '' thumbnails_url = '/static_v2/img/thumbnails_lottery.png' cache_key = 'apps_lottery_%s_html' % id record = None member = request.member if 'new_app:' in id: project_id = id activity_status = u"未开始" else: if not is_pc: #从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: print 'redis---return' return HttpResponse(cache_data) try: record = app_models.lottery.objects.get(id=id) except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'lottery/templates/webapp/m_lottery.html', c) expend = record.expend share_page_desc = record.name activity_status, record = update_lottery_status(record) project_id = 'new_app:lottery:%s' % record.related_page_id request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'expend_integral': expend, 'record_id': id, 'activity_status': activity_status, 'page_title': record.name if record else u'微信抽奖', 'page_html_content': html, 'app_name': "lottery", 'resource': "lottery", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': True if is_pc else False, 'auth_appid_info': auth_appid_info, 'share_page_desc': share_page_desc, 'share_img_url': thumbnails_url }) response = render_to_string('lottery/templates/webapp/m_lottery.html', c) if not is_pc: SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ p_id = request.GET.get('id','id') isPC = request.GET.get('isPC',0) webapp_owner_id = request.GET.get('webapp_owner_id', None) prize_info = {} member_grade = u"" if 'new_app' in p_id: project_id = p_id activity_status = u"未开始" record_id = 0 exsign_description = "" record = None else: if not webapp_owner_id: c = RequestContext(request, { 'is_deleted_data': True }) return render_to_response('exsign/templates/webapp/m_exsign.html', c) cache_key = 'apps_exsign_%s_html' % webapp_owner_id if not isPC: #从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: #存入全局变量 print 'redis---return' return HttpResponse(cache_data) record = app_models.exSign.objects(owner_id=webapp_owner_id) if record.count() > 0: record = record[0] prize_settings = record.prize_settings pagestore = pagestore_manager.get_pagestore('mongo') page = pagestore.get_page(record.related_page_id, 1) exsign_description = page['component']['components'][0]['model']['description'] activity_status = record.status_text project_id = 'new_app:exsign:%s' % record.related_page_id record_id = record.id prize_rules = {} for name in sorted(map(lambda x: (int(x),x), prize_settings.keys())): setting = prize_settings[name[1]] name = name[0] if setting['integral']: p_integral = setting['integral'] else: p_integral = 0 p_coupon = [] if setting['coupon']: for coupon in setting['coupon']: if request.member.grade_id == int(coupon["grade_id"]): p_coupon.append({ "name": coupon['name'] }) elif int(coupon["grade_id"]) == 0: p_coupon.append({ "name": coupon['name'] }) prize_rules[name] = {'integral': p_integral, 'coupon': p_coupon} prize_info = { 'prize_rules': prize_rules } else: c = RequestContext(request, { 'is_deleted_data': True }) return render_to_response('exsign/templates/webapp/m_exsign.html', c) request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) if request.member and request.member.grade_id: grade_id = request.member.grade_id member_grade = MemberGrade.objects.get(id=grade_id).name c = RequestContext(request, { 'record_id': record_id, 'activity_status': activity_status, 'page_title': u"签到", 'page_html_content': html, 'app_name': "exsign", 'resource': "exsign", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': False if not isPC else True, 'prize_info': json.dumps(prize_info), 'share_page_title': record.share['desc'] if record else '', 'share_img_url': record.share['img'] if record else '', 'share_page_desc': u"签到", 'exsign_description': exsign_description, 'member_grade': member_grade }) response = render_to_string('exsign/templates/webapp/m_exsign.html', c) if not isPC: SET_CACHE(cache_key, response) return HttpResponse(response)
def get(request): """ 响应GET """ if 'id' in request.GET: {% if resource.enable_termite %} id = request.GET['id'] isPC = request.GET.get('isPC',0) participance_data_count = 0 isMember = False auth_appid_info = None if not isPC: isMember = request.member and request.member.is_subscribed __STRIPPER_TAG__ if 'new_app:' in id: project_id = id activity_status = u"未开启" else: #termite类型数据 try: record = app_models.{{resource.class_name}}.objects.get(id=id) except: c = RequestContext(request,{ 'is_deleted_data': True }) return render_to_response('workbench/wepage_webapp_page.html', c) activity_status = record.status_text __STRIPPER_TAG__ now_time = datetime.today().strftime('%Y-%m-%d %H:%M') data_start_time = record.start_time.strftime('%Y-%m-%d %H:%M') data_end_time = record.end_time.strftime('%Y-%m-%d %H:%M') if data_start_time <= now_time and now_time < data_end_time: record.update(set__status=app_models.STATUS_RUNNING) activity_status = u'进行中' elif now_time >= data_end_time: record.update(set__status=app_models.STATUS_STOPED) activity_status = u'已结束' __STRIPPER_TAG__ project_id = 'new_app:{{app_name}}:%s' % record.related_page_id __STRIPPER_TAG__ {% if resource.need_check_user_participant %} if request.member: participance_data_count = app_models.{{resource.class_name}}Participance.objects(belong_to=id, member_id=request.member.id).count() {% endif %} __STRIPPER_TAG__ request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) __STRIPPER_TAG__ c = RequestContext(request, { 'record_id': id, 'activity_status': activity_status, 'is_already_participanted': (participance_data_count > 0), 'page_title': "{{resource.display_name}}", 'page_html_content': html, 'app_name': "{{app_name}}", 'resource': "{{resource.lower_name}}", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': isPC, 'isMember': isMember, 'auth_appid_info': auth_appid_info }) __STRIPPER_TAG__ return render_to_response('workbench/wepage_webapp_page.html', c) {% else %}
def get(request): """ webapp页面(目前是首页) """ start_date = datetime.datetime.now() if 'model' in request.GET: return jqm_views.show_preview_page(request) project_id = request.REQUEST.get('project_id', 0) if project_id == 0: response = create_response(500) response.errMsg = u'没有project_id参数' return response.get_response() # 如果是空页面,跳转到404页面 if pagecreater.is_home_page(request): pass else: projects = webapp_models.Project.objects.filter(id=project_id) if projects.count() == 0: c = RequestContext( request, { # "is_deleted_data": True }) return render_to_response('mobile_error_info.html', c) # from account.views import show_error_page # return show_error_page(request) #获取project # project = None # #project_id = request.REQUEST.get('project_id') # is_app_project = False # app_name = '' # if project_id.startswith('new_app:'): # _, app_name, project_id = project_id.split(':') # is_app_project = True # else: # project_id = int(request.REQUEST.get('project_id', 0)) # if is_app_project: # project = webapp_models.Project() # project.id = project_id # project.type = 'appkit' # else: # if project_id != 0: # project = webapp_models.Project.objects.get(id=project_id) # else: # workspace = webapp_models.Workspace.objects.get(owner=request.webapp_owner_id, inner_name='home_page') # project = webapp_models.Project.objects.get(workspace_id=workspace.id, type='wepage', is_active=True) # project_id = project.id # project.app_name = '' # project.is_app_project = is_app_project # request.project = project html = pagecreater.create_page(request, return_html_snippet=True) #获取page title page_title = u'店铺首页' beg_tag = 'data-page-title="' end_tag = '"' beg = html.find(beg_tag) + len(beg_tag) if beg != -1: end = html.find(end_tag, beg) page_title = html[beg:end] # 获取页面描述 site_description = pagecreater.get_site_description(request) # 是否是首页 if pagecreater.is_home_page(request): # 首页 current_page_name = 'home' else: # 微页面 current_page_name = 'page' # 是否是预览状态 is_preview = True if request.GET.get('page_id', '') == 'preview' else False c = RequestContext( request, { 'page_title': page_title, 'page_html_content': html, 'share_page_desc': site_description, 'share_to_timeline_use_desc': True, #分享到朋友圈的时候信息变成分享给朋友的描述 'current_page_name': current_page_name, 'is_preview': is_preview, 'hide_non_member_cover': True, #非会员也可使用该页面 'H5_HOST': settings.H5_HOST }) ## start watchdog.info end_date = datetime.datetime.now() url = '{}{}'.format(request.get_host(), request.get_full_path()) timestamp = end_date - start_date message_info = { 'message_service': 'WEPAGE', 'message_type': 'render_to_response', 'url': url, 'timestamp': str(timestamp), 'user_id': request.user_profile.user_id } watchdog.info(message_info) ## end watchdog.info return render_to_response('workbench/wepage_webapp_page.html', c)
def get(request): """ 响应GET """ id = request.GET['id'] isPC = request.GET.get('isPC', 0) share_page_desc = "" auth_appid_info = None record = None recordName = "" mpUserPreviewName = None if not isPC: isMember = request.member and request.member.is_subscribed if 'new_app:' in id: project_id = id activity_status = u"未开启" else: cache_key = 'apps_shvote_%s_html' % request.GET['id'] #从redis缓存获取静态页面 cache_data = GET_CACHE(cache_key) if cache_data: print 'redis---return' return HttpResponse(cache_data) try: record = app_models.Shvote.objects.get(id=id) recordName = record.name #获取公众号昵称 mpUserPreviewName = request.webapp_owner_info.auth_appid_info.nick_name except: c = RequestContext(request, {'is_deleted_data': True}) return render_to_response( 'shvote/templates/webapp/m_shvote.html', c) activity_status, record = update_shvote_status(record) share_page_desc = record.name project_id = 'new_app:shvote:%s' % record.related_page_id request.GET._mutable = True request.GET.update({"project_id": project_id}) request.GET._mutable = False html = pagecreater.create_page(request, return_html_snippet=True) c = RequestContext( request, { 'record_id': id, 'activity_status': activity_status, 'page_title': u"投票活动", 'page_html_content': html, 'app_name': "shvote", 'resource': "shvote", 'hide_non_member_cover': True, #非会员也可使用该页面 'isPC': True if isPC else False, 'auth_appid_info': auth_appid_info, 'share_page_title': mpUserPreviewName if mpUserPreviewName else recordName, 'share_img_url': record.share_image if record else '', "share_page_desc": share_page_desc, "groups": record.groups if record else [], "advertisement": record.advertisement if record.advertisement != '' else None }) response = render_to_string('shvote/templates/webapp/m_shvote.html', c) if request.member: SET_CACHE(cache_key, response) return HttpResponse(response)