Esempio n. 1
0
from django.template import RequestContext, loader
from django.http import HttpResponse
from torpedo_main.menu import get_menu, RootMenu, MenuItem
from statistics.models import League, Player
from django.utils.translation import ugettext as _
from django.http.response import HttpResponseRedirect

menu = get_menu()

def rooturl(lid):
    return '/statistics/%s/' % lid

def resturl(lid):
    return '/statistics/%s/rest/' % lid

def get_breadcrums(request, league):
    parts = request.path.strip('/').split('/')
    breadcrumb = RootMenu()
    breadcrumb.children['statistics'] = MenuItem(name=_('Statistics'), href='/statistics/%s' % league)
    lobj = League.objects.get(id=league)
    breadcrumb.children['league'] = MenuItem(name=lobj.name, href='/statistics/%s' % league)
    for lobj in League.objects.all():
        breadcrumb.children['league'].children[lobj.name] = MenuItem(name=lobj.name, href='/statistics/%s/' % lobj.id)
    if len(parts) == 2: 
        breadcrumb.children['next'] = MenuItem(name=_('next'), href='/statistics/%s' % league)
        breadcrumb.children['next'].children['teams'] = MenuItem(name='Teams', href='/statistics/%s/teams' % league)
        breadcrumb.children['next'].children['games'] = MenuItem(name='Games', href='/statistics/%s/games' % league)
    elif parts[-1] == 'teams':
        breadcrumb.children['teams'] = MenuItem(name=_('Teams'), href='/statistics/%s/teams' % league)
        breadcrumb.children['teams'].children['games'] = MenuItem(name='Games', href='/statistics/%s/games' % league)
    elif parts[-1] == 'games':
Esempio n. 2
0
def load_menu(request):
    """Loads the menu for the context for the given request"""
    menu = get_menu()
    menu.active = get_active_menu(menu, request.path)
    return {'torpedo_menu': menu}
Esempio n. 3
0
def channel(request):
    menu = get_menu()
    menu.active = "home"
    return flatpage(request, "/channel/", menu=menu)
Esempio n. 4
0
def association(request):
    menu = get_menu()
    menu.active = "association"
    return flatpage(request, "/association/", menu=menu)
Esempio n. 5
0
 def get_context_data(self, **kwargs):
     menu = get_menu()
     menu.active = None
     kwargs["menu"] = menu
     return kwargs
Esempio n. 6
0
 def render(self, context):
     return get_menu()