Ejemplo n.º 1
0
    def _actionGlobalRsrcAddEdit(self, sAction):
        """Add or modify Global Resource record"""

        oData = GlobalResourceData()
        oData.initFromParams(self, fStrict=True)

        self._checkForUnknownParameters()

        if self._oSrvGlue.getMethod() != 'POST':
            raise WuiException('Expected "POST" request, got "%s"' %
                               (self._oSrvGlue.getMethod(), ))

        oGlobalResourceLogic = GlobalResourceLogic(self._oDb)
        dErrors = oData.validateAndConvert(self._oDb)
        if len(dErrors) == 0:
            if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
                oGlobalResourceLogic.addGlobalResource(self._oCurUser.uid,
                                                       oData)
            elif sAction == WuiAdmin.ksActionGlobalRsrcEdit:
                idGlobalRsrc = self.getStringParam(
                    GlobalResourceData.ksParam_idGlobalRsrc)
                oGlobalResourceLogic.editGlobalResource(
                    self._oCurUser.uid, idGlobalRsrc, oData)
            else:
                raise WuiException('Invalid parameter.')
            self._sPageTitle = None
            self._sPageBody = None
            self._sRedirectTo = self._sActionUrlBase + self.ksActionGlobalRsrcShowAll
        else:
            oContent = WuiGlobalResource(oData)
            (self._sPageTitle,
             self._sPageBody) = oContent.showAddModifyPage(sAction,
                                                           dErrors=dErrors)

        return True
Ejemplo n.º 2
0
    def _actionTestBoxListPost(self):
        """Actions on a list of testboxes."""

        # Parameters.
        aidTestBoxes = self.getListOfIntParams(TestBoxData.ksParam_idTestBox, iMin = 1, aiDefaults = []);
        sListAction  = self.getStringParam(self.ksParamListAction);
        if sListAction in [asDesc[0] for asDesc in WuiTestBoxList.kasTestBoxActionDescs]:
            idAction = None;
        else:
            asActionPrefixes = [ 'setgroup-', ];
            i = 0;
            while i < len(asActionPrefixes) and not sListAction.startswith(asActionPrefixes[i]):
                i += 1;
            if i >= len(asActionPrefixes):
                raise WuiException('Parameter "%s" has an invalid value: "%s"' % (self.ksParamListAction, sListAction,));
            idAction = sListAction[len(asActionPrefixes[i]):];
            if not idAction.isdigit():
                raise WuiException('Parameter "%s" has an invalid value: "%s"' % (self.ksParamListAction, sListAction,));
            idAction = int(idAction);
            sListAction = sListAction[:len(asActionPrefixes[i]) - 1];
        self._checkForUnknownParameters();


        # Take action.
        if sListAction is 'none':
            pass;
        else:
            oLogic = TestBoxLogic(self._oDb);
            aoTestBoxes = []
            for idTestBox in aidTestBoxes:
                aoTestBoxes.append(TestBoxData().initFromDbWithId(self._oDb, idTestBox));

            if sListAction in [ 'enable', 'disable' ]:
                fEnable = sListAction == 'enable';
                for oTestBox in aoTestBoxes:
                    if oTestBox.fEnabled != fEnable:
                        oTestBox.fEnabled = fEnable;
                        oLogic.editEntry(oTestBox, self._oCurUser.uid, fCommit = False);
            elif sListAction == 'setgroup':
                for oTestBox in aoTestBoxes:
                    if oTestBox.idSchedGroup != idAction:
                        oTestBox.idSchedGroup = idAction;
                        oLogic.editEntry(oTestBox, self._oCurUser.uid, fCommit = False);
            else:
                for oTestBox in aoTestBoxes:
                    if oTestBox.enmPendingCmd != sListAction:
                        oTestBox.enmPendingCmd = sListAction;
                        oLogic.editEntry(oTestBox, self._oCurUser.uid, fCommit = False);
            self._oDb.commit();

        # Re-display the list.
        self._sPageTitle  = None;
        self._sPageBody   = None;
        self._sRedirectTo = self._sActionUrlBase + self.ksActionTestBoxList;
        return True;
