Example #1
0
 def read(self, request):
     from wouso.interface import get_custom_theme
     from wouso.utils import get_themes
     return {
         'theme': get_custom_theme(request.user.get_profile()),
         'themes': get_themes()
     }
Example #2
0
def context(request):
    """ Make all configuration settings available as config_name
    and also define some game context
    """
    settings = {}
    settings['basepath'] = FORCE_SCRIPT_NAME
    for s in Setting.objects.all():
        settings['config_' + s.name.replace('-','_').lower()] = s.get_value()

    # override theme using GET args
    if request.GET.get('theme', None) is not None:
        from wouso.utils import get_themes
        theme = request.GET['theme']
        if theme in get_themes():
            settings['config_theme'] = theme

    # shorthand user.get_profile
    settings['player'] = request.user.get_profile() if request.user.is_authenticated() else None

    # do not use minidetector for now
    mobile = detect_mobile(request)
    if mobile:
        settings['base_template'] = 'mobile_base.html'
    else:
        settings['base_template'] = 'site_base.html'
    settings['has_mobile'] = mobile_browser(request)

    if request.GET.get('ajax', False):
        settings['base_template'] = 'interface/ajax_message.html'

    return settings
Example #3
0
def context(request):
    """ Make all configuration settings available as config_name
    and also define some game context """
    settings = {}
    for s in Setting.objects.all():
        settings['config_' + s.name.replace('-', '_')] = s.get_value()

    # override theme using GET args
    if request.GET.get('theme', None) is not None:
        from wouso.utils import get_themes
        theme = request.GET['theme']
        if theme in get_themes():
            settings['config_theme'] = theme

    # shorthand user.get_profile
    settings['player'] = request.user.get_profile(
    ) if request.user.is_authenticated() else None

    # do not use minidetector for now
    mobile = detect_mobile(request)
    if mobile:
        settings['base_template'] = 'mobile_base.html'
    else:
        settings['base_template'] = 'site_base.html'

    if request.GET.get('ajax', False):
        settings['base_template'] = 'interface/ajax_message.html'

    return settings
Example #4
0
    def props(self):
        title = HTMLSetting.get('title')
        intro = HTMLSetting.get('intro')
        einfo = HTMLSetting.get('extrainfo')
        hf = HTMLSetting.get('hidden_footer')
        theme = ChoicesSetting.get('theme')
        theme.choices = [(t, t) for t in get_themes()]
        logo = Setting.get('logo')

        default_group = ChoicesSetting.get('default_group')
        default_group.choices = [('', '')] + [
            (unicode(g), str(g.id)) for g in PlayerGroup.objects.all()
        ]

        default_race = ChoicesSetting.get('default_race')
        default_race.choices = [(unicode(g), str(g.id))
                                for g in Race.objects.all()]

        question_number_of_answers = IntegerSetting.get(
            'question_number_of_answers')
        level_limits = IntegerListSetting.get('level_limits')
        head_start_date = DatetimeSetting.get('head_start_date')

        return [
            title, intro, theme, logo, hf, einfo, default_group, default_race,
            question_number_of_answers, level_limits, head_start_date
        ]
Example #5
0
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
Example #6
0
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
def context(request):
    """ Make all configuration settings available as config_name
    and also define some game context
    """
    settings_dict = {}
    settings_dict['basepath'] = FORCE_SCRIPT_NAME
    for s in Setting.objects.all():
        settings_dict['config_' +
                      s.name.replace('-', '_').lower()] = s.get_value()
    # Special config
    if not settings.CHAT_ENABLED:
        settings_dict['config_disable_chat'] = True
        settings_dict['config_disable_private_chat'] = True
    else:
        settings_dict['config_chat_host'] = settings.SOCKETIO_HOST
        settings_dict['config_chat_port'] = settings.SOCKETIO_PORT

    for k, v in settings_dict.iteritems():
        if k.startswith('config_disable'):
            try:
                settings_dict[k] = bool(v)
            except ValueError:
                pass

    # user defined theme
    if request.user.is_authenticated():
        custom_theme = settings_dict.get(
            'config_theme_user_%d' % request.user.get_profile().id, None)
        if custom_theme:
            settings_dict['config_theme'] = custom_theme
            set_theme(custom_theme)

    # override theme using GET args
    if request.GET.get('theme', None) is not None:
        from wouso.utils import get_themes
        theme = request.GET['theme']
        if theme in get_themes():
            settings_dict['config_theme'] = theme
            set_theme(theme)
    else:
        set_theme(settings_dict['config_theme'])

    # shorthand user.get_profile
    settings_dict['player'] = request.user.get_profile(
    ) if request.user.is_authenticated() else None

    # do not use minidetector for now
    mobile = detect_mobile(request)
    if mobile:
        settings_dict['base_template'] = 'mobile_base.html'
    else:
        settings_dict['base_template'] = 'site_base.html'
    settings_dict['has_mobile'] = mobile_browser(request)

    if request.GET.get('ajax', False):
        settings_dict['base_template'] = 'interface/ajax_message.html'

    return settings_dict
Example #8
0
def context(request):
    """ Make all configuration settings available as config_name
    and also define some game context
    """
    settings_dict = {}
    settings_dict['basepath'] = FORCE_SCRIPT_NAME
    for s in Setting.objects.all():
        settings_dict['config_' + s.name.replace('-','_').lower()] = s.get_value()
    # Special config
    if not settings.CHAT_ENABLED:
        settings_dict['config_disable_chat'] = True
        settings_dict['config_disable_private_chat'] = True
    else:
        settings_dict['config_chat_host'] = settings.SOCKETIO_HOST
        settings_dict['config_chat_port'] = settings.SOCKETIO_PORT

    for k, v in settings_dict.iteritems():
        if k.startswith('config_disable'):
            try:
                settings_dict[k] = bool(v)
            except ValueError: pass

    # user defined theme
    if request.user.is_authenticated():
        custom_theme = settings_dict.get('config_theme_user_%d' % request.user.get_profile().id, None)
        if custom_theme:
            settings_dict['config_theme'] = custom_theme
            set_theme(custom_theme)

    # override theme using GET args
    if request.GET.get('theme', None) is not None:
        from wouso.utils import get_themes
        theme = request.GET['theme']
        if theme in get_themes():
            settings_dict['config_theme'] = theme
            set_theme(theme)
    else:
        set_theme(settings_dict['config_theme'])

    # shorthand user.get_profile
    settings_dict['player'] = request.user.get_profile() if request.user.is_authenticated() else None

    # do not use minidetector for now
    mobile = detect_mobile(request)
    if mobile:
        settings_dict['base_template'] = 'mobile_base.html'
    else:
        settings_dict['base_template'] = 'site_base.html'
    settings_dict['has_mobile'] = mobile_browser(request)

    if request.GET.get('ajax', False):
        settings_dict['base_template'] = 'interface/ajax_message.html'

    settings_dict['static_pages'] = get_static_pages()
    return settings_dict
Example #9
0
    def props(self):
        title = HTMLSetting.get('title')
        intro = HTMLSetting.get('intro')
        einfo = HTMLSetting.get('extrainfo')
        hf = HTMLSetting.get('hidden_footer')
        theme = ChoicesSetting.get('theme')
        theme.choices = [(t,t) for t in get_themes()]
        logo = Setting.get('logo')

        default_group = ChoicesSetting.get('default_group')
        default_group.choices = [(unicode(g), str(g.id)) for g in PlayerGroup.objects.all()]

        default_race = ChoicesSetting.get('default_race')
        default_race.choices = [(unicode(g), str(g.id)) for g in Race.objects.all()]

        return [title, intro, theme, logo, hf, default_group, default_race, einfo]
Example #10
0
    def props(self):
        title = HTMLSetting.get("title")
        intro = HTMLSetting.get("intro")
        einfo = HTMLSetting.get("extrainfo")
        hf = HTMLSetting.get("hidden_footer")
        theme = ChoicesSetting.get("theme")
        theme.choices = [(t, t) for t in get_themes()]
        logo = Setting.get("logo")

        default_group = ChoicesSetting.get("default_group")
        default_group.choices = [("", "")] + [(unicode(g), str(g.id)) for g in PlayerGroup.objects.all()]

        default_race = ChoicesSetting.get("default_race")
        default_race.choices = [(unicode(g), str(g.id)) for g in Race.objects.all()]

        return [title, intro, theme, logo, hf, default_group, default_race, einfo]
Example #11
0
    def props(self):
        title = HTMLSetting.get('title')
        intro = HTMLSetting.get('intro')
        einfo = HTMLSetting.get('extrainfo')
        hf = HTMLSetting.get('hidden_footer')
        theme = ChoicesSetting.get('theme')
        theme.choices = [(t,t) for t in get_themes()]
        logo = Setting.get('logo')

        default_group = ChoicesSetting.get('default_group')
        default_group.choices = [('', '')] + [(unicode(g), str(g.id)) for g in PlayerGroup.objects.all()]

        default_race = ChoicesSetting.get('default_race')
        default_race.choices = [(unicode(g), str(g.id)) for g in Race.objects.all()]

        return [title, intro, theme, logo, hf, default_group, default_race, einfo]
Example #12
0
    def props(self):
        title = HTMLSetting.get('title')
        intro = HTMLSetting.get('intro')
        einfo = HTMLSetting.get('extrainfo')
        hf = HTMLSetting.get('hidden_footer')
        theme = ChoicesSetting.get('theme')
        theme.choices = [(t, t) for t in get_themes()]
        logo = Setting.get('logo')

        default_group = ChoicesSetting.get('default_group')
        default_group.choices = [('', '')] + [(unicode(g), str(g.id)) for g in PlayerGroup.objects.all()]

        default_race = ChoicesSetting.get('default_race')
        default_race.choices = [(unicode(g), str(g.id)) for g in Race.objects.all()]

        question_number_of_answers = IntegerSetting.get('question_number_of_answers')

        level_limits = IntegerListSetting.get('level_limits')

        return [title, intro, theme, logo, hf, default_group, default_race, einfo, question_number_of_answers,
                level_limits]
Example #13
0
    def props(self):
        title = HTMLSetting.get('title')
        intro = HTMLSetting.get('intro')
        einfo = HTMLSetting.get('extrainfo')
        hf = HTMLSetting.get('hidden_footer')
        theme = ChoicesSetting.get('theme')
        theme.choices = [(t, t) for t in get_themes()]
        logo = Setting.get('logo')

        default_group = ChoicesSetting.get('default_group')
        default_group.choices = [(unicode(g), str(g.id))
                                 for g in PlayerGroup.objects.filter(gclass=0)]

        default_series = ChoicesSetting.get('default_series')
        default_series.choices = [(unicode(g), str(g.id))
                                  for g in PlayerGroup.objects.filter(gclass=1)
                                  ]

        return [
            title, intro, theme, logo, hf, default_group, default_series, einfo
        ]
Example #14
0
 def read(self, request):
     from wouso.interface import get_custom_theme
     from wouso.utils import get_themes
     return {'theme': get_custom_theme(request.user.get_profile()), 'themes': get_themes()}