VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminfailurereason.py@ 55341

Last change on this file since 55341 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: 6.0 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadminfailurereason.py 52776 2014-09-17 14:51:43Z vboxsync $
3
4"""
5Test Manager WUI - Failure Reasons Web content generator.
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
32# Validation Kit imports.
33from testmanager.webui.wuibase import WuiException
34from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
35from testmanager.core.failurereason import FailureReasonData
36from testmanager.core.failurecategory import FailureCategoryLogic
37from testmanager.core.db import TMDatabaseConnection
38
39
40class WuiAdminFailureReason(WuiFormContentBase):
41 """
42 WUI Failure Reason HTML content generator.
43 """
44
45 def __init__(self, oFailureReasonData, sMode, oDisp):
46 """
47 Prepare & initialize parent
48 """
49
50 if sMode == WuiFormContentBase.ksMode_Add:
51 sTitle = 'Add Failure Reason'
52 sSubmitAction = oDisp.ksActionFailureReasonAdd
53 elif sMode == WuiFormContentBase.ksMode_Edit:
54 sTitle = 'Edit Failure Reason'
55 sSubmitAction = oDisp.ksActionFailureReasonEdit
56 else:
57 raise WuiException('Unknown parameter')
58
59 WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle,
60 sSubmitAction = sSubmitAction, fEditable = False); ## @todo non-standard action names.
61
62 def _populateForm(self, oForm, oData):
63 """
64 Construct an HTML form
65 """
66
67 aoFailureCategories = FailureCategoryLogic(TMDatabaseConnection()).getFailureCategoriesForCombo()
68 if len(aoFailureCategories) == 0:
69 from testmanager.webui.wuiadmin import WuiAdmin
70 sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \
71 (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryShowAdd)
72
73 raise WuiException(sExceptionMsg)
74
75 oForm.addIntRO (FailureReasonData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason ID')
76 oForm.addTimestampRO (FailureReasonData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
77 oForm.addTimestampRO (FailureReasonData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
78 oForm.addIntRO (FailureReasonData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
79
80 oForm.addComboBox (FailureReasonData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category',
81 aoFailureCategories)
82
83 oForm.addText (FailureReasonData.ksParam_sShort, oData.sShort, 'Short Description')
84 oForm.addText (FailureReasonData.ksParam_sFull, oData.sFull, 'Full Description')
85 oForm.addInt (FailureReasonData.ksParam_iTicket, oData.iTicket, 'Ticket Number')
86 oForm.addMultilineText(FailureReasonData.ksParam_asUrls, oData.asUrls, 'Other URLs to reports '
87 'or discussions of the '
88 'observed symptoms')
89 oForm.addSubmit()
90
91 return True
92
93class WuiAdminFailureReasonList(WuiListContentBase):
94 """
95 WUI Admin Failure Reasons Content Generator.
96 """
97
98 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
99 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
100 sTitle = 'Failure Reasons', sId = 'failureReasons',
101 fnDPrint = fnDPrint, oDisp = oDisp);
102
103 self._asColumnHeaders = ['ID', 'Category', 'Short Description',
104 'Full Description', 'Ticket', 'External References', 'Actions' ]
105
106 self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',
107 'align="center"',' align="center"', 'align="center"', 'align="center"']
108
109 def _formatListEntry(self, iEntry):
110 from testmanager.webui.wuiadmin import WuiAdmin
111 oEntry = self._aoEntries[iEntry]
112
113 return [ oEntry.idFailureReason,
114 oEntry.idFailureCategory,
115 oEntry.sShort,
116 oEntry.sFull,
117 oEntry.iTicket,
118 oEntry.asUrls,
119 [ WuiTmLink('Modify', WuiAdmin.ksScriptName,
120 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonShowEdit,
121 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
122 WuiTmLink('Remove', WuiAdmin.ksScriptName,
123 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDel,
124 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason },
125 sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)),
126 ] ]
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