summaryrefslogtreecommitdiff
blob: 6bc36f3ef5c50c68588031c69b9b99f9b69e1c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright 1998-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from django.shortcuts import get_object_or_404
from www.models import SiteSettings, Menys, SubMenys, Sponsors

def default_siteinfo(request, menyrequest):
    siteinfo = {}
    siteinfo['site'] = get_object_or_404(SiteSettings)
    activemeny = get_object_or_404(Menys, name = menyrequest)
    menys = Menys.objects.all().order_by('sort')
    #contact = get_object_or_404(SubPages, nav2 = 'contact')
    for meny in menys:
        if meny.title == 'Login' and request.user.is_authenticated:
            meny.show = False
        if meny.title == 'User' and request.user.is_authenticated:
            meny.show = True
        if meny.arg == '':
            meny.arg = False
    siteinfo['activemeny'] = activemeny
    siteinfo['menys'] = menys
    #siteinfo['contact'] = contact
    siteinfo['sponsors'] = Sponsors.objects.all()
    if activemeny.sub:
        submenys = SubMenys.objects.filter(MenyId = activemeny.id).order_by('sort')
        for submeny in submenys:
            if submeny.arg == '':
                submeny.arg = False
        siteinfo['submenys'] = submenys
        siteinfo['subactivemeny'] = False
    else:
        siteinfo['submenys'] = []
        siteinfo['subactivemeny'] = False
    return siteinfo