Ejemplo n.º 3
0
    def _populateForm(self, oForm, oData):
        """
        Construct an HTML form
        """

        aoFailureCategories = FailureCategoryLogic(TMDatabaseConnection()).getFailureCategoriesForCombo()
        if len(aoFailureCategories) == 0:
            from testmanager.webui.wuiadmin import WuiAdmin
            sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \
                (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryShowAdd)

            raise WuiException(sExceptionMsg)

        oForm.addIntRO        (FailureReasonData.ksParam_idFailureReason,    oData.idFailureReason,    'Failure Reason ID')
        oForm.addTimestampRO  (FailureReasonData.ksParam_tsEffective,        oData.tsEffective,        'Last changed')
        oForm.addTimestampRO  (FailureReasonData.ksParam_tsExpire,           oData.tsExpire,           'Expires (excl)')
        oForm.addIntRO        (FailureReasonData.ksParam_uidAuthor,          oData.uidAuthor,          'Changed by UID')

        oForm.addComboBox     (FailureReasonData.ksParam_idFailureCategory,  oData.idFailureCategory,  'Failure Category',
                               aoFailureCategories)

        oForm.addText         (FailureReasonData.ksParam_sShort,             oData.sShort,             'Short Description')
        oForm.addText         (FailureReasonData.ksParam_sFull,              oData.sFull,              'Full Description')
        oForm.addInt          (FailureReasonData.ksParam_iTicket,            oData.iTicket,            'Ticket Number')
        oForm.addMultilineText(FailureReasonData.ksParam_asUrls,             oData.asUrls,             'Other URLs to reports '
                                                                                                       'or discussions of the '
                                                                                                       'observed symptoms')
        oForm.addSubmit()

        return True
    def _populateForm(self, oForm, oData):
        """
        Construct an HTML form
        """

        aoFailureReasons = FailureReasonLogic(self._oDisp.getDb()).fetchForCombo()
        if not aoFailureReasons:
            from testmanager.webui.wuiadmin import WuiAdmin
            raise WuiException('Please <a href="%s?%s=%s">add</a> some Failure Reasons first.'
                               % (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureReasonAdd));

        asTypes    = self.getListOfItems(self.asTypes,    oData.asTypes)
        asOsArches = self.getListOfItems(self.asOsArches, oData.asOsArches)

        oForm.addIntRO      (BuildBlacklistData.ksParam_idBlacklisting,  oData.idBlacklisting,  'Blacklist item ID')
        oForm.addTimestampRO(BuildBlacklistData.ksParam_tsEffective,     oData.tsEffective,     'Last changed')
        oForm.addTimestampRO(BuildBlacklistData.ksParam_tsExpire,        oData.tsExpire,        'Expires (excl)')
        oForm.addIntRO      (BuildBlacklistData.ksParam_uidAuthor,       oData.uidAuthor,        'Changed by UID')

        oForm.addComboBox   (BuildBlacklistData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason',
                             aoFailureReasons)

        oForm.addText       (BuildBlacklistData.ksParam_sProduct,        oData.sProduct,        'Product')
        oForm.addText       (BuildBlacklistData.ksParam_sBranch,         oData.sBranch,         'Branch')
        oForm.addListOfTypes(BuildBlacklistData.ksParam_asTypes,         asTypes,               'Build types')
        oForm.addListOfOsArches(BuildBlacklistData.ksParam_asOsArches,   asOsArches,            'Target architectures')
        oForm.addInt        (BuildBlacklistData.ksParam_iFirstRevision,  oData.iFirstRevision,  'First revision')
        oForm.addInt        (BuildBlacklistData.ksParam_iLastRevision,   oData.iLastRevision,   'Last revision (incl)')

        oForm.addSubmit();

        return True;
Ejemplo n.º 5
0
    def showAddModifyPage(self, sAction, dErrors = None):
        """
        Render add global resource HTML form.
        """
        from testmanager.webui.wuiadmin import WuiAdmin

        sFormActionUrl = '%s?%s=%s' % (WuiAdmin.ksScriptName,
                                       WuiAdmin.ksParamAction, sAction)
        if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
            sTitle = 'Add Global Resource'
        elif sAction == WuiAdmin.ksActionGlobalRsrcEdit:
            sTitle = 'Modify Global Resource'
            sFormActionUrl += '&%s=%s' % (GlobalResourceData.ksParam_idGlobalRsrc, self._oData.idGlobalRsrc)
        else:
            raise WuiException('Invalid paraemter "%s"' % (sAction,))

        oForm = WuiHlpForm('globalresourceform',
                           sFormActionUrl,
                           dErrors if dErrors is not None else dict())

        if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
            oForm.addIntRO  (GlobalResourceData.ksParam_idGlobalRsrc,    self._oData.idGlobalRsrc,   'Global Resource ID')
        oForm.addTimestampRO(GlobalResourceData.ksParam_tsEffective,     self._oData.tsEffective,    'Last changed')
        oForm.addTimestampRO(GlobalResourceData.ksParam_tsExpire,        self._oData.tsExpire,       'Expires (excl)')
        oForm.addIntRO      (GlobalResourceData.ksParam_uidAuthor,       self._oData.uidAuthor,      'Changed by UID')
        oForm.addText       (GlobalResourceData.ksParam_sName,           self._oData.sName,          'Name')
        oForm.addText       (GlobalResourceData.ksParam_sDescription,    self._oData.sDescription,   'Description')
        oForm.addCheckBox   (GlobalResourceData.ksParam_fEnabled,        self._oData.fEnabled,       'Enabled')

        oForm.addSubmit('Submit')

        return (sTitle, oForm.finalize())
Ejemplo n.º 6
0
    def __init__(self, oFailureReasonData, sMode, oDisp):
        """
        Prepare & initialize parent
        """

        if sMode == WuiFormContentBase.ksMode_Add:
            sTitle = 'Add Failure Reason'
            sSubmitAction = oDisp.ksActionFailureReasonAdd
        elif sMode == WuiFormContentBase.ksMode_Edit:
            sTitle = 'Edit Failure Reason'
            sSubmitAction = oDisp.ksActionFailureReasonEdit
        else:
            raise WuiException('Unknown parameter')

        WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle,
                                    sSubmitAction = sSubmitAction, fEditable = False); ## @todo non-standard action names.
Ejemplo n.º 7
0
    def __init__(self, oFailureCategoryData, sMode, oDisp):
        """
        Prepare & initialize parent
        """

        if sMode == WuiFormContentBase.ksMode_Add:
            sTitle = 'Add Failure Category'
            sSubmitAction = oDisp.ksActionFailureCategoryAdd
        elif sMode == WuiFormContentBase.ksMode_Edit:
            sTitle = 'Edit Failure Category'
            sSubmitAction = oDisp.ksActionFailureCategoryEdit
        else:
            raise WuiException('Unknown parameter')

        WuiFormContentBase.__init__(self,
                                    oFailureCategoryData,
                                    sMode,
                                    'FailureCategory',
                                    oDisp,
                                    sTitle,
                                    sSubmitAction=sSubmitAction,
                                    fEditable=False)