summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'python/tbc_www/views.py')
-rw-r--r--python/tbc_www/views.py60
1 files changed, 43 insertions, 17 deletions
diff --git a/python/tbc_www/views.py b/python/tbc_www/views.py
index c272c50..df3a84a 100644
--- a/python/tbc_www/views.py
+++ b/python/tbc_www/views.py
@@ -11,7 +11,7 @@ from gentoo_www.models import SiteSettings, Layout, Pages, SubPages, Sponsors, P
from tbc_www.models import EbuildsMetadata, BuildLogs, BuildJobs, BuildLogsQa, \
BuildJobsUse, Categories, CategoriesMetadata, Packages, PackagesMetadata, Ebuilds, \
Repos, EbuildsKeywords, BuildLogsErrors, EbuildsRestrictions, EbuildsIuse, PackagesRepoman, \
- BuildLogsConfig, BuildLogsUse, BuildLogsRepoman, PackagesEmails, Jobs
+ BuildLogsConfig, BuildLogsUse, BuildLogsRepoman, PackagesEmails, Jobs, ConfigsMetaData
import re
import gzip
import os
@@ -258,23 +258,33 @@ def new_repoman(request):
def new_logs(request):
pagerequest = 'logs'
+ object_on_page = 100
TmpDict = default_TmpDict(pagerequest)
+ BL_tmp = BuildLogs.objects.order_by('-TimeStamp')
alist = []
- for BL in BuildLogs.objects.order_by('-TimeStamp').filter(New = True):
- adict2 = {}
- adict2['BuildLogId'] = BL.BuildLogId
- adict2['C'] = BL.EbuildId.PackageId.CategoryId.Category
- adict2['P'] = BL.EbuildId.PackageId.Package
- adict2['V'] = BL.EbuildId.Version
- adict2['R'] = BL.EbuildId.PackageId.RepoId.Repo
- adict2['Fail'] = BL.Fail
- adict2['SummeryText'] = BL.SummeryText
+ for BL in BL_tmp:
+ adict = {}
+ adict['BuildLogId'] = BL.BuildLogId
+ adict['C'] = BL.EbuildId.PackageId.CategoryId.Category
+ adict['P'] = BL.EbuildId.PackageId.Package
+ adict['V'] = BL.EbuildId.Version
+ adict['R'] = BL.EbuildId.PackageId.RepoId.Repo
+ adict['Fail'] = BL.Fail
+ adict['SummeryText'] = BL.SummeryText
if BL.Fail:
- adict2['FI'] = fail_status(BL.BuildLogId)
- alist.append(adict2)
- TmpDict['BL_tmp'] = alist
- TmpDict['QA_tmp'] = BuildLogsQa.objects.filter(BuildLogId__New = True)
- TmpDict['RM_tmp'] = BuildLogsRepoman.objects.filter(BuildLogId__New = True)
+ adict['FI'] = fail_status(BL.BuildLogId)
+ alist.append(adict)
+ paginator = Paginator(alist, object_on_page)
+ page = request.GET.get('page')
+ try:
+ BL_tmp = paginator.page(page)
+ except PageNotAnInteger:
+ # If page is not an integer, deliver first page.
+ BL_tmp = paginator.page(1)
+ except EmptyPage:
+ # If page is out of range (e.g. 9999), deliver last page of results.
+ BL_tmp = paginator.page(paginator.num_pages)
+ TmpDict['BL_tmp'] = BL_tmp
return render(request, 'pages/logs/index.html', TmpDict)
def new_build_logs_all(request):
@@ -311,7 +321,6 @@ def new_build_logs_all(request):
def new_logs_build(request, buildlog_id):
pagerequest = 'logs'
TmpDict = default_TmpDict(pagerequest)
- TmpDict['Bugzillalogin'] = False
B = BuildLogs.objects.get(BuildLogId = buildlog_id)
EM = EbuildsMetadata.objects.get(EbuildId = B.EbuildId.EbuildId)
PM = PackagesMetadata.objects.get(PackageId__PackageId = B.EbuildId.PackageId.PackageId)
@@ -389,6 +398,8 @@ def submit_to_bugzilla(request, form, buildlog_id):
Filesize = os.path.getsize(LogDir + LogFile)/1024
if Filesize > 900:
#FIXME UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
+ # python-bugzilla need a fix in attachment()
+ # f = open(attachment) -> f = open(attachment, 'rb')
with open(LogDir + LogFile, 'rb') as orig_file:
with gzip.open('/tmp' + BC.LogName + '.gz', 'wb') as zipped_file:
zipped_file.writelines(orig_file)
@@ -403,6 +414,11 @@ def submit_to_bugzilla(request, form, buildlog_id):
def buildinfo_bugzilla(request, buildlog_id):
pagerequest = 'logs'
+ if not 'bugzillapassword' in request.session:
+ request.session['bugzillabuildid'] = buildlog_id
+ return redirect('set_bugzilla_user')
+ if 'bugzillabuildid' in request.session:
+ del request.session['bugzillabuildid']
TmpDict = default_TmpDict(pagerequest)
B = get_object_or_404(BuildLogs, BuildLogId = buildlog_id)
C = B.EbuildId.PackageId.CategoryId.Category
@@ -439,10 +455,10 @@ def buildinfo_bugzilla(request, buildlog_id):
def set_bugzilla_user(request):
pagerequest = 'home'
TmpDict = default_TmpDict(pagerequest)
+ b = Bugzilla.objects.get(Username=request.user.username)
if request.method == 'POST':
form = BugzillaUser(request.POST)
if form.is_valid():
- b = Bugzilla.objects.get(Username=request.user.username)
if b == []:
b = Bugzilla(Bugzillaname = form.cleaned_data['BugzillaName'], Username = request.user.username)
b.save()
@@ -451,9 +467,19 @@ def set_bugzilla_user(request):
b.Bugzillaname = form.cleaned_data['BugzillaName']
b.save()
request.session['bugzillapassword'] = form.cleaned_data['BugzillaPassword']
+ if 'bugzillabuildid' in request.session:
+ return redirect('buildinfo_bugzilla', buildlog_id=request.session['bugzillabuildid'])
return HttpResponseRedirect('/home/')
else:
form = BugzillaUser()
+ if b != []:
+ form.fields['BugzillaName'].initial = b.Bugzillaname
TmpDict['form'] = form
return render(request, 'registration/bugzillauser.html', TmpDict)
+
+def cluster_configs(request):
+ pagerequest = 'cluster'
+ TmpDict = default_TmpDict(pagerequest)
+ TmpDict['CM_tmp'] = ConfigsMetaData.objects.all
+ return render(request, 'pages/cluster/index.html', TmpDict)