本文整理汇总了Python中models.QotdGame.disabled方法的典型用法代码示例。如果您正苦于以下问题:Python QotdGame.disabled方法的具体用法?Python QotdGame.disabled怎么用?Python QotdGame.disabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.QotdGame
的用法示例。
在下文中一共展示了QotdGame.disabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sidebar_widget
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def sidebar_widget(context):
# TODO: nothing should happen in the sidebar_widget
user = context.get('user', None)
if not user or not user.is_authenticated():
return ''
if QotdGame.disabled():
return ''
qotd = QotdGame.get_for_today()
qotd_user = user.get_profile().get_extension(QotdUser)
if not qotd_user.has_question:
qotd_user.set_question(qotd)
else:
qotd = qotd_user.my_question
if qotd_user.has_answered:
time_passed = datetime.now() - qotd_user.last_answered
qotd_user.reset_question()
if time_passed > timedelta(seconds=120): # two minutes
return ''
return render_to_string('qotd/sidebar.html',
{'question': qotd,
'quser': qotd_user,
'qotd': QotdGame,
'id': 'qotd'})
示例2: done
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def done(request):
if QotdGame.disabled():
return redirect('wouso.interface.views.homepage')
# Do not show results until done
if not request.user.get_profile().get_extension(QotdUser).has_answered:
return redirect('games.qotd.views.history')
user = request.user.get_profile().get_extension(QotdUser)
qotd = user.my_question
if not qotd:
return redirect("homepage")
choice = user.last_answer
ans = [a for a in qotd.answers if a.id == choice]
if ans:
ans = ans[0]
valid = ans.correct
else:
ans = None
valid = False
return render_to_response('qotd/done.html',
{'question': qotd,
'choice': ans,
'valid': valid},
context_instance=RequestContext(request))
示例3: index
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def index(request):
if QotdGame.disabled():
return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
qotd = QotdGame.get_for_today()
profile = request.user.get_profile()
qotd_user = profile.get_extension(QotdUser)
if qotd_user.has_answered:
return HttpResponseRedirect(reverse('games.qotd.views.done'))
if qotd is None:
form = None
elif request.method == "POST":
form = QotdForm(qotd, request.POST)
if form.is_valid():
choice = int(form.cleaned_data['answers'])
QotdGame.answered(qotd_user, qotd, choice)
return HttpResponseRedirect(reverse('games.qotd.views.done'))
else:
form = QotdForm(qotd)
return render_to_response('qotd/index.html',
{'question': qotd, 'form': form},
context_instance=RequestContext(request))
示例4: done
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def done(request):
if QotdGame.disabled():
return HttpResponseRedirect(reverse("wouso.interface.views.homepage"))
# Do not show results until done
if not request.user.get_profile().get_extension(QotdUser).has_answered:
return HttpResponseRedirect(reverse("games.qotd.views.index"))
user = request.user.get_profile().get_extension(QotdUser)
qotd = user.my_question
if not qotd:
return redirect("homepage")
choice = user.last_answer
ans = [a for a in qotd.answers if a.id == choice]
if ans:
ans = ans[0]
valid = ans.correct
else:
ans = None
valid = False
return render_to_response(
"qotd/done.html", {"question": qotd, "choice": ans, "valid": valid}, context_instance=RequestContext(request)
)
示例5: index
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def index(request):
if QotdGame.disabled():
return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
profile = request.user.get_profile()
qotd_user = profile.get_extension(QotdUser)
if qotd_user.has_modifier('qotd-blind'):
return render_to_response('qotd/index.html', {"error":_("You have been blinded,you cannot answer to the Question of the Day")}, context_instance=RequestContext(request))
if not qotd_user.has_question:
qotd = QotdGame.get_for_today()
qotd_user.set_question(qotd)
else:
qotd = qotd_user.my_question
if qotd_user.has_answered:
qotd_user.reset_question()
extra = request.GET.urlencode()
if extra:
extra = '?' + extra
return HttpResponseRedirect(reverse('games.qotd.views.done') + extra)
if qotd is None:
form = None
elif request.method == "POST":
form = QotdForm(qotd, request.POST)
if form.is_valid():
choice = int(form.cleaned_data['answers'])
QotdGame.answered(qotd_user, qotd, choice)
extra = request.GET.urlencode()
if extra:
extra = '?' + extra
return HttpResponseRedirect(reverse('games.qotd.views.done') + extra)
else:
form = QotdForm(qotd)
return render_to_response('qotd/index.html',
{'question': qotd, 'form': form},
context_instance=RequestContext(request))
示例6: index
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def index(request):
if QotdGame.disabled():
return HttpResponseRedirect(reverse("wouso.interface.views.homepage"))
profile = request.user.get_profile()
qotd_user = profile.get_extension(QotdUser)
if qotd_user.magic.has_modifier("qotd-blind"):
messages.error(request, _("You have been blinded,you cannot answer to the Question of the Day"))
return redirect("games.qotd.views.history")
elif not qotd_user.has_question:
qotd = QotdGame.get_for_today()
qotd_user.set_question(qotd)
else:
qotd = qotd_user.my_question
if qotd_user.has_answered:
qotd_user.reset_question()
extra = request.GET.urlencode()
if extra:
extra = "?" + extra
return HttpResponseRedirect(reverse("games.qotd.views.done") + extra)
if qotd is None:
form = None
elif request.method == "POST":
form = QotdForm(qotd, request.POST)
if form.is_valid():
choice = int(form.cleaned_data["answers"])
QotdGame.answered(qotd_user, qotd, choice)
extra = request.GET.urlencode()
if extra:
extra = "?" + extra
return HttpResponseRedirect(reverse("games.qotd.views.done") + extra)
else:
form = QotdForm(qotd)
return render_to_response(
"qotd/index.html", {"question": qotd, "form": form}, context_instance=RequestContext(request)
)
示例7: dispatch
# 需要导入模块: from models import QotdGame [as 别名]
# 或者: from models.QotdGame import disabled [as 别名]
def dispatch(self, request, *args, **kwargs):
if QotdGame.disabled():
return redirect('wouso.interface.views.homepage')
profile = request.user.get_profile()
self.qotd_user = profile.get_extension(QotdUser)
if self.qotd_user.magic.has_modifier('qotd-blind'):
messages.error(request, _("You have been blinded, you cannot answer to the Question of the Day"))
return redirect('games.qotd.views.history')
elif not self.qotd_user.has_question:
self.qotd = QotdGame.get_for_today()
self.qotd_user.set_question(self.qotd)
else:
self.qotd = self.qotd_user.my_question
if self.qotd_user.has_answered:
self.qotd_user.reset_question()
return redirect('games.qotd.views.history')
return super(QotdView, self).dispatch(request, *args, **kwargs)