Example #1
0
    def get_indexer_value(self, searchable=False):
        """Return the filing value for the filing_no indexer.
        For Dossiers without a number and only a prefix it return the half
        of the number."""

        value = None
        if IFilingNumber(self.context).filing_no:
            value = IFilingNumber(self.context).filing_no

        elif IDossier(self.context).filing_prefix:
            value = '%s-%s-?' % (
                self._get_client_id(),
                self._get_term_title(
                    IDossier(self.context).filing_prefix,
                    'opengever.dossier.type_prefixes'),
            )
            if searchable:
                # cut the -? away
                value = value[:-2]

        if value:
            if searchable:
                return value.replace('-', ' ')
            return value
        return
Example #2
0
    def get_indexer_value(self, searchable=False):
        """Return the filing value for the filing_no indexer.
        For Dossiers without a number and only a prefix it return the half
        of the number."""

        value = None
        if IFilingNumber(self.context).filing_no:
            value = IFilingNumber(self.context).filing_no

        elif IDossier(self.context).filing_prefix:
            value = '%s-%s-?' % (
                self._get_admin_unit_title(),
                self._get_term_title(
                    IDossier(self.context).filing_prefix,
                    'opengever.dossier.type_prefixes'),
                )
            if searchable:
                # cut the -? away
                value = value[:-2]

        if value:
            if searchable:
                return value.replace('-', ' ')
            return value
        return
Example #3
0
    def test_archiving_with_existing_number(self):
        number = 'FAKE NUMBER'
        self.archiver.archive('administration', '2013', number=number)

        self.assertEquals('FAKE NUMBER', IFilingNumber(self.dossier).filing_no)
        self.assertEquals('FAKE NUMBER.1', IFilingNumber(self.sub1).filing_no)
        self.assertEquals('FAKE NUMBER.2', IFilingNumber(self.sub2).filing_no)
        self.assertEquals('FAKE NUMBER.1.1',
                          IFilingNumber(self.subsub1).filing_no)
    def test_archiving(self):
        self.login(self.dossier_responsible)
        IDossierArchiver(self.dossier).archive('administration', '2013')

        self.assertEquals('Hauptmandant-Administration-2013-1',
                          IFilingNumber(self.dossier).filing_no)
        self.assertEquals('Hauptmandant-Administration-2013-1.1',
                          IFilingNumber(self.subdossier).filing_no)
        self.assertEquals('Hauptmandant-Administration-2013-1.2',
                          IFilingNumber(self.subdossier2).filing_no)
 def test_archiving_with_existing_number(self):
     self.login(self.dossier_responsible)
     number = 'FAKE NUMBER'
     IDossierArchiver(self.dossier).archive('administration',
                                            '2013',
                                            number=number)
     self.assertEquals('FAKE NUMBER', IFilingNumber(self.dossier).filing_no)
     self.assertEquals('FAKE NUMBER.1',
                       IFilingNumber(self.subdossier).filing_no)
     self.assertEquals('FAKE NUMBER.2',
                       IFilingNumber(self.subdossier2).filing_no)
