本文整理汇总了Python中wouso.core.config.models.BoolSetting.get方法的典型用法代码示例。如果您正苦于以下问题:Python BoolSetting.get方法的具体用法?Python BoolSetting.get怎么用?Python BoolSetting.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wouso.core.config.models.BoolSetting
的用法示例。
在下文中一共展示了BoolSetting.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_header_link
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def get_header_link(kls, request):
if BoolSetting.get('disable-Chat').get_value():
return {}
url = reverse('wouso.interface.chat.views.index')
count = 0
return dict(link=url, text=_('Chat'), count=count)
示例2: index
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def index(request):
if BoolSetting.get('disable-Chat').get_value():
return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
user = request.user.get_profile()
return render_to_response('chat.html', {'user': user},
context_instance=RequestContext(request))
示例3: get_context_data
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def get_context_data(self, **kwargs):
context = super(BazaarView, self).get_context_data(**kwargs)
player = self.request.user.get_profile() if self.request.user.is_authenticated() else None
spells = Spell.objects.all().order_by('-available', 'level_required')
# Disable exchange for real
exchange_disabled = BoolSetting.get('disable-Bazaar-Exchange').get_value()
try:
rate = scoring.calculate('gold-points-rate', gold=1)['points']
rate2 = round(1/scoring.calculate('points-gold-rate', points=1)['gold'])
except InvalidFormula:
rate, rate2 = 1, 1
rate_text = _('Rate: 1 gold = {rate} points, {rate2} points = 1 gold').format(rate=rate,
rate2=rate2)
cast_spells = PlayerSpellDue.objects.filter(source=player).all()
unseen_count = cast_spells.filter(seen=False).count()
# TODO: think of smth better
cast_spells.update(seen=True)
context.update({'spells': spells,
'rate': rate, 'rate_text': rate_text,
'cast': cast_spells,
'unseen_count': unseen_count,
'theowner': player,
'exchange_disabled': exchange_disabled})
return context
示例4: bazaar
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def bazaar(request, message='', error=''):
player = request.user.get_profile() if request.user.is_authenticated() else None
spells = Spell.objects.all().order_by('-available', 'level_required')
# Disable exchange for real
exchange_disabled = BoolSetting.get('disable-Bazaar-Exchange').get_value()
try:
rate = scoring.calculate('gold-points-rate', gold=1)['points']
rate2 = round(1/scoring.calculate('points-gold-rate', points=1)['gold'])
except InvalidFormula:
rate, rate2 = 1, 1
rate_text = _('Rate: 1 gold = {rate} points, 1 gold = {rate2} points').format(rate=rate, rate2=rate2)
cast_spells = PlayerSpellDue.objects.filter(source=player).all()
unseen_count = cast_spells.filter(seen=False).count()
# TODO: think of smth better
cast_spells.update(seen=True)
return render_to_response('magic/bazaar.html', {'spells': spells,
'rate': rate, 'rate_text': rate_text,
'cast': cast_spells,
'unseen_count': unseen_count,
'theowner': player,
'message': message,
'exchange_disabled': exchange_disabled,
'error': error},
context_instance=RequestContext(request))
示例5: disabled
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def disabled(kls):
""" Search for a disabled config setting.
"""
from wouso.core.config.models import BoolSetting
name = kls.__name__
return BoolSetting.get('disable-%s' % name).get_value()
示例6: get_sidebar_widget
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def get_sidebar_widget(kls, request):
top5 = TopUser.objects.exclude(user__is_superuser=True).exclude(race__can_play=False)
top5 = top5.order_by('-points')[:10]
is_top = request.get_full_path().startswith('/top/')
return render_to_string('top/sidebar.html',
{'topusers': top5,
'is_top': is_top,
'top': Top,
'coin_top_setting': kls.coin_top_settings(),
'config_disable_challenge_top': BoolSetting.get('disable-Challenge-Top').get_value(),
}
)
示例7: archive
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def archive(request):
user = request.user.get_profile()
chat_user = get_author(request)
if user.has_modifier('block-global-chat-page') or user.has_modifier('block-communication') or not chat_user.canAccessChat:
return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
if BoolSetting.get('disable-Chat').get_value():
return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
return render_to_response('chat/archive.html',
{'chat_user': user,
},
context_instance=RequestContext(request))
示例8: challenge_random
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def challenge_random(request):
setting = BoolSetting.get("random_challenge").get_value()
if setting:
messages.error(request, _("Random challenge disabled"))
return redirect("challenge_index_view")
current_player = request.user.get_profile().get_extension(ChallengeUser)
player = current_player.get_random_opponent()
if not player:
messages.error(request, _("There is no one you can challenge now."))
return redirect("challenge_index_view")
return redirect("challenge_launch", player.id)
示例9: bazaar_exchange
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def bazaar_exchange(request):
gold_rate = scoring.calculate('gold-points-rate', gold=1)['points']
points_rate = scoring.calculate('points-gold-rate', points=1)['gold']
player = request.user.get_profile()
message, error = '', ''
if BoolSetting.get('disable-Bazaar-Exchange').get_value():
error = _("Exchange is disabled")
elif request.method == 'POST':
try:
points = float(request.POST.get('points', 0))
gold = round(float(request.POST.get('gold', 0)))
except:
error = _('Invalid amounts')
else:
if points != 0:
gold = points_rate * points
if gold > 0:
if player.points < points:
error = _('Insufficient points')
else:
points = round(gold) / points_rate
scoring.score(player, None, 'points-gold-rate', points=points)
message = _('Converted successfully')
else:
error = _('Insufficient points')
# other way around
elif gold != 0:
points = gold_rate * gold
if player.coins['gold'] < gold:
error = _('Insufficient gold')
else:
scoring.score(player, None, 'gold-points-rate', gold=gold)
message = _('Converted successfully')
else:
error = _('Unknown action')
else:
error = _('Expected post')
if error:
messages.error(request, error)
if message:
messages.success(request, message)
return render_to_response('magic/bazaar_buy.html',
{'tab': 'exchange'},
context_instance=RequestContext(request))
示例10: index
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def index(request):
if BoolSetting.get('disable-Chat').get_value():
return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
profile = request.user.get_profile()
# gather users online in the last ten minutes
oldest = datetime.datetime.now() - datetime.timedelta(minutes = 10)
online_last10 = Player.objects.filter(last_seen__gte=oldest).order_by('-last_seen')
user = request.user.get_profile()
return render_to_response('chat.html',
{'user': user,
'last10': online_last10,
},
context_instance=RequestContext(request))
示例11: user_profile
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def user_profile(request, id, page=u'1'):
profile = get_object_or_404(Player, id=id)
activity_list = Activity.get_player_activity(profile)
top_user = profile.get_extension(TopUser)
history = History.user_points(profile.user)
paginator = Paginator(activity_list, 10)
try:
activity = paginator.page(page)
except (EmptyPage, InvalidPage):
activity = paginator.page(paginator.num_pages)
# some hackish introspection
if hasattr(g, 'user_model'):
model = getattr(g, 'user_model')
setattr(profile, model.__name__.lower(), profile.get_extension(model))
#Fix to show succes message from report user form
if 'report_msg' in request.session:
message = request.session['report_msg']
del request.session['report_msg']
else:
message=''
challenge_launched_recently = Challenge.exist_last_day(date.today(),
request.user.get_profile(), profile)
specialquest_button = SpecialQuestGame.get_specialquest_user_button(request, profile)
config_disable_magic = BoolSetting.get('setting-magic').get_value() is False
return render_to_response('profile/profile.html',
{'profile': profile,
'activity': activity,
'top': top_user,
'scoring': history,
'challenge_launched_recently': challenge_launched_recently,
'specialquest_button': specialquest_button,
'config_disable_magic': config_disable_magic,
'message': message},
context_instance=RequestContext(request))
示例12: bazaar
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def bazaar(request, message='', error=''):
player = request.user.get_profile() if request.user.is_authenticated() else None
spells = Spell.objects.all().order_by('-available', 'level_required')
# Disable exchange for real
exchange_disabled = BoolSetting.get('disable-Bazaar-Exchange').get_value()
try:
rate = scoring.calculate('gold-points-rate', gold=1)['points']
rate2 = round(1/scoring.calculate('points-gold-rate', points=1)['gold'])
except InvalidFormula:
rate, rate2 = 1, 1
rate_text = _('Rate: 1 gold = {rate} points, 1 gold = {rate2} points').format(rate=rate, rate2=rate2)
cast_spells = PlayerSpellDue.objects.filter(source=player).all()
unseen_count = cast_spells.filter(seen=False).count()
# TODO: think of smth better
cast_spells.update(seen=True)
# get all significant magic activity
activity_list = Activity.objects.filter(Q(action='spell-buy') | Q(action='earned-ach') | Q(action__contains='gold') | Q(action='cast')).order_by('-timestamp')
paginator = Paginator(activity_list, 40)
try:
activity = paginator.page(1)
except (EmptyPage, InvalidPage):
activity = paginator.page(paginator.num_pages)
return render_to_response('magic/bazaar.html', {'spells': spells,
'activity': activity,
'rate': rate, 'rate_text': rate_text,
'cast': cast_spells,
'unseen_count': unseen_count,
'theowner': player,
'message': message,
'exchange_disabled': exchange_disabled,
'error': error},
context_instance=RequestContext(request))
示例13: challenge_random
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def challenge_random(request):
setting = BoolSetting.get('disable-challenge-random').get_value()
if setting:
messages.error(request, _('Random challenge disabled'))
return redirect('challenge_index_view')
current_player = request.user.get_profile().get_extension(ChallengeUser)
# selects challengeable players
players = ChallengeUser.objects.exclude(user = current_player.user)
players = players.exclude(race__can_play=False)
players = [p for p in players if current_player.can_challenge(p)]
if not players:
messages.error(request, _('There is no one you can challenge now.'))
return redirect('challenge_index_view')
no_players = len(players)
# selects the user to be challenged
import random
i = random.randrange(0, no_players)
return launch(request, players[i].id)
示例14: homepage
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def homepage(request, page=u'1'):
""" First page shown """
if request.user.is_anonymous():
return anonymous_homepage(request)
profile = request.user.get_profile()
# gather users online in the last ten minutes
oldest = datetime.datetime.now() - datetime.timedelta(minutes = 10)
online_last10 = Player.objects.filter(last_seen__gte=oldest).order_by('-last_seen')
activity = get_wall(page)
topuser = profile.get_extension(TopUser)
topgroups = [profile.group] if profile.group else []
for g in topgroups:
g.position = TopHistory.get_user_position(topuser, relative_to=g)
if detect_mobile(request) and BoolSetting.get('setting-mobile-version').get_value():
template = 'mobile_index.html'
else:
template = 'site_index.html'
news = NewsItem.objects.all().order_by('-date_pub', '-id')
more = False
if len(news) > 10:
more = True
news = news[:10]
return render_to_response(template,
{'last10': online_last10, 'activity': activity,
'is_homepage': True,
'top': topuser,
'topgroups': topgroups,
'games': get_games(),
'news': news,
'more': more,
},
context_instance=RequestContext(request))
示例15: magic_cast
# 需要导入模块: from wouso.core.config.models import BoolSetting [as 别名]
# 或者: from wouso.core.config.models.BoolSetting import get [as 别名]
def magic_cast(request, destination=None, spell=None):
player = request.user.get_profile()
destination = get_object_or_404(Player, pk=destination)
error = ''
if Bazaar.disabled() or BoolSetting.get('disable-Magic').get_value():
error = _("Magic is disabled")
elif request.method == 'POST':
spell = get_object_or_404(Spell, pk=request.POST.get('spell', 0))
try:
days = int(request.POST.get('days', 0))
except ValueError:
pass
else:
if (days > spell.due_days) or ((spell.due_days > 0) and (days < 1)):
error = _('Invalid number of days')
else:
due = datetime.now() + timedelta(days=days)
if not spell.mass:
error = destination.magic.cast_spell(spell=spell, source=player, due=due)
else:
players = destination.get_neighbours_from_top(2, player.race, spell.type)
players = player.magic.filter_players_by_spell(players, spell)
error = player.magic.mass_cast(spell=spell, destination=players, due=due)
if not error:
return HttpResponseRedirect(reverse('wouso.interface.profile.views.user_profile', args=(destination.id,)))
error = _('Cast failed:') + ' ' + error
if error:
messages.error(request, error)
return render_to_response('profile/cast.html',
{'destination': destination},
context_instance=RequestContext(request))