def showForm(self, dErrors=None, sErrorMsg=None): """ Render the form. """ oForm = WuiHlpForm( self._sId, '?' + webutils.encodeUrlParams( {WuiDispatcherBase.ksParamAction: self._sSubmitAction}), dErrors if dErrors is not None else dict(), fReadOnly=self._sMode == self.ksMode_Show) self._oData.convertToParamNull() # If form cannot be constructed due to some reason we # need to show this reason try: self._populateForm(oForm, self._oData) if self._sRedirectTo is not None: oForm.addTextHidden(self._oDisp.ksParamRedirectTo, self._sRedirectTo) except WuiException as oXcpt: sContent = unicode(oXcpt) else: sContent = oForm.finalize() # Add any post form content. atPostFormContent = self._generatePostFormContent(self._oData) if atPostFormContent: for iSection, tSection in enumerate(atPostFormContent): (sSectionTitle, sSectionContent) = tSection sContent += u'<div id="postform-%d" class="tmformpostsection">\n' % ( iSection, ) if sSectionTitle: sContent += '<h3 class="tmformpostheader">%s</h3>\n' % ( webutils.escapeElem(sSectionTitle), ) sContent += u' <div id="postform-%d-content" class="tmformpostcontent">\n' % ( iSection, ) sContent += sSectionContent sContent += u' </div>\n' \ u'</div>\n' # Add action to the top. aoActions = self._generateTopRowFormActions(self._oData) if aoActions: sActionLinks = '<p>%s</p>' % (' '.join( unicode(oLink) for oLink in aoActions)) sContent = sActionLinks + sContent # Add error info to the top. if sErrorMsg is not None: sContent = '<p class="tmerrormsg">' + webutils.escapeElem( sErrorMsg) + '</p>\n' + sContent return (self._sTitle, sContent)
def showForm(self, dErrors = None, sErrorMsg = None): """ Render the form. """ oForm = WuiHlpForm(self._sId, '?' + webutils.encodeUrlParams({WuiDispatcherBase.ksParamAction: self._sSubmitAction}), dErrors if dErrors is not None else dict(), fReadOnly = self._sMode == self.ksMode_Show); self._oData.convertToParamNull(); # If form cannot be constructed due to some reason we # need to show this reason try: self._populateForm(oForm, self._oData); if self._sRedirectTo is not None: oForm.addTextHidden(self._oDisp.ksParamRedirectTo, self._sRedirectTo); except WuiException as oXcpt: sContent = unicode(oXcpt) else: sContent = oForm.finalize(); # Add any post form content. atPostFormContent = self._generatePostFormContent(self._oData); if atPostFormContent: for iSection, tSection in enumerate(atPostFormContent): (sSectionTitle, sSectionContent) = tSection; sContent += u'<div id="postform-%d" class="tmformpostsection">\n' % (iSection,); if sSectionTitle: sContent += '<h3 class="tmformpostheader">%s</h3>\n' % (webutils.escapeElem(sSectionTitle),); sContent += u' <div id="postform-%d-content" class="tmformpostcontent">\n' % (iSection,); sContent += sSectionContent; sContent += u' </div>\n' \ u'</div>\n'; # Add action to the top. aoActions = self._generateTopRowFormActions(self._oData); if aoActions: sActionLinks = '<p>%s</p>' % (' '.join(unicode(oLink) for oLink in aoActions)); sContent = sActionLinks + sContent; # Add error info to the top. if sErrorMsg is not None: sContent = '<p class="tmerrormsg">' + webutils.escapeElem(sErrorMsg) + '</p>\n' + sContent; return (self._sTitle, sContent);
def showForm(self, dErrors = None, sErrorMsg = None): """ Render the form. """ oForm = WuiHlpForm(self._sId, '?' + webutils.encodeUrlParams({WuiDispatcherBase.ksParamAction: self._sSubmitAction}), dErrors if dErrors is not None else dict(), fReadOnly = self._sMode == self.ksMode_Show); self._oData.convertToParamNull(); # If form cannot be constructed due to some reason we # need to show this reason try: self._populateForm(oForm, self._oData); if self._sRedirectTo is not None: oForm.addTextHidden(self._oDisp.ksParamRedirectTo, self._sRedirectTo); except WuiException, oXcpt: sContent = unicode(oXcpt)
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 len(aoFailureReasons) > 0; # 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 ) oForm = WuiHlpForm('failure-reason', sFormActionUrl, sOnSubmit = WuiHlpForm.ksOnSubmit_AddReturnToFieldWithCurrentUrl); 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()); 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()); 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;