1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuiadminfailurecategory.py 76553 2019-01-01 01:45:53Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager WUI - Failure Categories Web content generator.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2019 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: 76553 $"
|
---|
30 |
|
---|
31 |
|
---|
32 | # Validation Kit imports.
|
---|
33 | from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiContentBase, WuiListContentBase, WuiTmLink;
|
---|
34 | from testmanager.webui.wuiadminfailurereason import WuiAdminFailureReasonList;
|
---|
35 | from testmanager.core.failurecategory import FailureCategoryData;
|
---|
36 | from testmanager.core.failurereason import FailureReasonLogic;
|
---|
37 |
|
---|
38 |
|
---|
39 | class WuiFailureReasonCategoryLink(WuiTmLink):
|
---|
40 | """ Link to a failure category. """
|
---|
41 | def __init__(self, idFailureCategory, sName = WuiContentBase.ksShortDetailsLink, sTitle = None, fBracketed = None):
|
---|
42 | if fBracketed is None:
|
---|
43 | fBracketed = len(sName) > 2;
|
---|
44 | from testmanager.webui.wuiadmin import WuiAdmin;
|
---|
45 | WuiTmLink.__init__(self, sName = sName,
|
---|
46 | sUrlBase = WuiAdmin.ksScriptName,
|
---|
47 | dParams = { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryDetails,
|
---|
48 | FailureCategoryData.ksParam_idFailureCategory: idFailureCategory, },
|
---|
49 | fBracketed = fBracketed,
|
---|
50 | sTitle = sTitle);
|
---|
51 | self.idFailureCategory = idFailureCategory;
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 | class WuiFailureCategory(WuiFormContentBase):
|
---|
56 | """
|
---|
57 | WUI Failure Category HTML content generator.
|
---|
58 | """
|
---|
59 |
|
---|
60 | def __init__(self, oData, sMode, oDisp):
|
---|
61 | """
|
---|
62 | Prepare & initialize parent
|
---|
63 | """
|
---|
64 |
|
---|
65 | sTitle = 'Failure Category';
|
---|
66 | if sMode == WuiFormContentBase.ksMode_Add:
|
---|
67 | sTitle = 'Add ' + sTitle;
|
---|
68 | elif sMode == WuiFormContentBase.ksMode_Edit:
|
---|
69 | sTitle = 'Edit ' + sTitle;
|
---|
70 | else:
|
---|
71 | assert sMode == WuiFormContentBase.ksMode_Show;
|
---|
72 |
|
---|
73 | WuiFormContentBase.__init__(self, oData, sMode, 'FailureCategory', oDisp, sTitle);
|
---|
74 |
|
---|
75 | def _populateForm(self, oForm, oData):
|
---|
76 | """
|
---|
77 | Construct an HTML form
|
---|
78 | """
|
---|
79 |
|
---|
80 | oForm.addIntRO (FailureCategoryData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category ID')
|
---|
81 | oForm.addTimestampRO(FailureCategoryData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
|
---|
82 | oForm.addTimestampRO(FailureCategoryData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
|
---|
83 | oForm.addIntRO (FailureCategoryData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
|
---|
84 | oForm.addText (FailureCategoryData.ksParam_sShort, oData.sShort, 'Short Description')
|
---|
85 | oForm.addText (FailureCategoryData.ksParam_sFull, oData.sFull, 'Full Description')
|
---|
86 |
|
---|
87 | oForm.addSubmit()
|
---|
88 |
|
---|
89 | return True;
|
---|
90 |
|
---|
91 | def _generatePostFormContent(self, oData):
|
---|
92 | """
|
---|
93 | Adds a table with the category members below the form.
|
---|
94 | """
|
---|
95 | if oData.idFailureCategory is not None and oData.idFailureCategory >= 0:
|
---|
96 | oLogic = FailureReasonLogic(self._oDisp.getDb());
|
---|
97 | tsNow = self._oDisp.getNow();
|
---|
98 | cMax = 4096;
|
---|
99 | aoEntries = oLogic.fetchForListingInCategory(0, cMax, tsNow, oData.idFailureCategory)
|
---|
100 | if aoEntries:
|
---|
101 | oList = WuiAdminFailureReasonList(aoEntries, 0, cMax, tsNow, fnDPrint = None, oDisp = self._oDisp);
|
---|
102 | return [ [ 'Members', oList.show(fShowNavigation = False)[1]], ];
|
---|
103 | return [];
|
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|
107 | class WuiFailureCategoryList(WuiListContentBase):
|
---|
108 | """
|
---|
109 | WUI Admin Failure Category Content Generator.
|
---|
110 | """
|
---|
111 |
|
---|
112 | def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
|
---|
113 | WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
|
---|
114 | sTitle = 'Failure Categories', sId = 'failureCategories',
|
---|
115 | fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
|
---|
116 |
|
---|
117 | self._asColumnHeaders = ['ID', 'Short Description', 'Full Description', 'Actions' ]
|
---|
118 | self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"', 'align="center"']
|
---|
119 |
|
---|
120 | def _formatListEntry(self, iEntry):
|
---|
121 | from testmanager.webui.wuiadmin import WuiAdmin
|
---|
122 | oEntry = self._aoEntries[iEntry]
|
---|
123 |
|
---|
124 | aoActions = [
|
---|
125 | WuiTmLink('Details', WuiAdmin.ksScriptName,
|
---|
126 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryDetails,
|
---|
127 | FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory }),
|
---|
128 | ];
|
---|
129 | if self._oDisp is None or not self._oDisp.isReadOnlyUser():
|
---|
130 | aoActions += [
|
---|
131 | WuiTmLink('Modify', WuiAdmin.ksScriptName,
|
---|
132 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryEdit,
|
---|
133 | FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory }),
|
---|
134 | WuiTmLink('Remove', WuiAdmin.ksScriptName,
|
---|
135 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryDoRemove,
|
---|
136 | FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory },
|
---|
137 | sConfirm = 'Do you really want to remove failure cateogry #%d?' % (oEntry.idFailureCategory,)),
|
---|
138 | ]
|
---|
139 |
|
---|
140 | return [ oEntry.idFailureCategory,
|
---|
141 | oEntry.sShort,
|
---|
142 | oEntry.sFull,
|
---|
143 | aoActions,
|
---|
144 | ];
|
---|
145 |
|
---|