Example #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
Example #2
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
Example #3
0
    def _actionGlobalRsrcShowAddEdit(self, sAction): # pylint: disable=C0103
        """Show Global Resource creation or edit dialog"""

        oGlobalResourceLogic = GlobalResourceLogic(self._oDb)
        if sAction == WuiAdmin.ksActionGlobalRsrcEdit:
            idGlobalRsrc = self.getIntParam(GlobalResourceData.ksParam_idGlobalRsrc, iDefault = -1)
            oData = oGlobalResourceLogic.getById(idGlobalRsrc)
        else:
            oData = GlobalResourceData()
            oData.convertToParamNull()

        self._checkForUnknownParameters()

        oContent = WuiGlobalResource(oData)
        (self._sPageTitle, self._sPageBody) = oContent.showAddModifyPage(sAction)

        return True
Example #4
0
    def _actionGlobalRsrcShowAddEdit(self, sAction): # pylint: disable=C0103
        """Show Global Resource creation or edit dialog"""

        oGlobalResourceLogic = GlobalResourceLogic(self._oDb)
        if sAction == WuiAdmin.ksActionGlobalRsrcEdit:
            idGlobalRsrc = self.getIntParam(GlobalResourceData.ksParam_idGlobalRsrc, iDefault = -1)
            oData = oGlobalResourceLogic.getById(idGlobalRsrc)
        else:
            oData = GlobalResourceData()
            oData.convertToParamNull()

        self._checkForUnknownParameters()

        oContent = WuiGlobalResource(oData)
        (self._sPageTitle, self._sPageBody) = oContent.showAddModifyPage(sAction)

        return True