VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminglobalrsrc.py

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadminglobalrsrc.py 106061 2024-09-16 14:03:52Z vboxsync $
3
4"""
5Test Manager WUI - Global resources.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2024 Oracle and/or its affiliates.
11
12This file is part of VirtualBox base platform packages, as
13available from https://www.virtualbox.org.
14
15This program is free software; you can redistribute it and/or
16modify it under the terms of the GNU General Public License
17as published by the Free Software Foundation, in version 3 of the
18License.
19
20This program is distributed in the hope that it will be useful, but
21WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23General Public License for more details.
24
25You should have received a copy of the GNU General Public License
26along with this program; if not, see <https://www.gnu.org/licenses>.
27
28The contents of this file may alternatively be used under the terms
29of the Common Development and Distribution License Version 1.0
30(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31in the VirtualBox distribution, in which case the provisions of the
32CDDL are applicable instead of those of the GPL.
33
34You may elect to license modified versions of this file under the
35terms and conditions of either the GPL or the CDDL or both.
36
37SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38"""
39__version__ = "$Revision: 106061 $"
40
41# Validation Kit imports.
42from testmanager.webui.wuibase import WuiException
43from testmanager.webui.wuicontentbase import WuiContentBase
44from testmanager.webui.wuihlpform import WuiHlpForm
45from testmanager.core.globalresource import GlobalResourceData
46from testmanager.webui.wuicontentbase import WuiListContentBase, WuiTmLink
47
48
49class WuiGlobalResource(WuiContentBase):
50 """
51 WUI global resources content generator.
52 """
53
54 def __init__(self, oData, fnDPrint = None):
55 """
56 Do necessary initializations
57 """
58 WuiContentBase.__init__(self, fnDPrint)
59 self._oData = oData
60
61 def showAddModifyPage(self, sAction, dErrors = None):
62 """
63 Render add global resource HTML form.
64 """
65 from testmanager.webui.wuiadmin import WuiAdmin
66
67 sFormActionUrl = '%s?%s=%s' % (WuiAdmin.ksScriptName,
68 WuiAdmin.ksParamAction, sAction)
69 if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
70 sTitle = 'Add Global Resource'
71 elif sAction == WuiAdmin.ksActionGlobalRsrcEdit:
72 sTitle = 'Modify Global Resource'
73 sFormActionUrl += '&%s=%s' % (GlobalResourceData.ksParam_idGlobalRsrc, self._oData.idGlobalRsrc)
74 else:
75 raise WuiException('Invalid paraemter "%s"' % (sAction,))
76
77 oForm = WuiHlpForm('globalresourceform',
78 sFormActionUrl,
79 dErrors if dErrors is not None else {})
80
81 if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
82 oForm.addIntRO (GlobalResourceData.ksParam_idGlobalRsrc, self._oData.idGlobalRsrc, 'Global Resource ID')
83 oForm.addTimestampRO(GlobalResourceData.ksParam_tsEffective, self._oData.tsEffective, 'Last changed')
84 oForm.addTimestampRO(GlobalResourceData.ksParam_tsExpire, self._oData.tsExpire, 'Expires (excl)')
85 oForm.addIntRO (GlobalResourceData.ksParam_uidAuthor, self._oData.uidAuthor, 'Changed by UID')
86 oForm.addText (GlobalResourceData.ksParam_sName, self._oData.sName, 'Name')
87 oForm.addText (GlobalResourceData.ksParam_sDescription, self._oData.sDescription, 'Description')
88 oForm.addCheckBox (GlobalResourceData.ksParam_fEnabled, self._oData.fEnabled, 'Enabled')
89
90 oForm.addSubmit('Submit')
91
92 return (sTitle, oForm.finalize())
93
94
95class WuiGlobalResourceList(WuiListContentBase):
96 """
97 WUI Content Generator.
98 """
99
100 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
101 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
102 sTitle = 'Global Resources', sId = 'globalResources',
103 fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
104
105 self._asColumnHeaders = ['ID', 'Name', 'Description', 'Enabled', 'Actions' ]
106 self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',
107 'align="center"', 'align="center"']
108
109 def _formatListEntry(self, iEntry):
110 from testmanager.webui.wuiadmin import WuiAdmin
111 oEntry = self._aoEntries[iEntry]
112
113 aoActions = [ ];
114 if self._oDisp is None or not self._oDisp.isReadOnlyUser():
115 aoActions += [
116 WuiTmLink('Modify', WuiAdmin.ksScriptName,
117 { WuiAdmin.ksParamAction: WuiAdmin.ksActionGlobalRsrcShowEdit,
118 GlobalResourceData.ksParam_idGlobalRsrc: oEntry.idGlobalRsrc }),
119 WuiTmLink('Remove', WuiAdmin.ksScriptName,
120 { WuiAdmin.ksParamAction: WuiAdmin.ksActionGlobalRsrcDel,
121 GlobalResourceData.ksParam_idGlobalRsrc: oEntry.idGlobalRsrc },
122 sConfirm = 'Are you sure you want to remove global resource #%d?' % (oEntry.idGlobalRsrc,)),
123 ];
124
125 return [ oEntry.idGlobalRsrc,
126 oEntry.sName,
127 oEntry.sDescription,
128 oEntry.fEnabled,
129 aoActions, ];
130
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