summaryrefslogtreecommitdiff
blob: 29e561d543c6f73ebbe19ba8fab0f6fa8905ac06 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# 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, BuildLogsQa, \
	BuildJobsUse, Categories, CategoriesMetadata, Packages, PackagesMetadata, Ebuilds, \
	Repos, EbuildsKeywords, BuildLogsErrors, EbuildsRestrictions, EbuildsIuse, PackagesRepoman, \
	BuildLogsConfig, BuildLogsUse, BuildLogsQa
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
	TmpDict = default_TmpDict(pagerequest)
	TmpDict['EM'] = EbuildsMetadata.objects.filter(New = True).order_by('-Id')[:Lines]
	alist = []
	for BL in BuildLogs.objects.order_by('-TimeStamp')[:Lines]:
		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
		if BL.Fail:
			adict2['BE_tmp'] = BuildLogsErrors.objects.filter(BuildLogId = BL.BuildLogId)
		alist.append(adict2)
	TmpDict['BL'] = alist
	adict = {}
	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['QA_tmp'] = BuildLogsQa.objects.order_by('-Id')[:Lines/2]
	TmpDict['PR_tmp'] = PackagesRepoman.objects.order_by('-Id')[:Lines/2]
	return render(request, 'pages/' + pagerequest + '/index.html', TmpDict)

def categories(request):
	pagerequest = 'packages'
	TmpDict = default_TmpDict(pagerequest)
	alist = []
	for CM in CategoriesMetadata.objects.filter(CategoryId__Active = True).order_by('CategoryId__Category'):
		adict = {}
		adict['CategoryId'] = CM.CategoryId.CategoryId
		adict['Category'] = CM.CategoryId.Category
		adict['Descriptions'] = CM.Descriptions
		packages = []
		for P in Packages.objects.filter(Active = True).filter(CategoryId_id = CM.CategoryId.CategoryId).order_by('Package'):
			packages.append(P.Package + '\n')
		adict['Packages'] = packages
		alist.append(adict)
	TmpDict['CM_tmp'] = alist
	return render(request, 'pages/' + pagerequest + '/index.html', TmpDict)

def packages(request, category_id):
	pagerequest = 'packages'
	TmpDict = default_TmpDict(pagerequest)
	alist = []
	for PM in PackagesMetadata.objects.filter(PackageId__CategoryId_id = category_id).filter(PackageId__Active = True):
		adict = {}
		adict['PackageId'] = PM.PackageId.PackageId
		adict['Package'] = PM.PackageId.Package
		adict['Descriptions'] = PM.Descriptions
		adict['Commitlog'] =PM.Gitlog
		try:
			PackagesRepoman.objects.get(PackageId__PackageId = PM.PackageId.PackageId)
		except PackagesRepoman.DoesNotExist as e:
			adict['Repoman'] = False
		else:
			adict['Repoman'] = True
		ebuilds = []
		for E in Ebuilds.objects.filter(Active = True).filter(PackageId__Package = PM.PackageId.Package):
			ebuilds.append(E.Version + '::' +  E.PackageId.RepoId.Repo + '\n')
		adict['Ebuilds'] = ebuilds
		alist.append(adict)
	TmpDict['PM_tmp'] = alist
	TmpDict['C'] = get_object_or_404(Categories,  CategoryId = category_id)
	return render(request, 'pages/' + pagerequest + '/category/index.html', TmpDict)

def ebuilds(request, package_id):
	pagerequest = 'packages'
	TmpDict = default_TmpDict(pagerequest)
	P = get_object_or_404(PackagesMetadata, PackageId__PackageId = package_id)
	TmpDict['P'] = P
	TmpDict['EM_tmp'] = EbuildsMetadata.objects.filter(EbuildId__Active = True).filter(EbuildId__PackageId__Package = P.PackageId.Package)
	TmpDict['EK_tmp'] = EbuildsKeywords.objects.filter(EbuildId__Active = True).filter(EbuildId__PackageId__Package = P.PackageId.Package)
	try:
		PackagesRepoman.objects.get(PackageId__PackageId = package_id)
	except PackagesRepoman.DoesNotExist as e:
		TmpDict['PR'] = False
	else:
		TmpDict['PR'] = True
	return render(request, 'pages/' + pagerequest + '/ebuilds/index.html', TmpDict)

def ebuild(request, ebuild_id):
	pagerequest = 'packages'
	TmpDict = default_TmpDict(pagerequest)
	TmpDict['E'] = get_object_or_404(Ebuilds,  EbuildId = ebuild_id)
	TmpDict['EM_tmp'] = EbuildsMetadata.objects.filter(EbuildId__EbuildId = ebuild_id)
	TmpDict['EK_tmp'] = EbuildsKeywords.objects.filter(EbuildId__EbuildId = ebuild_id)
	TmpDict['BL_tmp'] = BuildLogs.objects.filter(EbuildId__EbuildId = ebuild_id)
	TmpDict['EU_tmp'] = EbuildsIuse.objects.filter(EbuildId__EbuildId = ebuild_id)
	TmpDict['ER_tmp'] = EbuildsRestrictions.objects.filter(EbuildId__EbuildId = ebuild_id)
	return render(request, 'pages/' + pagerequest + '/ebuilds/ebuild/index.html', TmpDict)