Example #6
0
    def test_archiving(self):
        self.archiver.archive('administration', '2013')

        self.assertEquals('SKA ARCH-Administration-2013-1',
                          IFilingNumber(self.dossier).filing_no)
        self.assertEquals('SKA ARCH-Administration-2013-1.1',
                          IFilingNumber(self.sub1).filing_no)
        self.assertEquals('SKA ARCH-Administration-2013-1.2',
                          IFilingNumber(self.sub2).filing_no)
        self.assertEquals('SKA ARCH-Administration-2013-1.1.1',
                          IFilingNumber(self.subsub1).filing_no)
    def test_report_appends_filing_fields(self, browser):
        self.activate_feature('filing_number')
        self.login(self.regular_user, browser=browser)

        IFilingNumber(self.dossier).filing_no = u'Client1-Leitung-2012-1'
        self.dossier.reindexObject()

        browser.open(view='dossier_report',
                     data=self.make_path_param(self.dossier))

        data = browser.contents
        with NamedTemporaryFile(delete=False, suffix='.xlsx') as tmpfile:
            tmpfile.write(data)
            tmpfile.flush()
            workbook = load_workbook(tmpfile.name)

        labels = [cell.value for cell in list(workbook.active.rows)[0]]
        self.assertIn(u'filing_no_filing', labels)
        self.assertIn(u'filing_no_year', labels)
        self.assertIn(u'filing_no_number', labels)
        self.assertIn(u'Filing number', labels)

        self.assertSequenceEqual([
            self.dossier.title,
            datetime(2016, 1, 1), None, u'Ziegler Robert (robert.ziegler)',
            u'Leitung', 2012, 1, u'Client1-Leitung-2012-1',
            u'dossier-state-active', u'Client1 1.1 / 1'
        ], [cell.value for cell in list(workbook.active.rows)[1]])
    def test_precondition_violation_raises_error_on_archive_form(
            self, browser):
        """Preconditions also need to be validated and handled correctly if
        the user directly invokes the transition-archive form.
        """
        self.login(self.secretariat_user, browser)

        # Create open task to violate one of the preconditions for resolving
        create(
            Builder('task').within(self.empty_dossier).having(
                responsible_client='fa',
                responsible=self.regular_user.getId(),
                issuer=self.dossier_responsible.getId(),
                task_type='correction',
                deadline=date(2016, 11, 1)).in_state('task-state-open'))

        browser.open(self.empty_dossier, view='transition-archive')

        browser.fill({
            'filing prefix': 'Government',
            'filing Year': u'2017',
            'Action': 'resolve and set filing no'
        })
        browser.click_on('Archive')

        self.assert_workflow_state('dossier-state-active', self.empty_dossier)
        self.assertEqual(['not all task are closed'],
                         statusmessages.error_messages())
        self.assertEquals(None, IFilingNumber(self.empty_dossier).filing_no)
Example #9
0
    def __call__(self):
        searchable = []
        # append some other attributes to the searchableText index
        # reference_number
        refNumb = getAdapter(self.context, IReferenceNumber)
        searchable.append(refNumb.get_number())

        # sequence_number
        seqNumb = getUtility(ISequenceNumber)
        searchable.append(str(seqNumb.get_number(self.context)))

        # responsible
        searchable.append(self.context.responsible_label.encode('utf-8'))

        # filing_no
        if IFilingNumberMarker.providedBy(self.context):
            filing_no = getattr(IFilingNumber(self.context), 'filing_no', None)
            if filing_no:
                searchable.append(filing_no.encode('utf-8'))

        # comments
        comments = getattr(IDossier(self.context), 'comments', None)
        if comments:
            searchable.append(comments.encode('utf-8'))

        # keywords
        keywords = IDossier(self.context).keywords
        if keywords:
            searchable.extend(
                keyword.encode('utf-8') if isinstance(keyword, unicode)
                else keyword
                for keyword in keywords)

        return ' '.join(searchable)
Example #10
0
    def migrate_filing_number(self, brain):

        filing_number = brain.filing_no
        if filing_number and not filing_number.endswith('-?'):

            dossier = brain.getObject()
            IFilingNumber(dossier).filing_no = IDossier(dossier).filing_no
    def test_dossier_byline_filing_number_display(self, browser):
        self.login(self.regular_user, browser=browser)
        IFilingNumber(self.dossier).filing_no = 'OG-Amt-2013-5'

        browser.open(self.dossier)

        filing_number = self.get_byline_value_by_label('Filing Number:')
        self.assertEquals('OG-Amt-2013-5', filing_number.text)
Example #12
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())
Example #13
0
    def test_returns_filing_number_for_dossiers_with_only_filing_prefix_information(self):
        self.login(self.regular_user)

        IDossier(self.dossier).filing_prefix = self.filing_prefix
        IFilingNumber(self.dossier).filing_no = self.filing_no
        self.dossier.reindexObject()

        self.assert_index_value(self.filing_no, 'filing_no', self.dossier)
        self.assert_index_value(self.searchable_filing_no, 'searchable_filing_no', self.dossier)
