1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuiadminuseraccount.py 69111 2017-10-17 14:26:02Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager WUI - User accounts.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2017 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: 69111 $"
|
---|
30 |
|
---|
31 | # Validation Kit imports.
|
---|
32 | from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink;
|
---|
33 | from testmanager.core.useraccount import UserAccountData
|
---|
34 |
|
---|
35 |
|
---|
36 | class WuiUserAccount(WuiFormContentBase):
|
---|
37 | """
|
---|
38 | WUI user account content generator.
|
---|
39 | """
|
---|
40 | def __init__(self, oData, sMode, oDisp):
|
---|
41 | if sMode == WuiFormContentBase.ksMode_Add:
|
---|
42 | sTitle = 'Add User Account';
|
---|
43 | elif sMode == WuiFormContentBase.ksMode_Edit:
|
---|
44 | sTitle = 'Modify User Account';
|
---|
45 | else:
|
---|
46 | assert sMode == WuiFormContentBase.ksMode_Show;
|
---|
47 | sTitle = 'User Account';
|
---|
48 | WuiFormContentBase.__init__(self, oData, sMode, 'User', oDisp, sTitle);
|
---|
49 |
|
---|
50 | def _populateForm(self, oForm, oData):
|
---|
51 | oForm.addIntRO( UserAccountData.ksParam_uid, oData.uid, 'User ID');
|
---|
52 | oForm.addTimestampRO(UserAccountData.ksParam_tsEffective, oData.tsEffective, 'Effective Date');
|
---|
53 | oForm.addTimestampRO(UserAccountData.ksParam_tsExpire, oData.tsExpire, 'Effective Date');
|
---|
54 | oForm.addIntRO( UserAccountData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID');
|
---|
55 | oForm.addText( UserAccountData.ksParam_sLoginName, oData.sLoginName, 'Login name')
|
---|
56 | oForm.addText( UserAccountData.ksParam_sUsername, oData.sUsername, 'User name')
|
---|
57 | oForm.addText( UserAccountData.ksParam_sFullName, oData.sFullName, 'Full name')
|
---|
58 | oForm.addText( UserAccountData.ksParam_sEmail, oData.sEmail, 'E-mail')
|
---|
59 | oForm.addCheckBox( UserAccountData.ksParam_fReadOnly, oData.fReadOnly, 'Only read access')
|
---|
60 | if self._sMode != WuiFormContentBase.ksMode_Show:
|
---|
61 | oForm.addSubmit('Add User' if self._sMode == WuiFormContentBase.ksMode_Add else 'Change User');
|
---|
62 | return True;
|
---|
63 |
|
---|
64 |
|
---|
65 | class WuiUserAccountList(WuiListContentBase):
|
---|
66 | """
|
---|
67 | WUI user account list content generator.
|
---|
68 | """
|
---|
69 |
|
---|
70 | def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
|
---|
71 | WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
|
---|
72 | sTitle = 'Registered User Accounts', sId = 'users', fnDPrint = fnDPrint, oDisp = oDisp,
|
---|
73 | aiSelectedSortColumns = aiSelectedSortColumns);
|
---|
74 | self._asColumnHeaders = ['User ID', 'Name', 'E-mail', 'Full Name', 'Login Name', 'Access', 'Actions'];
|
---|
75 | self._asColumnAttribs = ['align="center"', 'align="center"', 'align="center"', 'align="center"', 'align="center"',
|
---|
76 | 'align="center"', 'align="center"', ];
|
---|
77 |
|
---|
78 | def _formatListEntry(self, iEntry):
|
---|
79 | from testmanager.webui.wuiadmin import WuiAdmin;
|
---|
80 | oEntry = self._aoEntries[iEntry];
|
---|
81 | aoActions = [
|
---|
82 | WuiTmLink('Details', WuiAdmin.ksScriptName,
|
---|
83 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionUserDetails,
|
---|
84 | UserAccountData.ksParam_uid: oEntry.uid } ),
|
---|
85 | ];
|
---|
86 | if self._oDisp is None or not self._oDisp.isReadOnlyUser():
|
---|
87 | aoActions += [
|
---|
88 | WuiTmLink('Modify', WuiAdmin.ksScriptName,
|
---|
89 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionUserEdit,
|
---|
90 | UserAccountData.ksParam_uid: oEntry.uid } ),
|
---|
91 | WuiTmLink('Remove', WuiAdmin.ksScriptName,
|
---|
92 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionUserDelPost,
|
---|
93 | UserAccountData.ksParam_uid: oEntry.uid },
|
---|
94 | sConfirm = 'Are you sure you want to remove user #%d?' % (oEntry.uid,)),
|
---|
95 | ];
|
---|
96 |
|
---|
97 | return [ oEntry.uid, oEntry.sUsername, oEntry.sEmail, oEntry.sFullName, oEntry.sLoginName,
|
---|
98 | 'read only' if oEntry.fReadOnly else 'full',
|
---|
99 | aoActions, ];
|
---|
100 |
|
---|