本文整理汇总了Python中wouso.core.config.models.Setting类的典型用法代码示例。如果您正苦于以下问题:Python Setting类的具体用法?Python Setting怎么用?Python Setting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Setting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_custom_theme
def set_custom_theme(player, theme):
from wouso.utils import get_themes
from wouso.core.config.models import Setting
if theme in get_themes():
Setting.get('theme_user_%d' % player.id).set_value(theme)
return True
return False
示例2: chat_scripts
def chat_scripts():
"""
Dump the chat scris
:return:
"""
if settings.CHAT_ENABLED and not Setting.get('disable-Chat').get_value():
return render_to_string('chat/setup.html', {'chat_host': Setting.get('chat_host').get_value(),
'chat_port': Setting.get('chat_port').get_value(),
'basepath': settings.FORCE_SCRIPT_NAME,
})
return ''
示例3: coin_top_settings
def coin_top_settings(cls):
"""
Return a list of coin names for which we calculate the top
Example: ['gold', 'karma']
"""
return [c for c in Setting.get('top-coins').get_value().split(',') if c] or []
示例4: read
def read(self, request):
api = {
'api_version': API_VERSION,
'title': Setting.get('title').get_value(),
'authenticated': request.user.is_authenticated()
}
return api
示例5: render_zone
def render_zone(context, zone, glue):
"""
:return: HTML for the sidebar
"""
s = get_library(zone)
order = [k for k in Setting.get('%s-order' % zone).get_value().split(',') if k]
if not order:
order = s.get_blocks()
return glue.join([s.get_block(block, context) for block in order])
示例6: handle
def handle(self, *args, **options):
self.stdout.write('Starting at: %s\n' % datetime.now())
# Now handle other apps
from wouso.interface import get_apps
apps = get_apps()
for a in apps:
self.stdout.write('%s ...\n' % a.name())
a.management_task(stdout=self.stdout)
# Now handle games
for g in get_games():
if g.management_task:
self.stdout.write('%s ...\n' % g.name())
g.management_task(stdout=self.stdout)
now = datetime.now()
Setting.get('wousocron_lastrun').set_value('%s' % now)
self.stdout.write('Finished at: %s\n' % now)
示例7: get_theme
def get_theme():
"""
Return the current theme
"""
global _theme
if _theme is None:
from wouso.core.config.models import Setting
return Setting.get('theme').value
return _theme
示例8: setup_user_groups
def setup_user_groups():
# Assistants group, 'Staff'
staff = Group.objects.get_or_create(name='Staff')[0]
cpanel_perm = Permission.objects.get(codename='change_setting')
staff.permissions.add(cpanel_perm)
# Default entry race, 'Unaffiliated'
unaffiliated = Race.objects.get_or_create(name='Unaffiliated')[0]
unaffiliated.can_play = False
unaffiliated.save()
default_race = Setting.get('default_race')
default_race.set_value(str(unaffiliated.pk))
示例9: get_context_data
def get_context_data(self, **kwargs):
from wouso.games.quest.models import Quest, QuestGame
from django import get_version
from wouso.settings import WOUSO_VERSION, DATABASES
from wouso.core.config.models import Setting
database = DATABASES['default'].copy()
database_engine = database['ENGINE'].split('.')[-1]
database_name = database['NAME']
future_questions = Schedule.objects.filter(
day__gte=datetime.datetime.now())
nr_future_questions = len(future_questions)
questions = Question.objects.all()
nr_questions = len(questions)
active_quest = QuestGame().get_current()
total_quests = Quest.objects.all().count()
# artifacts
artifact_groups = ArtifactGroup.objects.all()
# admins
staff_group, new = auth.Group.objects.get_or_create(name='Staff')
# wousocron last_run
last_run = Setting.get('wousocron_lastrun').get_value()
if last_run == "":
last_run = "wousocron was never run"
# online members
oldest = datetime.datetime.now() - datetime.timedelta(minutes=10)
online_last10 = Player.objects.filter(last_seen__gte=oldest).order_by(
'-last_seen')
# number of players which can play
cp_number = Player.objects.filter(race__can_play=True).count()
context = super(StatusView, self).get_context_data(**kwargs)
context.update({'nr_future_questions': nr_future_questions,
'nr_questions': nr_questions,
'active_quest': active_quest,
'total_quests': total_quests,
'artifact_groups': artifact_groups,
'django_version': get_version(),
'wouso_version': WOUSO_VERSION,
'database_engine': database_engine,
'database_name': database_name,
'staff': staff_group,
'last_run': last_run,
'online_users': online_last10,
'cp_number': cp_number})
return context
示例10: render_header
def render_header(context):
s = get_library('header')
order = [k for k in Setting.get('header-order').get_value().split(',') if k]
if not order:
order = s.get_blocks()
content = ''
for block in order:
data = s.get_block(block, context)
if not data:
continue
content += '<span id="head-%s"><a href="%s">%s' % (block, data.get('link', ''), data.get('text', ''))
if data.get('count', 0):
content += '<sup class="unread-count">%s</sup>' % data.get('count')
content += '</a></span> '
return content
示例11: dashboard
def dashboard(request):
from wouso.games.quest.models import Quest, QuestGame
from django import get_version
from wouso.settings import WOUSO_VERSION
from wouso.core.config.models import Setting
future_questions = Schedule.objects.filter(day__gte=datetime.datetime.now())
nr_future_questions = len(future_questions)
questions = Question.objects.all()
nr_questions = len(questions)
active_quest = QuestGame().get_current()
total_quests = Quest.objects.all().count()
# artifacts
artifact_groups = ArtifactGroup.objects.all()
# admins
staff_group, new = auth.Group.objects.get_or_create(name='Staff')
# wousocron last_run
last_run = Setting.get('wousocron_lastrun').get_value()
if last_run == "":
last_run="wousocron was never run"
# online members
oldest = datetime.datetime.now() - datetime.timedelta(minutes = 10)
online_last10 = Player.objects.filter(last_seen__gte=oldest).order_by('-last_seen')
# number of players which can play
cp_number = Player.objects.filter(race__can_play=True).count()
return render_to_response('cpanel/index.html',
{'nr_future_questions' : nr_future_questions,
'nr_questions' : nr_questions,
'active_quest': active_quest,
'total_quests': total_quests,
'module': 'home',
'artifact_groups': artifact_groups,
'django_version': get_version(),
'wouso_version': WOUSO_VERSION,
'staff': staff_group,
'last_run': last_run,
'online_users': online_last10,
'cp_number': cp_number,
},
context_instance=RequestContext(request))
示例12: render_zone
def render_zone(context, zone, glue):
"""
:return: HTML for the sidebar
"""
s = get_library(zone)
order = [k for k in Setting.get('%s-order' % zone).get_value().split(',') if k]
if not order:
order = s.get_blocks()
# Do not print blocks with empty contents.
non_empty_block_contents = []
for block in order:
content = s.get_block(block, context)
if content and not content.isspace():
non_empty_block_contents.append(content)
return glue.join(non_empty_block_contents)
示例13: dashboard
def dashboard(request):
from wouso.games.quest.models import Quest, QuestGame
from django import get_version
from wouso.settings import WOUSO_VERSION
from wouso.core.config.models import Setting
future_questions = Schedule.objects.filter(day__gte=datetime.datetime.now())
nr_future_questions = len(future_questions)
questions = Question.objects.all()
nr_questions = len(questions)
active_quest = QuestGame().get_current()
total_quests = Quest.objects.all().count()
# artifacts
artifact_groups = ArtifactGroup.objects.all()
# admins
staff_group, new = auth.Group.objects.get_or_create(name='Staff')
# wousocron last_run
last_run = Setting.get('wousocron_lastrun').get_value()
return render_to_response('cpanel/index.html',
{'nr_future_questions' : nr_future_questions,
'nr_questions' : nr_questions,
'active_quest': active_quest,
'total_quests': total_quests,
'module': 'home',
'artifact_groups': artifact_groups,
'django_version': get_version(),
'wouso_version': WOUSO_VERSION,
'staff': staff_group,
'last_run': last_run,
},
context_instance=RequestContext(request))
示例14: post
def post(self, request):
data = request.POST['display']
blocks = ','.join([b.strip() for b in data.split(',') if b.strip()])
Setting.get('sidebar-order').set_value(blocks)
return redirect('cpanel_display')
示例15: get_theme_dir
def get_theme_dir(self):
""" Note (AE): I'm unhappy with this approach, since a Setting.get
call is done for every request. THIS must be cached somehow
"""
theme = Setting.get('theme').value
return os.path.join(settings.THEMES_ROOT, theme, 'templates')