def getuserltry(request): userltry = getUserBase(request) userltry['has_got_one'] = False userltry['mychance'] = 0 cur_user = User.objects.get(username=request.user.username) cur_action = Actions.objects.filter( action_type__actiontype_code=settings.ACTIONTYPEOFREWARD, is_cur_action=True) if cur_action: myrwd = MyRewards.objects.filter(action=cur_action, username=request.user.username) #如果本次活动已中奖 if myrwd: userltry['has_got_one'] = True else: today_first = datetime.datetime.now().strftime( '%Y-%m-%d') + r' 00:00:00' ltylog = LotteryLog.objects.filter( username=cur_user, action=cur_action, opt_ts__gt=datetime.datetime.strptime(today_first, "%Y-%m-%d %H:%M:%S")) #如果今天已抽过奖 if ltylog: userltry['mychance'] = 0 else: userltry['mychance'] = settings.LOTTERY_CHANCE_DAILY else: userltry['mychance'] = 0 return userltry
def visittopic(request,offset): try: topic_id = int(offset) except ValueError: raise Http404() parmdic = getUserBase(request) topic = Cbbs.objects.get(id=topic_id) topic_user = User.objects.get(username=topic.username) tp_comments = Comments.objects.filter(cbbs=topic).order_by('-create_ts') parmdic['topic_title'] = '['+topic.cbbsctgy.cbbsctgy_desc+']'+topic.title parmdic['topic_content'] = topic.content parmdic['topic_userid'] = topic_user.id parmdic['topic_useravatar'] = getUserAvatarURL(topic_user) parmdic['ctgy'] = topic.category.ctgy_desc parmdic['ctgyidx'] = int(topic.category.ctgy_code)-1 parmdic['topic_create_ts'] = topic.create_ts parmdic['topic_id'] = topic.id parmdic['comments'] = tp_comments # parmdic['topic_viewers'] = topic.viewers parmdic['topic_comnts'] = topic.comnts if topic_user.nickname: parmdic['topic_showname'] = topic_user.nickname else: parmdic['topic_showname'] = topic_user.username saveuserlog(request.user.username,settings.VIEW_OPT_CODE,topic.id) topic.refresh_from_db() parmdic['topic_viewers'] = topic.viewers return render(request,"topic.html",parmdic)
def visitcom(request): parmdic = getUserBase(request) anns = Announcement.objects.filter(is_curanncm=True).order_by('-update_ts') if anns: parmdic['announce'] = anns[0] # 闲聊区主题列表 parmdic['cbbslist'] = Cbbs.objects.filter(category__ctgy_code=settings.XL_MODULE_CODE).order_by('-priority','-update_ts') # 提问区主题列表 parmdic['cbbslist2'] = Cbbs.objects.filter(category__ctgy_code=settings.TW_MODULE_CODE).order_by('-priority','-update_ts') # 反馈区主题列表 parmdic['cbbslist3'] = Cbbs.objects.filter(category__ctgy_code=settings.FK_MODULE_CODE).order_by('-priority','-update_ts') return render(request,"community.html",parmdic)
def aboutus(request): """关于我们页面""" #参数列表 parmdic = {} #用户已登陆 if request.user.is_authenticated(): parmdic = getUserBase(request) parmdic['anymous'] = False else: parmdic['showname'] = u'游客' parmdic['anymous'] = True parmdic['hostinfo'] = request.get_host() parmdic['isStaff'] = request.user.is_staff return render(request, 'about.html', parmdic)
def smarket(request): """积分商城页面""" parmdic = getUserBase(request) return render(request, 'scoremarket.html', parmdic)