Example #14
0
    def _recursive_archive(self, dossier, number, prefix):

        IFilingNumber(dossier).filing_no = number

        IDossier(self.context).filing_prefix = prefix
        dossier.reindexObject(idxs=['filing_no', 'searchable_filing_no'])

        for i, subdossier in enumerate(dossier.get_subdossiers(), start=1):
            self._recursive_archive(subdossier.getObject(),
                                    '%s.%i' % (number, i), prefix)
    def test_resolving_and_set_new_filing_number(self, browser):
        self.login(self.secretariat_user, browser)

        former_filing_number = u'Hauptmandant-Administration-2013-1'
        IFilingNumber(self.empty_dossier).filing_no = former_filing_number
        browser.open(self.empty_dossier, view='transition-archive')

        browser.fill({
            'filing prefix': 'Government',
            'filing Year': u'2017',
            'Action': 'resolve and set a new filing no'
        })
        browser.click_on('Archive')

        self.assert_workflow_state('dossier-state-resolved',
                                   self.empty_dossier)
        statusmessages.assert_message('The Dossier has been resolved')
        self.assertEquals('Hauptmandant-Government-2017-1',
                          IFilingNumber(self.empty_dossier).filing_no)
Example #16
0
    def test_filing_no_is_also_in_searchable_text(self):
        self.login(self.regular_user)

        IDossier(self.dossier).filing_prefix = self.filing_prefix
        IFilingNumber(self.dossier).filing_no = self.filing_no
        self.dossier.reindexObject()

        searchable_text_data = index_data_for(self.dossier).get('SearchableText')

        for segment in self.searchable_filing_no:
            self.assertIn(segment, searchable_text_data)
    def test_only_give_filing_number_on_resolved_dossier(self, browser):
        self.login(self.secretariat_user, browser)
        self.set_workflow_state('dossier-state-resolved', self.empty_dossier)
        browser.open(self.empty_dossier, view='transition-archive')

        browser.fill({
            'filing prefix': 'Government',
            'filing Year': u'2017',
            'Action': 'set a filing no'
        })
        browser.click_on('Archive')

        self.assert_workflow_state('dossier-state-resolved',
                                   self.empty_dossier)
        statusmessages.assert_message('The filing number has been given.')
        self.assertEquals('Hauptmandant-Government-2017-1',
                          IFilingNumber(self.empty_dossier).filing_no)
Example #18
0
def get_filing_actions(context):
    """Create a vocabulary with different actions,
    depending on the actual review_state."""

    wft = getToolByName(context, 'portal_workflow')
    review_state = wft.getInfoFor(context, 'review_state', None)
    filing_no = IFilingNumber(context).filing_no

    values = []

    if review_state != 'dossier-state-resolved':

        # not archived yet or not a valid filing_no
        if filing_no and re.search(FILLING_NO_PATTERN, filing_no):
            values.append(
                SimpleVocabulary.createTerm(METHOD_RESOLVING_EXISTING_FILING,
                                            RESOLVE_WITH_EXISTING_NUMBER,
                                            RESOLVE_WITH_EXISTING_NUMBER))

            values.append(
                SimpleVocabulary.createTerm(METHOD_RESOLVING_AND_FILING,
                                            RESOLVE_WITH_NEW_NUMBER,
                                            RESOLVE_WITH_NEW_NUMBER))

        # allready archived
        else:
            values.append(
                SimpleVocabulary.createTerm(METHOD_RESOLVING_AND_FILING,
                                            RESOLVE_AND_NUMBER,
                                            RESOLVE_AND_NUMBER))

            values.append(
                SimpleVocabulary.createTerm(METHOD_RESOLVING, ONLY_RESOLVE,
                                            ONLY_RESOLVE))
    # allready resolved
    else:
        if not filing_no:
            values.append(
                SimpleVocabulary.createTerm(METHOD_FILING, ONLY_NUMBER,
                                            ONLY_NUMBER))

    return SimpleVocabulary(values)
Example #19
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())

        # Validate resolving preconditions
        resolver = get_resolver(self.context)
        try:
            resolver.raise_on_failed_preconditions()

        except PreconditionsViolated as exc:
            return self.show_errors(exc.errors)

        except InvalidDates as exc:
            return self.show_invalid_end_dates(
                titles=exc.invalid_dossier_titles)

        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())
Example #20
0
 def get_filing_no(self):
     if IFilingNumberMarker(self.context):
         return IFilingNumber(self.context).filing_no