Esempio n. 1
0
    def archive(self, action):
        """Try to archive this dossier.

        For that to happen, first all subdossiers need to have filing_no
        and end_date set, and then be resolved. If resolving any of the
        subdossier fails, we'll throw and error and return.
        """

        data, errors = self.extractData()

        # Abort if there were errors
        if len(errors) > 0:
            return
        self.ptool = getToolByName(self.context, 'plone_utils')
        self.wft = self.context.portal_workflow

        action = data.get('filing_action')
        filing_year = data.get('filing_year')
        filing_no = None
        filing_prefix = data.get('filing_prefix')
        end_date = data.get('dossier_enddate')

        if action == METHOD_FILING:
            # allready resolved only give a filing number
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)
            self.ptool.addPortalMessage(
                _("The filing number has been given"), type="info")
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        # archiving must passed to the resolving view
        resolver = IDossierResolver(self.context)
        if resolver.is_resolve_possible():
            raise TypeError
        if resolver.are_enddates_valid():
            raise TypeError

        if action == METHOD_RESOLVING_AND_FILING:
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)

        if action == METHOD_RESOLVING_EXISTING_FILING:
            # archive all with the existing filing number
            filing_no = IFilingNumber(self.context).filing_no
            filing_prefix = IDossier(self.context).filing_prefix
            IDossierArchiver(self.context).archive(
                filing_prefix, filing_year, number=filing_no)

        if action == METHOD_RESOLVING:
            # only update the prefixes
            if filing_prefix:
                IDossierArchiver(self.context).update_prefix(filing_prefix)

        # If everything went well, resolve the main dossier
        resolver.resolve(end_date=end_date)

        self.ptool.addPortalMessage(
            _("The Dossier has been resolved"), type="info")
        return self.request.RESPONSE.redirect(self.context.absolute_url())
Esempio n. 2
0
    def render(self):
        ptool = getToolByName(self, 'plone_utils')

        resolver = IDossierResolver(self.context)

        # check preconditions
        if resolver.is_reactivate_possible():
            resolver.reactivate()
            ptool.addPortalMessage(_('Dossiers successfully reactivated.'),
                                   type="info")
            self.request.RESPONSE.redirect(self.context.absolute_url())
        else:
            ptool.addPortalMessage(
                _("It isn't possible to reactivate a sub dossier."),
                type="warning")
            self.request.RESPONSE.redirect(self.context.absolute_url())
Esempio n. 3
0
    def archive(self, action):
        """Try to archive this dossier.

        For that to happen, first all subdossiers need to have filing_no
        and end_date set, and then be resolved. If resolving any of the
        subdossier fails, we'll throw and error and return.
        """

        data, errors = self.extractData()

        # Abort if there were errors
        if len(errors) > 0:
            return
        self.ptool = getToolByName(self.context, 'plone_utils')
        self.wft = self.context.portal_workflow

        action = data.get('filing_action')
        filing_year = data.get('filing_year')
        filing_no = None
        filing_prefix = data.get('filing_prefix')
        end_date = data.get('dossier_enddate')

        if action == METHOD_FILING:
            # allready resolved only give a filing number
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)
            self.ptool.addPortalMessage(_("The filing number has been given"),
                                        type="info")
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        # archiving must passed to the resolving view
        resolver = IDossierResolver(self.context)
        if resolver.is_resolve_possible():
            raise TypeError
        if resolver.are_enddates_valid():
            raise TypeError

        if action == METHOD_RESOLVING_AND_FILING:
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)

        if action == METHOD_RESOLVING_EXISTING_FILING:
            # archive all with the existing filing number
            filing_no = IFilingNumber(self.context).filing_no
            filing_prefix = IDossier(self.context).filing_prefix
            IDossierArchiver(self.context).archive(filing_prefix,
                                                   filing_year,
                                                   number=filing_no)

        if action == METHOD_RESOLVING:
            # only update the prefixes
            if filing_prefix:
                IDossierArchiver(self.context).update_prefix(filing_prefix)

        # If everything went well, resolve the main dossier
        resolver.resolve(end_date=end_date)

        self.ptool.addPortalMessage(_("The Dossier has been resolved"),
                                    type="info")
        return self.request.RESPONSE.redirect(self.context.absolute_url())
Esempio n. 4
0
    def render(self):

        ptool = getToolByName(self, 'plone_utils')

        resolver = IDossierResolver(self.context)

        # check preconditions
        errors = resolver.is_resolve_possible()
        if errors:
            for msg in errors:
                ptool.addPortalMessage(msg, type="error")

            return self.request.RESPONSE.redirect(
                self.context.absolute_url())

        # validate enddates
        invalid_dates = resolver.are_enddates_valid()
        if invalid_dates:
            for title in invalid_dates:
                ptool.addPortalMessage(
                    _("The dossier ${dossier} has a invalid end_date",
                      mapping=dict(dossier=title,)),
                    type="error")

            return self.request.RESPONSE.redirect(
                self.context.absolute_url())

        if resolver.is_archive_form_needed():
            self.request.RESPONSE.redirect('transition-archive')
        else:
            resolver.resolve()
            if self.context.is_subdossier():
                ptool.addPortalMessage(
                    _('The subdossier has been succesfully resolved'),
                    type='info')
            else:
                ptool.addPortalMessage(
                    _('The dossier has been succesfully resolved'),
                    type='info')

            self.request.RESPONSE.redirect(self.context.absolute_url())