VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminfailurereason.py@ 78352

Last change on this file since 78352 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.7 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadminfailurereason.py 76553 2019-01-01 01:45:53Z vboxsync $
3
4"""
5Test Manager WUI - Failure Reasons Web content generator.
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 testmanager.webui.wuibase import WuiException
34from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiContentBase, WuiTmLink;
35from testmanager.core.failurereason import FailureReasonData;
36from testmanager.core.failurecategory import FailureCategoryLogic;
37from testmanager.core.db import TMDatabaseConnection;
38
39
40
41class WuiFailureReasonDetailsLink(WuiTmLink):
42 """ Short link to a failure reason. """
43 def __init__(self, idFailureReason, sName = WuiContentBase.ksShortDetailsLink, sTitle = None, fBracketed = None):
44 if fBracketed is None:
45 fBracketed = len(sName) > 2;
46 from testmanager.webui.wuiadmin import WuiAdmin;
47 WuiTmLink.__init__(self, sName = sName,
48 sUrlBase = WuiAdmin.ksScriptName,
49 dParams = { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDetails,
50 FailureReasonData.ksParam_idFailureReason: idFailureReason, },
51 fBracketed = fBracketed);
52 self.idFailureReason = idFailureReason;
53
54
55
56class WuiFailureReasonAddLink(WuiTmLink):
57 """ Link for adding a failure reason. """
58 def __init__(self, sName = WuiContentBase.ksShortAddLink, sTitle = None, fBracketed = None):
59 if fBracketed is None:
60 fBracketed = len(sName) > 2;
61 from testmanager.webui.wuiadmin import WuiAdmin;
62 WuiTmLink.__init__(self, sName = sName,
63 sUrlBase = WuiAdmin.ksScriptName,
64 dParams = { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonAdd, },
65 fBracketed = fBracketed);
66
67
68
69class WuiAdminFailureReason(WuiFormContentBase):
70 """
71 WUI Failure Reason HTML content generator.
72 """
73
74 def __init__(self, oFailureReasonData, sMode, oDisp):
75 """
76 Prepare & initialize parent
77 """
78
79 sTitle = 'Failure Reason';
80 if sMode == WuiFormContentBase.ksMode_Add:
81 sTitle = 'Add' + sTitle;
82 elif sMode == WuiFormContentBase.ksMode_Edit:
83 sTitle = 'Edit' + sTitle;
84 else:
85 assert sMode == WuiFormContentBase.ksMode_Show;
86
87 WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle);
88
89 def _populateForm(self, oForm, oData):
90 """
91 Construct an HTML form
92 """
93
94 aoFailureCategories = FailureCategoryLogic(TMDatabaseConnection()).getFailureCategoriesForCombo()
95 if not aoFailureCategories:
96 from testmanager.webui.wuiadmin import WuiAdmin
97 sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \
98 (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryAdd)
99
100 raise WuiException(sExceptionMsg)
101
102 oForm.addIntRO (FailureReasonData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason ID')
103 oForm.addTimestampRO (FailureReasonData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
104 oForm.addTimestampRO (FailureReasonData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
105 oForm.addIntRO (FailureReasonData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
106
107 oForm.addComboBox (FailureReasonData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category',
108 aoFailureCategories)
109
110 oForm.addText (FailureReasonData.ksParam_sShort, oData.sShort, 'Short Description')
111 oForm.addText (FailureReasonData.ksParam_sFull, oData.sFull, 'Full Description')
112 oForm.addInt (FailureReasonData.ksParam_iTicket, oData.iTicket, 'Ticket Number')
113 oForm.addMultilineText(FailureReasonData.ksParam_asUrls, oData.asUrls, 'Other URLs to reports '
114 'or discussions of the '
115 'observed symptoms')
116 oForm.addSubmit()
117
118 return True
119
120
121class WuiAdminFailureReasonList(WuiListContentBase):
122 """
123 WUI Admin Failure Reasons Content Generator.
124 """
125
126 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
127 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
128 sTitle = 'Failure Reasons', sId = 'failureReasons',
129 fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
130
131 self._asColumnHeaders = ['ID', 'Category', 'Short Description',
132 'Full Description', 'Ticket', 'External References', 'Actions' ]
133
134 self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',
135 'align="center"',' align="center"', 'align="center"', 'align="center"']
136
137 def _formatListEntry(self, iEntry):
138 from testmanager.webui.wuiadmin import WuiAdmin
139 from testmanager.webui.wuiadminfailurecategory import WuiFailureReasonCategoryLink;
140 oEntry = self._aoEntries[iEntry]
141
142 aoActions = [
143 WuiTmLink('Details', WuiAdmin.ksScriptName,
144 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDetails,
145 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
146 ];
147 if self._oDisp is None or not self._oDisp.isReadOnlyUser():
148 aoActions += [
149 WuiTmLink('Modify', WuiAdmin.ksScriptName,
150 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonEdit,
151 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
152 WuiTmLink('Remove', WuiAdmin.ksScriptName,
153 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDoRemove,
154 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason },
155 sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)),
156 ];
157
158 return [ oEntry.idFailureReason,
159 WuiFailureReasonCategoryLink(oEntry.idFailureCategory, sName = oEntry.oCategory.sShort, fBracketed = False),
160 oEntry.sShort,
161 oEntry.sFull,
162 oEntry.iTicket,
163 oEntry.asUrls,
164 aoActions,
165 ]
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