本文整理汇总了Python中models.ChallengeGame.get_active方法的典型用法代码示例。如果您正苦于以下问题:Python ChallengeGame.get_active方法的具体用法?Python ChallengeGame.get_active怎么用?Python ChallengeGame.get_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.ChallengeGame
的用法示例。
在下文中一共展示了ChallengeGame.get_active方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def read(self, request):
player = request.user.get_profile()
challuser = player.get_extension(ChallengeUser)
return [dict(status=c.status, date=c.date, id=c.id,
user_from=unicode(c.user_from.user),
user_from_id=c.user_from.user.id,
user_to=unicode(c.user_to.user),
user_to_id=c.user_to.user.id) for c in ChallengeGame.get_active(challuser)]
示例2: sidebar_widget
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def sidebar_widget(context):
user = context.get('user', None)
if not user or not user.is_authenticated():
return ''
chall_user = user.get_profile().get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
challs = [c for c in challs if c.status == 'A']
# reduce noise, thanks
if not challs:
return ''
return render_to_string('challenge/sidebar.html', {'challenges': challs,
'challenge': ChallengeGame, 'chall_user': chall_user, 'id': 'challenge'})
示例3: sidebar_widget
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def sidebar_widget(request):
profile = request.user.get_profile()
if not profile:
return ''
chall_user = profile.get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
challs = [c for c in challs if c.status == 'A']
# reduce noise, thanks
if not challs:
return ''
return render_to_string('challenge/sidebar.html', {'challenges': challs, 'challenge': ChallengeGame, 'chall_user': chall_user})
示例4: index
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def index(request):
""" Shows all challenges related to the current user """
profile = request.user.get_profile()
chall_user = profile.get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
played = ChallengeGame.get_played(chall_user)[:10]
if not chall_user.is_eligible():
messages.error(request, _('Your race can\'t play. Go home'))
return render_to_response('challenge/index.html',
{'challenges': challs, 'played': played, 'challuser': chall_user, 'challenge': ChallengeGame},
context_instance=RequestContext(request))
示例5: index
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def index(request):
""" Shows all challenges related to the current user """
profile = request.user.get_profile()
chall_user = profile.get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
played = ChallengeGame.get_played(chall_user)[:10]
if not chall_user.is_eligible():
return do_result(request, error='Ne pare rau, nu esti anul I, nu poti provoca. Te invitam pe wouso-next.rosedu.org')
return render_to_response('challenge/index.html',
{'challenges': challs, 'played': played, 'challuser': chall_user, 'challenge': ChallengeGame},
context_instance=RequestContext(request))
示例6: sidebar_widget
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def sidebar_widget(request):
if not request.user.is_authenticated():
return ""
chall_user = request.user.get_profile().get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
challs = [c for c in challs if c.status == "A"]
# reduce noise, thanks
if not challs:
return ""
return render_to_string(
"challenge/sidebar.html", {"challenges": challs, "challenge": ChallengeGame, "chall_user": chall_user}
)
示例7: sidebar_widget
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def sidebar_widget(context):
user = context.get("user", None)
if not user or not user.is_authenticated():
return ""
chall_user = user.get_profile().get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
challs = [c for c in challs if c.status == "A"]
# reduce noise, thanks
if not challs:
return ""
return render_to_string(
"challenge/sidebar.html",
{"challenges": challs, "challenge": ChallengeGame, "chall_user": chall_user, "id": "challenge"},
)
示例8: header_link
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def header_link(request):
profile = request.user.get_profile()
if profile:
chall_user = profile.get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
# remove launched challenges by the user
challs = [c for c in challs if not (c.status == 'L' and c.user_from.user == chall_user)]
# remove refused challenges
challs = [c for c in challs if not c.status == 'R']
count = len(challs)
else:
count = 0
url = reverse('wouso.games.challenge.views.index')
return dict(link=url, count=count, text=_('Challenges'))
示例9: index
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def index(request):
""" Shows all challenges related to the current user """
profile = request.user.get_profile()
chall_user = profile.get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
played = ChallengeGame.get_played(chall_user)[:10]
if not chall_user.is_eligible():
return do_result(request, error="Your race can't play. Go home")
return render_to_response(
"challenge/index.html",
{"challenges": challs, "played": played, "challuser": chall_user, "challenge": ChallengeGame},
context_instance=RequestContext(request),
)
示例10: header_link
# 需要导入模块: from models import ChallengeGame [as 别名]
# 或者: from models.ChallengeGame import get_active [as 别名]
def header_link(context):
user = context.get("user", None)
if not user or not user.is_authenticated():
return dict(text=_("Challenges"))
if ChallengeGame.disabled():
return ""
profile = user.get_profile()
if profile:
chall_user = profile.get_extension(ChallengeUser)
challs = ChallengeGame.get_active(chall_user)
# remove launched challenges by the user
challs = [c for c in challs if not (c.status == "L" and c.user_from.user == chall_user)]
# remove refused challenges
challs = [c for c in challs if not c.status == "R"]
count = len(challs)
else:
count = 0
url = reverse("wouso.games.challenge.views.index")
return dict(link=url, count=count, text=_("Challenges"))