def index(request): StatComm.count_page_traffic(request) isMble = dmb.process_request(request) context = {} #if not request.user.is_anonymous(): user = request.user next_url = request.GET.get('next') if next_url: return redirect(next_url) else: #get user list user_list = User.objects.filter().order_by('-date') day_word_list = Day_words.objects.filter().order_by('-id') if day_word_list: day_word = day_word_list[0] context = { 'user_list': user_list, 'content': day_word.content, 'creator': day_word.user.get_full_name() } else: context = {'user_list': user_list} blocks = Block.objects.all() context['blocks'] = blocks if isMble: return render(request, 'map2family/m_hostpage.html', context) else: return render(request, 'map2family/homepage.html', context)
def contact_us(request): StatComm.count_page_traffic(request) isMble = dmb.process_request(request) if isMble: return render(request, 'help/m_contact-us.html', {}) else: return render(request, 'help/m_contact-us.html', {})
def find_password(request): StatComm.count_page_traffic(request) isMble = dmb.process_request(request) content = {'page': 'find_password', 'page_title': '找回密码'} if isMble: return render(request, 'basedatas/m_user_register.html', content) else: return render(request, 'basedatas/user_register.html', content)
def demo(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) context = {} if isMobile: return render(request, 'pic/m_demo.html', context) else: return render(request, 'pic/m_demo.html', context)
def demo(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) context = {} if isMobile: return render(request, 'pic/m_demo.html', context ) else: return render(request, 'pic/m_demo.html', context )
def new_tofuture(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) context = {'page': 'new'} if is_Mobile: return render(request, 'tofuture/m_new.html', context) else: return render(request, 'tofuture/new.html', context)
def new_tofuture(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) context = {'page':'new'} if is_Mobile: return render(request, 'tofuture/m_new.html', context ) else: return render(request, 'tofuture/new.html', context )
def delete(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) context = {'page':'new'} if is_Mobile: return render(request, 'lastinfo/m_new.html', context ) else: return render(request, 'lastinfo/new.html', context )
def delete(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) context = {'page': 'new'} if is_Mobile: return render(request, 'lastinfo/m_new.html', context) else: return render(request, 'lastinfo/new.html', context)
def new_lastinfo(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(is_Mobile, request) context = {'page':'new'} if is_Mobile: return render(request, 'lastinfo/m_new.html', context ) else: return render(request, 'lastinfo/new.html', context )
def index_tofuture(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) tofuture_list = Tofuture.objects.all() context = {'tofuture_list':tofuture_list} return render(request, 'tofuture/index.html', context )
def index_tofuture(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) tofuture_list = Tofuture.objects.all() context = {'tofuture_list': tofuture_list} return render(request, 'tofuture/index.html', context)
def new_lastinfo(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(is_Mobile, request) context = {'page': 'new'} if is_Mobile: return render(request, 'lastinfo/m_new.html', context) else: return render(request, 'lastinfo/new.html', context)
def new_day_words(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(is_Mobile, request) if is_Mobile: return render(request, 'daywords/m_new.html', {}) else: return render(request, 'daywords/m_new.html', {})
def upload(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) context = {} if is_Mobile: return render(request, 'pic/m_upload.html', context) else: return render(request, 'pic/m_upload.html', context)
def upload(request): StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) context = {} if is_Mobile: return render(request, 'pic/m_upload.html', context ) else: return render(request, 'pic/m_upload.html', context )
def user_register(request): StatComm.count_page_traffic(request) dmb = DetectMobileBrowser() isMble = dmb.process_request(request) content = {'page': 'user_register', 'page_title': '注册为新会员'} print isMble if isMble: return render(request, 'basedatas/m_user_register.html', content) else: return render(request, 'basedatas/user_register.html', content)
def save_tofuture(request): StatComm.count_page_traffic(request) #save the changes for last info if request.user.is_anonymous(): return redirect(settings.APP_WEB_LOGIN_URL) result = {} if request.method == 'POST': if 'title' in request.POST and 'years' in request.POST and 'content' in request.POST: title = request.POST.get('title') years = request.POST.get('years') content = request.POST.get('content') page = request.POST.get('page') content = content.encode('utf8', 'ignore') title = title.encode('utf8', 'ignore') #save last mail instance if page == 'new': tofuture_instance = Tofuture.objects.create(title=title, years=years, mgs=content, user=request.user) tofuture_instance.save() else: id = request.POST.get('id') try: tofuture_instance = Tofuture.objects.get(id=id, user=request.user) tofuture_instance.title = title tofuture_instance.years = years tofuture_instance.mgs = content tofuture_instance.save() except Tofuture.DoesNotExist: result['status'] = 'ERROR' result['MSG'] = '要修改的记录不存在...' return HttpResponse(json.dumps(result), content_type='application/json') result['status'] = 'OK' result['id'] = tofuture_instance.id result['MSG'] = '已成功提交至服务器...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,就不告诉你...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,气死你...' return HttpResponse(json.dumps(result), content_type='application/json')
def index_lastinfo(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): lastinfo_list = '' else: lastinfo_list = LastInfo.objects.filter(user = request.user).order_by('-date') context = {'lastinfo_list':lastinfo_list} if isMobile: return render(request, 'lastinfo/m_index.html', context ) else: return render(request, 'lastinfo/index.html', context )
def new(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) context = { } isMobile = dmb.process_request(request) if isMobile: return render(request, 'heartbeat/m_new.html', context) else: return render(request, 'heartbeat/new.html', context)
def new(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) context = {} isMobile = dmb.process_request(request) if isMobile: return render(request, 'heartbeat/m_new.html', context) else: return render(request, 'heartbeat/new.html', context)
def detail_tofuture(request, tofuture_id ): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) try: tofuture_instance = get_object_or_404(Tofuture, id=tofuture_id, user=request.user) context = {'tofuture':tofuture_instance} return render(request, 'tofuture/detail.html', context ) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def index(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) #if request.user.is_anonymous(): # return comm.redirect_login_path(isMobile, request) #pic_list = Pic.objects.filter(user=request.user).order_by('-pk') #context = {'pic_list':pic_list} context = {} if isMobile: return render(request, 'pic/m_index.html', context) else: return render(request, 'pic/index.html', context)
def detail_lastinfo(request, id_lastinfo ): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) try: lastinfo_instance = get_object_or_404(LastInfo, id=id_lastinfo, user=request.user) context = {'lastinfo':lastinfo_instance} return render(request, 'lastinfo/detail.html', context ) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def index_lastinfo(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): lastinfo_list = '' else: lastinfo_list = LastInfo.objects.filter( user=request.user).order_by('-date') context = {'lastinfo_list': lastinfo_list} if isMobile: return render(request, 'lastinfo/m_index.html', context) else: return render(request, 'lastinfo/index.html', context)
def index(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) #if request.user.is_anonymous(): # return comm.redirect_login_path(isMobile, request) #pic_list = Pic.objects.filter(user=request.user).order_by('-pk') #context = {'pic_list':pic_list} context = {} if isMobile: return render(request, 'pic/m_index.html', context ) else: return render(request, 'pic/index.html', context )
def detail_tofuture(request, tofuture_id): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) try: tofuture_instance = get_object_or_404(Tofuture, id=tofuture_id, user=request.user) context = {'tofuture': tofuture_instance} return render(request, 'tofuture/detail.html', context) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def detail_lastinfo(request, id_lastinfo): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) try: lastinfo_instance = get_object_or_404(LastInfo, id=id_lastinfo, user=request.user) context = {'lastinfo': lastinfo_instance} return render(request, 'lastinfo/detail.html', context) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def index(request): isMobile = dmb.process_request(request) StatComm.count_page_traffic(request) if not request.user.is_anonymous(): heartbeat_list = HeartBeat.objects.filter(owner=request.user).order_by('-pk') else: heartbeat_list = '' context = {'heartbeat_list' : heartbeat_list} isMobile = dmb.process_request(request) if isMobile: return render(request, 'heartbeat/m_index.html', context) else: return render(request, 'heartbeat/index.html', context)
def save_tofuture(request): StatComm.count_page_traffic(request) #save the changes for last info if request.user.is_anonymous(): return redirect(settings.APP_WEB_LOGIN_URL) result = {} if request.method == 'POST': if 'title' in request.POST and 'years' in request.POST and 'content' in request.POST : title = request.POST.get('title') years = request.POST.get('years') content = request.POST.get('content') page = request.POST.get('page') content = content.encode('utf8','ignore') title = title.encode('utf8','ignore') #save last mail instance if page == 'new': tofuture_instance = Tofuture.objects.create(title=title, years=years, mgs=content, user= request.user) tofuture_instance.save() else: id = request.POST.get('id') try: tofuture_instance = Tofuture.objects.get(id = id, user = request.user) tofuture_instance.title = title tofuture_instance.years = years tofuture_instance.mgs = content tofuture_instance.save() except Tofuture.DoesNotExist: result['status'] = 'ERROR' result['MSG'] = '要修改的记录不存在...' return HttpResponse(json.dumps(result), content_type='application/json') result['status'] = 'OK' result['id'] = tofuture_instance.id result['MSG'] = '已成功提交至服务器...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,就不告诉你...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,气死你...' return HttpResponse(json.dumps(result), content_type='application/json')
def index(request): isMobile = dmb.process_request(request) StatComm.count_page_traffic(request) if not request.user.is_anonymous(): heartbeat_list = HeartBeat.objects.filter( owner=request.user).order_by('-pk') else: heartbeat_list = '' context = {'heartbeat_list': heartbeat_list} isMobile = dmb.process_request(request) if isMobile: return render(request, 'heartbeat/m_index.html', context) else: return render(request, 'heartbeat/index.html', context)
def index_day_words(request): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) day_words_list = Day_words.objects.all().order_by('-pk') words_list = [] each_word = {} if request.user.is_anonymous(): user = '' else: user = request.user #I need log module to get the efficiency of this for section for day_words in day_words_list: g_dayword_list = G_daywords.objects.filter(app=day_words) #count = g_dayword_list.count() #get if current user praised this day_word Praised = False for g_dayword in g_dayword_list: if user == g_dayword.owner: Praised = True break each_word = { 'word_id': day_words.id, 'username': day_words.user.get_full_name(), 'words': day_words.content, 'date': day_words.date, 'count': day_words.good_count, 'isPraised': Praised, 'comment_count': day_words.comment_count } words_list.append(each_word) context = {'words_list': words_list} isMobile = dmb.process_request(request) if isMobile: return render(request, 'daywords/m_index.html', context) else: return render(request, 'daywords/m_index.html', context)
def index(request): """ get all msg belong to current user """ StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(is_Mobile, request) msg_list = Msg.objects.filter(owner = request.user).order_by('-date') request.user.msg_mark = False; request.user.save() context = {'msg_list':msg_list} if is_Mobile: return render(request, 'msg/m_index.html', context ) else: return render(request, 'msg/m_index.html', context )
def index(request): """ get all msg belong to current user """ StatComm.count_page_traffic(request) is_Mobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(is_Mobile, request) msg_list = Msg.objects.filter(owner=request.user).order_by('-date') request.user.msg_mark = False request.user.save() context = {'msg_list': msg_list} if is_Mobile: return render(request, 'msg/m_index.html', context) else: return render(request, 'msg/m_index.html', context)
def change_tofuture(request,tofuture_id): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) #modify a last info try: tofuture_instance = get_object_or_404(Tofuture, id=tofuture_id, user=request.user) context = {'tofuture_instance':tofuture_instance, 'page':'change'} if isMobile: return render(request, 'tofuture/m_new.html', context ) else: return render(request, 'tofuture/m_new.html', context ) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def change_tofuture(request, tofuture_id): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) #modify a last info try: tofuture_instance = get_object_or_404(Tofuture, id=tofuture_id, user=request.user) context = {'tofuture_instance': tofuture_instance, 'page': 'change'} if isMobile: return render(request, 'tofuture/m_new.html', context) else: return render(request, 'tofuture/m_new.html', context) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def change_lastinfo(request,lastinfo_id): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) #modify a last info try: lastinfo_instance = get_object_or_404(LastInfo, id=lastinfo_id, user=request.user) lrcv_list = L_Receiver.objects.filter(lastinfo_pk = lastinfo_instance) context = {'lastinfo':lastinfo_instance, 'lrcv_list':lrcv_list, 'page':'change'} if isMobile: return render(request, 'lastinfo/m_new.html', context ) else: return render(request, 'lastinfo/new.html', context ) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def change_lastinfo(request, lastinfo_id): StatComm.count_page_traffic(request) isMobile = dmb.process_request(request) if request.user.is_anonymous(): return comm.redirect_login_path(isMobile, request) #modify a last info try: lastinfo_instance = get_object_or_404(LastInfo, id=lastinfo_id, user=request.user) lrcv_list = L_Receiver.objects.filter(lastinfo_pk=lastinfo_instance) context = { 'lastinfo': lastinfo_instance, 'lrcv_list': lrcv_list, 'page': 'change' } if isMobile: return render(request, 'lastinfo/m_new.html', context) else: return render(request, 'lastinfo/new.html', context) except Http404: return HttpResponseNotFound('<h1>Page not found</h1>')
def save_lastinfo(request): StatComm.count_page_traffic(request) #save the changes for last info if request.user.is_anonymous(): return redirect(settings.APP_WEB_LOGIN_URL) result = {} if request.method == 'POST': if 'title' in request.POST and 'recipients' in request.POST and 'days' in request.POST and 'content' in request.POST : title = request.POST.get('title') recipients = request.POST.get('recipients') days = request.POST.get('days') content = request.POST.get('content') page = request.POST.get('page') content = content.encode('utf8','ignore') title = title.encode('utf8','ignore') if recipients: list_recipient = recipients.split(',') #save last mail instance if page == 'new': last_info_instance = LastInfo.objects.create(title=title, days=days, mgs=content, user= request.user) last_info_instance.save() else: id = request.POST.get('id') try: last_info_instance = LastInfo.objects.get(id = id, user = request.user) last_info_instance.title = title last_info_instance.days = days last_info_instance.mgs = content last_info_instance.is_sent = '0' last_info_instance.save() except LastInfo.DoesNotExist: result['status'] = 'ERROR' result['MSG'] = '要修改的记录不存在...' return HttpResponse(json.dumps(result), content_type='application/json') l_rcvs = L_Receiver.objects.filter(lastinfo_pk=last_info_instance) for l_rcv in l_rcvs: l_rcv.delete() for recipient in list_recipient: l_rcv = L_Receiver.objects.create(email=recipient, lastinfo_pk=last_info_instance) l_rcv.save() result['status'] = 'OK' result['id'] = last_info_instance.id result['MSG'] = '已成功提交至服务器...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,你还是不对,不过我已经给你提示了...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,就不告诉你...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,气死你...' return HttpResponse(json.dumps(result), content_type='application/json')
def save_lastinfo(request): StatComm.count_page_traffic(request) #save the changes for last info if request.user.is_anonymous(): return redirect(settings.APP_WEB_LOGIN_URL) result = {} if request.method == 'POST': if 'title' in request.POST and 'recipients' in request.POST and 'days' in request.POST and 'content' in request.POST: title = request.POST.get('title') recipients = request.POST.get('recipients') days = request.POST.get('days') content = request.POST.get('content') page = request.POST.get('page') content = content.encode('utf8', 'ignore') title = title.encode('utf8', 'ignore') if recipients: list_recipient = recipients.split(',') #save last mail instance if page == 'new': last_info_instance = LastInfo.objects.create( title=title, days=days, mgs=content, user=request.user) last_info_instance.save() else: id = request.POST.get('id') try: last_info_instance = LastInfo.objects.get( id=id, user=request.user) last_info_instance.title = title last_info_instance.days = days last_info_instance.mgs = content last_info_instance.is_sent = '0' last_info_instance.save() except LastInfo.DoesNotExist: result['status'] = 'ERROR' result['MSG'] = '要修改的记录不存在...' return HttpResponse(json.dumps(result), content_type='application/json') l_rcvs = L_Receiver.objects.filter( lastinfo_pk=last_info_instance) for l_rcv in l_rcvs: l_rcv.delete() for recipient in list_recipient: l_rcv = L_Receiver.objects.create( email=recipient, lastinfo_pk=last_info_instance) l_rcv.save() result['status'] = 'OK' result['id'] = last_info_instance.id result['MSG'] = '已成功提交至服务器...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,你还是不对,不过我已经给你提示了...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,就不告诉你...' else: result['status'] = 'ERROR' result['MSG'] = '嘿嘿,气死你...' return HttpResponse(json.dumps(result), content_type='application/json')