def new_main(request):
	pagerequest = 'new'
	Lines = 30
	TmpDict = default_TmpDict(pagerequest)
	TmpDict['EM'] = EbuildsMetadata.objects.filter(New = True).order_by('-Id')[:Lines]
	alist = []
	for BL in BuildLogs.objects.order_by('-TimeStamp')[:Lines]:
		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
		if BL.Fail:
			adict2['BE_tmp'] = BuildLogsErrors.objects.filter(BuildLogId = BL.BuildLogId)
		alist.append(adict2)
	TmpDict['BL'] = alist
	adict = {}
	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['Status'] = BJ.Status
		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['QA_tmp'] = BuildLogsQa.objects.order_by('-Id')[:Lines/2] 
	TmpDict['PR_tmp'] = PackagesRepoman.objects.order_by('-Id')[:Lines/2]
	return render(request, 'pages/' + pagerequest + '/index.html', TmpDict)

def new_repomanqa(request):
	pagerequest = 'new'
	Lines = 30
	TmpDict = default_TmpDict(pagerequest)
	TmpDict['QA_tmp'] = BuildLogsQa.objects.order_by('-Id')[:Lines/2] 
	TmpDict['PR_tmp'] = PackagesRepoman.objects.order_by('-Id')[:Lines/2]
	return render(request, 'pages/' + pagerequest + '/repomanqa/index.html', TmpDict)

def new_logs(request):
	pagerequest = 'new'
	Lines = 30
	TmpDict = default_TmpDict(pagerequest)
	alist = []
	for BL in BuildLogs.objects.order_by('-TimeStamp')[:Lines]:
		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
		if BL.Fail:
			adict2['BE_tmp'] = BuildLogsErrors.objects.filter(BuildLogId = BL.BuildLogId)
		try:
			PackagesRepomanInfo = PackagesRepoman.objects.get(PackageId__PackageId = BL.EbuildId.PackageId.PackageId)
		except PackagesRepoman.DoesNotExist as e:
			adict2['PR'] = False
		else:
			adict2['PR'] = PackagesRepomanInfo.RepomanText
		alist.append(adict2)
	TmpDict['BL_tmp'] = alist
	return render(request, 'pages/' + pagerequest + '/logs/index.html', TmpDict)

def new_logs_build(request, buildlog_id):
	pagerequest = 'new'
	TmpDict = default_TmpDict(pagerequest)
	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)
	BLI = {}
	BLI['BuildLogId'] = buildlog_id
	BLI['EbuildId'] = B.EbuildId.EbuildId
	BLI['C'] = B.EbuildId.PackageId.CategoryId.Category
	BLI['P'] = B.EbuildId.PackageId.Package
	BLI['V'] = B.EbuildId.Version
	BLI['R'] = B.EbuildId.PackageId.RepoId.Repo
	BLI['EC'] = EM.Commit
	BLI['PD'] = EM.Descriptions
	BLI['PC'] = PM.Gitlog
	BLI['Fail'] = B.Fail
	if B.Fail:
		BLI['BE_tmp'] = BuildLogsErrors.objects.filter(BuildLogId = buildlog_id)
	BLI['Summery_text'] = B.SummeryText
	if B.BugId == "0":
		BLI['BugId'] = False
	else:
		BLI['BugId'] = B.BugId
	BC = BuildLogsConfig.objects.get(BuildLogId = buildlog_id)
	#CEO_tmp = ConfigsEmergeOptions.objects.filter(ConfigId = BC.ConfigId.ConfigId)
	BU_tmp = BuildLogsUse.objects.filter(BuildLogId = BC.BuildLogId)
	config_eoption = []
	BLI['configid'] = BC.ConfigId.ConfigId
	BLI['hostname'] = BC.ConfigId.HostName
	BLI['config'] = BC.ConfigId.SetupId.Setup
	BLI['profile'] = BC.ConfigId.SetupId.Profile
	BLI['logid'] = BC.LogId
	BLI['logname'] = BC.LogName[1:]
	BLI['emerge_info_text'] = BC.EInfoId.EmergeInfoText
	#for CEO in CEO_tmp:
	#	config_eoption.append(CEO.EmergeOptionId.EOption)
	#BLI['emerge_option'] = config_eoption
	if not BU_tmp == []:
		use_enable = []
		use_disable = []
		for BU in BU_tmp:
			if BU.Status:
				use_enable.append(BU.UseId.Flag)
			else:
				use_disable.append(BU.UseId.Flag)
		if not use_enable == []:
			BLI['use_enable'] = use_enable
		if not use_disable == []:
			BLI['use_disable'] = use_disable
	try: 
		BRQ = BuildLogsQa.objects.get(BuildLogId = B.BuildLogId)
		BLI['RepomanQA'] = BRQ.SummeryText
	except BuildLogsQa.DoesNotExist as e:
			BLI['RepomanQA'] = False
	print(BLI)
	TmpDict['BLI'] = BLI
	return render(request, 'pages/' + pagerequest + '/logs/build/index.html', TmpDict)