# Copyright 1998-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from django.shortcuts import render, get_object_or_404, HttpResponseRedirect from django.conf import settings from gentoo_www.models import SiteSettings, Layout, Pages, SubPages, Sponsors, Posts from tbc_www.models import EbuildsMetadata, BuildLogs, BuildJobs, BuildLogsRepomanQa, \ BuildJobsUse import re def default_TmpDict(pagerequest): site = get_object_or_404(SiteSettings) page = get_object_or_404(Pages, nav1 = pagerequest) pages = Pages.objects.all() if page.SubMenu: subpages = SubPages.objects.filter(PageId = page.PageId) else: subpages = False contact = get_object_or_404(SubPages, nav2 = 'contact') TmpDict = {'site' : site} TmpDict['page'] = page TmpDict['pages'] = pages TmpDict['subpages'] = subpages TmpDict['contact'] = contact TmpDict['smappages'] = SubPages.objects.all() return TmpDict def home(request): pagerequest = 'home' Lines = 10 adict = {} TmpDict = default_TmpDict(pagerequest) TmpDict['EM'] = EbuildsMetadata.objects.filter(Revision = '1.1').order_by('-Id')[:Lines] TmpDict['BL'] = BuildLogs.objects.order_by('-TimeStamp')[:Lines] BJ_Tmp = BuildJobs.objects.order_by('-TimeStamp')[:Lines] for BJ in BJ_Tmp: adict2 = {} adict2['EbuildId'] = BJ.EbuildId.EbuildId adict2['C'] = BJ.EbuildId.PackageId.CategoryId.Category adict2['P'] = BJ.EbuildId.PackageId.Package adict2['V'] = BJ.EbuildId.Version adict2['R'] = BJ.EbuildId.PackageId.RepoId.Repo adict2['title'] = "Setup: " + BJ.SetupId.Setup + "\n" + "Profile: " + BJ.SetupId.Profile + "\n" BJU = BuildJobsUse.objects.filter(BuildJobId = BJ.BuildJobId) if not BJU == []: use_enable = [] use_disable = [] for BU in BJU: if BU.Status: use_enable.append(BU.UseId.Flag) else: use_disable.append(BU.UseId.Flag) if not use_enable == []: adict2['title'] = adict2['title'] + "Enable: " for use in use_enable: adict2['title'] = adict2['title'] + use + " " adict2['title'] = adict2['title'] + "\n" if not use_disable == []: adict2['title'] = adict2['title'] + "Disable: " for use in use_disable: adict2['title'] = adict2['title'] + use + " " adict2['title'] = adict2['title'] + "\n" adict[BJ.BuildJobId] = adict2 TmpDict['BJ'] = adict TmpDict['RM'] = BuildLogsRepomanQa.objects.order_by('-Id')[:Lines] return render(request, 'pages/' + pagerequest + '/index.html', TmpDict)