1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuiadminfailurereason.py 52776 2014-09-17 14:51:43Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager WUI - Failure Reasons Web content generator.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2014 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: 52776 $"
|
---|
30 |
|
---|
31 |
|
---|
32 | # Validation Kit imports.
|
---|
33 | from testmanager.webui.wuibase import WuiException
|
---|
34 | from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
|
---|
35 | from testmanager.core.failurereason import FailureReasonData
|
---|
36 | from testmanager.core.failurecategory import FailureCategoryLogic
|
---|
37 | from testmanager.core.db import TMDatabaseConnection
|
---|
38 |
|
---|
39 |
|
---|
40 | class 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 |
|
---|
93 | class 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 | ] ]
|
---|