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
|
# -*- coding: utf-8 -*-
# $Id: wuiadminfailurereason.py $
"""
Test Manager WUI - Failure Reasons Web content generator.
"""
__copyright__ = \
"""
Copyright (C) 2012-2019 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
you can redistribute it and/or modify it under the terms of the GNU
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
__version__ = "$Revision: 127855 $"
# Validation Kit imports.
from testmanager.webui.wuibase import WuiException
from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiContentBase, WuiTmLink;
from testmanager.core.failurereason import FailureReasonData;
from testmanager.core.failurecategory import FailureCategoryLogic;
from testmanager.core.db import TMDatabaseConnection;
class WuiFailureReasonDetailsLink(WuiTmLink):
""" Short link to a failure reason. """
def __init__(self, idFailureReason, sName = WuiContentBase.ksShortDetailsLink, sTitle = None, fBracketed = None):
if fBracketed is None:
fBracketed = len(sName) > 2;
from testmanager.webui.wuiadmin import WuiAdmin;
WuiTmLink.__init__(self, sName = sName,
sUrlBase = WuiAdmin.ksScriptName,
dParams = { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDetails,
FailureReasonData.ksParam_idFailureReason: idFailureReason, },
fBracketed = fBracketed);
self.idFailureReason = idFailureReason;
class WuiFailureReasonAddLink(WuiTmLink):
""" Link for adding a failure reason. """
def __init__(self, sName = WuiContentBase.ksShortAddLink, sTitle = None, fBracketed = None):
if fBracketed is None:
fBracketed = len(sName) > 2;
from testmanager.webui.wuiadmin import WuiAdmin;
WuiTmLink.__init__(self, sName = sName,
sUrlBase = WuiAdmin.ksScriptName,
dParams = { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonAdd, },
fBracketed = fBracketed);
class WuiAdminFailureReason(WuiFormContentBase):
"""
WUI Failure Reason HTML content generator.
"""
def __init__(self, oFailureReasonData, sMode, oDisp):
"""
Prepare & initialize parent
"""
sTitle = 'Failure Reason';
if sMode == WuiFormContentBase.ksMode_Add:
sTitle = 'Add' + sTitle;
elif sMode == WuiFormContentBase.ksMode_Edit:
sTitle = 'Edit' + sTitle;
else:
assert sMode == WuiFormContentBase.ksMode_Show;
WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle);
def _populateForm(self, oForm, oData):
"""
Construct an HTML form
"""
aoFailureCategories = FailureCategoryLogic(TMDatabaseConnection()).getFailureCategoriesForCombo()
if not aoFailureCategories:
from testmanager.webui.wuiadmin import WuiAdmin
sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \
(WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryAdd)
raise WuiException(sExceptionMsg)
oForm.addIntRO (FailureReasonData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason ID')
oForm.addTimestampRO (FailureReasonData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
oForm.addTimestampRO (FailureReasonData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
oForm.addIntRO (FailureReasonData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
oForm.addComboBox (FailureReasonData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category',
aoFailureCategories)
oForm.addText (FailureReasonData.ksParam_sShort, oData.sShort, 'Short Description')
oForm.addText (FailureReasonData.ksParam_sFull, oData.sFull, 'Full Description')
oForm.addInt (FailureReasonData.ksParam_iTicket, oData.iTicket, 'Ticket Number')
oForm.addMultilineText(FailureReasonData.ksParam_asUrls, oData.asUrls, 'Other URLs to reports '
'or discussions of the '
'observed symptoms')
oForm.addSubmit()
return True
class WuiAdminFailureReasonList(WuiListContentBase):
"""
WUI Admin Failure Reasons Content Generator.
"""
def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
sTitle = 'Failure Reasons', sId = 'failureReasons',
fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
self._asColumnHeaders = ['ID', 'Category', 'Short Description',
'Full Description', 'Ticket', 'External References', 'Actions' ]
self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',
'align="center"',' align="center"', 'align="center"', 'align="center"']
def _formatListEntry(self, iEntry):
from testmanager.webui.wuiadmin import WuiAdmin
from testmanager.webui.wuiadminfailurecategory import WuiFailureReasonCategoryLink;
oEntry = self._aoEntries[iEntry]
aoActions = [
WuiTmLink('Details', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDetails,
FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
];
if self._oDisp is None or not self._oDisp.isReadOnlyUser():
aoActions += [
WuiTmLink('Modify', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonEdit,
FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
WuiTmLink('Remove', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDoRemove,
FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason },
sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)),
];
return [ oEntry.idFailureReason,
WuiFailureReasonCategoryLink(oEntry.idFailureCategory, sName = oEntry.oCategory.sShort, fBracketed = False),
oEntry.sShort,
oEntry.sFull,
oEntry.iTicket,
oEntry.asUrls,
aoActions,
]
|