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
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
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
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
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): 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), )
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))
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): 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))