VirtualBox

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

Last change on this file since 52776 was 52776, checked in by vboxsync, 10 years ago

fix OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadminglobalrsrc.py 52776 2014-09-17 14:51:43Z vboxsync $
3
4"""
5Test Manager WUI - Global resources.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2014 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: 52776 $"
30
31# Validation Kit imports.
32from testmanager.webui.wuibase import WuiException
33from testmanager.webui.wuicontentbase import WuiContentBase
34from testmanager.webui.wuihlpform import WuiHlpForm
35from testmanager.core.globalresource import GlobalResourceData
36from testmanager.webui.wuicontentbase import WuiListContentBase, WuiTmLink
37
38
39class WuiGlobalResource(WuiContentBase):
40 """
41 WUI global resources content generator.
42 """
43
44 def __init__(self, oData, fnDPrint = None):
45 """
46 Do necessary initializations
47 """
48 WuiContentBase.__init__(self, fnDPrint)
49 self._oData = oData
50
51 def showAddModifyPage(self, sAction, dErrors = None):
52 """
53 Render add global resource HTML form.
54 """
55 from testmanager.webui.wuiadmin import WuiAdmin
56
57 sFormActionUrl = '%s?%s=%s' % (WuiAdmin.ksScriptName,
58 WuiAdmin.ksParamAction, sAction)
59 if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
60 sTitle = 'Add Global Resource'
61 elif sAction == WuiAdmin.ksActionGlobalRsrcEdit:
62 sTitle = 'Modify Global Resource'
63 sFormActionUrl += '&%s=%s' % (GlobalResourceData.ksParam_idGlobalRsrc, self._oData.idGlobalRsrc)
64 else:
65 raise WuiException('Invalid paraemter "%s"' % (sAction,))
66
67 oForm = WuiHlpForm('globalresourceform',
68 sFormActionUrl,
69 dErrors if dErrors is not None else dict())
70
71 if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
72 oForm.addIntRO (GlobalResourceData.ksParam_idGlobalRsrc, self._oData.idGlobalRsrc, 'Global Resource ID')
73 oForm.addTimestampRO(GlobalResourceData.ksParam_tsEffective, self._oData.tsEffective, 'Last changed')
74 oForm.addTimestampRO(GlobalResourceData.ksParam_tsExpire, self._oData.tsExpire, 'Expires (excl)')
75 oForm.addIntRO (GlobalResourceData.ksParam_uidAuthor, self._oData.uidAuthor, 'Changed by UID')
76 oForm.addText (GlobalResourceData.ksParam_sName, self._oData.sName, 'Name')
77 oForm.addText (GlobalResourceData.ksParam_sDescription, self._oData.sDescription, 'Description')
78 oForm.addCheckBox (GlobalResourceData.ksParam_fEnabled, self._oData.fEnabled, 'Enabled')
79
80 oForm.addSubmit('Submit')
81
82 return (sTitle, oForm.finalize())
83
84
85class WuiGlobalResourceList(WuiListContentBase):
86 """
87 WUI Content Generator.
88 """
89
90 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
91 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
92 sTitle = 'Global Resources', sId = 'globalResources',
93 fnDPrint = fnDPrint, oDisp = oDisp)
94
95 self._asColumnHeaders = ['ID', 'Name', 'Description', 'Enabled', 'Actions' ]
96 self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',
97 'align="center"', 'align="center"']
98
99 def _formatListEntry(self, iEntry):
100 from testmanager.webui.wuiadmin import WuiAdmin
101 oEntry = self._aoEntries[iEntry]
102
103 return [ oEntry.idGlobalRsrc,
104 oEntry.sName,
105 oEntry.sDescription,
106 oEntry.fEnabled,
107 [ WuiTmLink('Modify', WuiAdmin.ksScriptName,
108 { WuiAdmin.ksParamAction: WuiAdmin.ksActionGlobalRsrcShowEdit,
109 GlobalResourceData.ksParam_idGlobalRsrc: oEntry.idGlobalRsrc }),
110 WuiTmLink('Remove', WuiAdmin.ksScriptName,
111 { WuiAdmin.ksParamAction: WuiAdmin.ksActionGlobalRsrcDel,
112 GlobalResourceData.ksParam_idGlobalRsrc: oEntry.idGlobalRsrc },
113 sConfirm = 'Are you sure you want to remove global resource #%d?' % (oEntry.idGlobalRsrc,)),
114 ] ]
115
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