VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminbuildsource.py@ 78138

Last change on this file since 78138 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadminbuildsource.py 76553 2019-01-01 01:45:53Z vboxsync $
3
4"""
5Test Manager WUI - Build Sources.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2019 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 76553 $"
30
31
32# Validation Kit imports.
33from common import utils, webutils;
34from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink, WuiRawHtml;
35from testmanager.core import coreconsts;
36from testmanager.core.db import isDbTimestampInfinity;
37from testmanager.core.buildsource import BuildSourceData;
38
39
40class WuiAdminBuildSrc(WuiFormContentBase):
41 """
42 WUI Build Sources HTML content generator.
43 """
44
45 def __init__(self, oData, sMode, oDisp):
46 assert isinstance(oData, BuildSourceData);
47 if sMode == WuiFormContentBase.ksMode_Add:
48 sTitle = 'New Build Source';
49 elif sMode == WuiFormContentBase.ksMode_Edit:
50 sTitle = 'Edit Build Source - %s (#%s)' % (oData.sName, oData.idBuildSrc,);
51 else:
52 assert sMode == WuiFormContentBase.ksMode_Show;
53 sTitle = 'Build Source - %s (#%s)' % (oData.sName, oData.idBuildSrc,);
54 WuiFormContentBase.__init__(self, oData, sMode, 'BuildSrc', oDisp, sTitle);
55
56 def _populateForm(self, oForm, oData):
57 oForm.addIntRO (BuildSourceData.ksParam_idBuildSrc, oData.idBuildSrc, 'Build Source item ID')
58 oForm.addTimestampRO(BuildSourceData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
59 oForm.addTimestampRO(BuildSourceData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
60 oForm.addIntRO (BuildSourceData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
61 oForm.addText (BuildSourceData.ksParam_sName, oData.sName, 'Name')
62 oForm.addText (BuildSourceData.ksParam_sDescription, oData.sDescription, 'Description')
63 oForm.addText (BuildSourceData.ksParam_sProduct, oData.sProduct, 'Product')
64 oForm.addText (BuildSourceData.ksParam_sBranch, oData.sBranch, 'Branch')
65 asTypes = self.getListOfItems(coreconsts.g_kasBuildTypesAll, oData.asTypes);
66 oForm.addListOfTypes(BuildSourceData.ksParam_asTypes, asTypes, 'Build types')
67 asOsArches = self.getListOfItems(coreconsts.g_kasOsDotCpusAll, oData.asOsArches);
68 oForm.addListOfOsArches(BuildSourceData.ksParam_asOsArches, asOsArches, 'Target architectures')
69 oForm.addInt (BuildSourceData.ksParam_iFirstRevision, oData.iFirstRevision, 'Starting from revision')
70 oForm.addInt (BuildSourceData.ksParam_iLastRevision, oData.iLastRevision, 'Ending by revision')
71 oForm.addLong (BuildSourceData.ksParam_cSecMaxAge,
72 utils.formatIntervalSeconds2(oData.cSecMaxAge) if oData.cSecMaxAge not in [-1, '', None] else '',
73 'Max age in seconds');
74 oForm.addSubmit();
75 return True;
76
77class WuiAdminBuildSrcList(WuiListContentBase):
78 """
79 WUI Build Source content generator.
80 """
81
82 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
83 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
84 sTitle = 'Registered Build Sources', sId = 'build sources',
85 fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
86 self._asColumnHeaders = ['ID', 'Name', 'Description', 'Product',
87 'Branch', 'Build Types', 'OS/ARCH', 'First Revision', 'Last Revision', 'Max Age',
88 'Actions' ];
89 self._asColumnAttribs = ['align="center"', 'align="center"', 'align="center"', 'align="center"', 'align="center"',
90 'align="left"', 'align="left"', 'align="center"', 'align="center"', 'align="center"',
91 'align="center"' ];
92
93 def _getSubList(self, aList):
94 """
95 Convert pythonic list into HTML list
96 """
97 if aList not in (None, []):
98 sHtml = ' <ul class="tmshowall">\n'
99 for sTmp in aList:
100 sHtml += ' <li class="tmshowall">%s</a></li>\n' % (webutils.escapeElem(sTmp),);
101 sHtml += ' </ul>\n';
102 else:
103 sHtml = '<ul class="tmshowall"><li class="tmshowall">Any</li></ul>\n';
104
105 return WuiRawHtml(sHtml);
106
107 def _formatListEntry(self, iEntry):
108 """
109 Format *show all* table entry
110 """
111
112 from testmanager.webui.wuiadmin import WuiAdmin
113 oEntry = self._aoEntries[iEntry]
114
115 aoActions = [
116 WuiTmLink('Details', WuiAdmin.ksScriptName,
117 { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildSrcDetails,
118 BuildSourceData.ksParam_idBuildSrc: oEntry.idBuildSrc,
119 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }),
120 ];
121 if self._oDisp is None or not self._oDisp.isReadOnlyUser():
122 aoActions += [
123 WuiTmLink('Clone', WuiAdmin.ksScriptName,
124 { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildSrcClone,
125 BuildSourceData.ksParam_idBuildSrc: oEntry.idBuildSrc,
126 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }),
127 ];
128 if isDbTimestampInfinity(oEntry.tsExpire):
129 aoActions += [
130 WuiTmLink('Modify', WuiAdmin.ksScriptName,
131 { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildSrcEdit,
132 BuildSourceData.ksParam_idBuildSrc: oEntry.idBuildSrc } ),
133 WuiTmLink('Remove', WuiAdmin.ksScriptName,
134 { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildSrcDoRemove,
135 BuildSourceData.ksParam_idBuildSrc: oEntry.idBuildSrc },
136 sConfirm = 'Are you sure you want to remove build source #%d?' % (oEntry.idBuildSrc,) )
137 ];
138
139 return [ oEntry.idBuildSrc,
140 oEntry.sName,
141 oEntry.sDescription,
142 oEntry.sProduct,
143 oEntry.sBranch,
144 self._getSubList(oEntry.asTypes),
145 self._getSubList(oEntry.asOsArches),
146 oEntry.iFirstRevision,
147 oEntry.iLastRevision,
148 utils.formatIntervalSeconds2(oEntry.cSecMaxAge) if oEntry.cSecMaxAge is not None else None,
149 aoActions,
150 ]
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette