VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminfailurecategory.py@ 65661

Last change on this file since 65661 was 65350, checked in by vboxsync, 8 years ago

TestManager/webui: Implemented simple column sorting direction toggle during the meeting. (Still testboxes only.)

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

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