1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuiadminfailurereason.py 62484 2016-07-22 18:35:33Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager WUI - Failure Reasons Web content generator.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2016 Oracle Corporation
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | """
|
---|
29 | __version__ = "$Revision: 62484 $"
|
---|
30 |
|
---|
31 |
|
---|
32 | # Validation Kit imports.
|
---|
33 | from testmanager.webui.wuibase import WuiException
|
---|
34 | from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiContentBase, WuiTmLink;
|
---|
35 | from testmanager.core.failurereason import FailureReasonData;
|
---|
36 | from testmanager.core.failurecategory import FailureCategoryLogic;
|
---|
37 | from testmanager.core.db import TMDatabaseConnection;
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 | class 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 |
|
---|
56 | class 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 |
|
---|
69 | class 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 len(aoFailureCategories) == 0:
|
---|
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 |
|
---|
121 | class WuiAdminFailureReasonList(WuiListContentBase):
|
---|
122 | """
|
---|
123 | WUI Admin Failure Reasons Content Generator.
|
---|
124 | """
|
---|
125 |
|
---|
126 | def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
|
---|
127 | WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
|
---|
128 | sTitle = 'Failure Reasons', sId = 'failureReasons',
|
---|
129 | fnDPrint = fnDPrint, oDisp = oDisp);
|
---|
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 | return [ oEntry.idFailureReason,
|
---|
143 | WuiFailureReasonCategoryLink(oEntry.idFailureCategory, sName = oEntry.oCategory.sShort, fBracketed = False),
|
---|
144 | oEntry.sShort,
|
---|
145 | oEntry.sFull,
|
---|
146 | oEntry.iTicket,
|
---|
147 | oEntry.asUrls,
|
---|
148 | [ WuiTmLink('Details', WuiAdmin.ksScriptName,
|
---|
149 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDetails,
|
---|
150 | FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
|
---|
151 | WuiTmLink('Modify', WuiAdmin.ksScriptName,
|
---|
152 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonEdit,
|
---|
153 | FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
|
---|
154 | WuiTmLink('Remove', WuiAdmin.ksScriptName,
|
---|
155 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDoRemove,
|
---|
156 | FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason },
|
---|
157 | sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)),
|
---|
158 | ] ]
|
---|