Пример #1
0
    def _generateMainReason(self, oTestResultTree, oTestSet):
        """
        Generates the form for displaying and updating the main failure reason.

        oTestResultTree is an instance TestResultDataEx.
        oTestSet is an instance of TestSetData.

        """
        _ = oTestSet;
        sHtml = ' ';

        if oTestResultTree.isFailure() or oTestResultTree.cErrors > 0:
            sHtml += '   <h2>Failure Reason:</h2>\n';
            oData = oTestResultTree.oReason;

            # We need the failure reasons for the combobox.
            aoFailureReasons = FailureReasonLogic(self._oDisp.getDb()).fetchForCombo('Test Sheriff, you figure out why!');
            assert aoFailureReasons;

            # For now we'll use the standard form helper.
            sFormActionUrl = '%s?%s=%s' % ( self._oDisp.ksScriptName, self._oDisp.ksParamAction,
                                            WuiMain.ksActionTestResultFailureAddPost if oData is None else
                                            WuiMain.ksActionTestResultFailureEditPost )
            fReadOnly = not self._oDisp or self._oDisp.isReadOnlyUser();
            oForm = WuiHlpForm('failure-reason', sFormActionUrl,
                               sOnSubmit = WuiHlpForm.ksOnSubmit_AddReturnToFieldWithCurrentUrl, fReadOnly = fReadOnly);
            oForm.addTextHidden(TestResultFailureData.ksParam_idTestResult, oTestResultTree.idTestResult);
            oForm.addTextHidden(TestResultFailureData.ksParam_idTestSet, oTestSet.idTestSet);
            if oData is not None:
                oForm.addComboBox(TestResultFailureData.ksParam_idFailureReason, oData.idFailureReason, 'Reason',
                                  aoFailureReasons,
                                  sPostHtml = u' ' + WuiFailureReasonDetailsLink(oData.idFailureReason).toHtml()
                                            + (u' ' + WuiFailureReasonAddLink('New', fBracketed = False).toHtml()
                                               if not fReadOnly else u''));
                oForm.addMultilineText(TestResultFailureData.ksParam_sComment, oData.sComment, 'Comment')

                oForm.addNonText(u'%s (%s), %s'
                                 % ( oData.oAuthor.sUsername, oData.oAuthor.sUsername,
                                     self.formatTsShort(oData.tsEffective),),
                                 'Sheriff',
                                 sPostHtml = ' ' + WuiTestResultFailureDetailsLink(oData.idTestResult, "Show Details").toHtml() )

                oForm.addTextHidden(TestResultFailureData.ksParam_tsEffective, oData.tsEffective);
                oForm.addTextHidden(TestResultFailureData.ksParam_tsExpire, oData.tsExpire);
                oForm.addTextHidden(TestResultFailureData.ksParam_uidAuthor, oData.uidAuthor);
                oForm.addSubmit('Change Reason');
            else:
                oForm.addComboBox(TestResultFailureData.ksParam_idFailureReason, -1, 'Reason', aoFailureReasons,
                                  sPostHtml = ' ' + WuiFailureReasonAddLink('New').toHtml() if not fReadOnly else '');
                oForm.addMultilineText(TestResultFailureData.ksParam_sComment, '', 'Comment');
                oForm.addTextHidden(TestResultFailureData.ksParam_tsEffective, '');
                oForm.addTextHidden(TestResultFailureData.ksParam_tsExpire, '');
                oForm.addTextHidden(TestResultFailureData.ksParam_uidAuthor, '');
                oForm.addSubmit('Add Reason');

            sHtml += oForm.finalize();
        return sHtml;
Пример #2
0
    def _populateForm(self, oForm, oData):

        aoFailureReasons = FailureReasonLogic(
            self._oDisp.getDb()).fetchForCombo('Todo: Figure out why')
        sPostHtml = ''
        if oData.idFailureReason is not None and oData.idFailureReason >= 0:
            sPostHtml += u' ' + WuiFailureReasonDetailsLink(
                oData.idFailureReason).toHtml()
        sPostHtml += u' ' + WuiFailureReasonAddLink('New',
                                                    fBracketed=False).toHtml()
        oForm.addComboBox(TestResultFailureData.ksParam_idFailureReason,
                          oData.idFailureReason,
                          'Reason',
                          aoFailureReasons,
                          sPostHtml=sPostHtml)
        oForm.addMultilineText(TestResultFailureData.ksParam_sComment,
                               oData.sComment, 'Comment')
        oForm.addIntRO(TestResultFailureData.ksParam_idTestResult,
                       oData.idTestResult, 'Test Result ID')
        oForm.addIntRO(TestResultFailureData.ksParam_idTestSet,
                       oData.idTestSet, 'Test Set ID')
        oForm.addTimestampRO(TestResultFailureData.ksParam_tsEffective,
                             oData.tsEffective, 'Effective Date')
        oForm.addTimestampRO(TestResultFailureData.ksParam_tsExpire,
                             oData.tsExpire, 'Expire (excl)')
        oForm.addIntRO(TestResultFailureData.ksParam_uidAuthor,
                       oData.uidAuthor, 'Changed by UID')
        if self._sMode != WuiFormContentBase.ksMode_Show:
            oForm.addSubmit('Add' if self._sMode ==
                            WuiFormContentBase.ksMode_Add else 'Modify')
        return True