def assert_processes_folder_created(self, parent):
     folder_process = parent.get('organigramm-prozesse')
     self.assertEqual('0.0. Organigramm, Prozesse', folder_process.Title())
     self.assertEqual(u'Organigramm, Prozesse', folder_process.title_de)
     self.assertIsNone(folder_process.title_fr)
     self.assertEqual('organigramm-prozesse', folder_process.getId())
     self.assertEqual(30, ILifeCycle(folder_process).custody_period)
     self.assertEqual(u'', folder_process.description)
     self.assertEqual(u'', folder_process.former_reference)
     self.assertEqual(u'privacy_layer_no',
                      IClassification(folder_process).privacy_layer)
     self.assertEqual(u'unchecked',
                      IClassification(folder_process).public_trial)
     self.assertEqual(
         u'',
         IClassification(folder_process).public_trial_statement)
     self.assertEqual(
         "0",
         IReferenceNumberPrefix(folder_process).reference_number_prefix)
     self.assertEqual(u'', folder_process.referenced_activity)
     self.assertEqual(5, ILifeCycle(folder_process).retention_period)
     self.assertEqual(date(2005, 1, 1), folder_process.valid_from)
     self.assertEqual(date(2020, 1, 1), folder_process.valid_until)
     self.assertEqual('repositoryfolder-state-active',
                      api.content.get_state(folder_process))
     self.assertIsNone(getattr(folder_process, 'guid', None))
     self.assertIsNone(getattr(folder_process, 'parent_guid', None))
     self.assertEqual(
         IAnnotations(folder_process)[BUNDLE_GUID_KEY],
         index_data_for(folder_process)[GUID_INDEX_NAME])
     return folder_process
    def save_new_prefix(self, action):
        data, errors = self.extractData()

        if len(errors) > 0:
            return

        obj = self.context
        parent = aq_parent(aq_inner(obj))

        new_prefix = unicode(data['prefix'])
        old_prefix = IReferenceNumberPrefix(parent).get_number(obj)

        intids = getUtility(IIntIds)
        intid = intids.getId(aq_base(obj))

        prefix_adapter = IReferenceNumberPrefix(parent)

        # Check if prefix already allocated
        prefix_mapping = prefix_adapter.get_prefix_mapping(obj)
        child_mapping = prefix_adapter.get_child_mapping(obj)

        if new_prefix in prefix_mapping.values() or \
        new_prefix in child_mapping.keys():
            raise Exception("This prefix is already allocated!")

        # Save new prefix in both mappings
        prefix_mapping[intid] = new_prefix
        child_mapping[new_prefix] = intid

        # Drop entry for old prefix from child_mapping
        if old_prefix in child_mapping:
            child_mapping.pop(old_prefix)

        if IRepositoryFolder.providedBy(obj):
            # Also change the prefix on the repo folder behavior
            rnp_behavior = IReferenceNumberPrefixBehavior(obj)
            rnp_behavior.reference_number_prefix = new_prefix

        obj.reindexObject()

        IStatusMessage(self.request).addStatusMessage(
            _(u"Reference Number prefix for '%s' "
                "changed to '%s'" % (obj.id, new_prefix)), 'info')

        return self.request.RESPONSE.redirect(self.context.absolute_url())
    def test_works_also_with_alpha_numeric_prefixes(self, browser):
        self.login(self.administrator, browser)
        browser.open(self.repository_root)
        factoriesmenu.add('RepositoryFolder')
        browser.fill({
            'Title': u'Test repository',
            'Reference Prefix': 'a1x10',
        }).save()
        statusmessages.assert_no_error_messages()

        prefix_adapter = IReferenceNumberPrefix(browser.context)
        self.assertEquals('a1x10', prefix_adapter.reference_number_prefix)
    def test_repository_folder(self):
        # So, lets create the repository-root::
        self.browser.open('http://nohost/plone/folder_factories')
        self.assertPageContains('opengever.repository.repositoryroot')
        self.browser.getControl('RepositoryRoot').click()
        self.browser.getControl('Add').click()
        self.browser.getControl('Title').value = 'Registraturplan'
        self.browser.getControl('Description').value = ''
        self.browser.getControl('Save').click()
        self.browser.assert_url(
            'http://nohost/plone/registraturplan/tabbed_view')

        # Now, create our first repository folder::
        self.browser.open('./folder_factories')
        self.assertPageContains('opengever.repository.repositoryfolder')
        self.browser.getControl('RepositoryFolder').click()
        self.browser.getControl('Add').click()
        self.browser.getControl('Title').value = 'Accounting'
        self.browser.getControl('Save').click()
        self.browser.assert_url(
            'http://nohost/plone/registraturplan/accounting/tabbed_view')

        # Check some stuff::
        obj = self.portal.get('registraturplan').get('accounting')
        self.assertEquals(u'1',
                          IReferenceNumberPrefix(obj).reference_number_prefix)
        self.assertEquals(('test_user_1_', ), obj.listCreators())

        # Add another one::
        self.browser.open(
            'http://nohost/plone/registraturplan/++add++opengever.repository.repositoryfolder'
        )
        self.browser.getControl('Title').value = 'Custody'
        self.browser.getControl('Save').click()
        self.browser.assert_url(
            'http://nohost/plone/registraturplan/custody/tabbed_view')

        obj = self.portal.get('registraturplan').get('custody')
        self.assertEquals(u'2',
                          IReferenceNumberPrefix(obj).reference_number_prefix)
Example #5
0
 def test_create_repository_folder(self, browser):
     self.login(self.administrator, browser)
     browser.open(self.branch_repofolder)
     factoriesmenu.add('RepositoryFolder')
     browser.fill({'Title': 'Custody'}).save()
     statusmessages.assert_no_error_messages()
     self.assertEquals(
         ('tabbed_view', 'opengever-repository-repositoryfolder'),
         plone.view_and_portal_type())
     custody = browser.context
     self.assertEquals(
         u'2',
         IReferenceNumberPrefix(custody).reference_number_prefix)
    def test_works_also_with_alpha_numeric_prefixes(self):
        create(
            Builder('repository').within(
                self.repo).having(reference_number_prefix='5'))

        self.browser.open('%s/++add++opengever.repository.repositoryfolder' %
                          (self.repo.absolute_url()))
        self.browser.fill({
            'Title': u'Test repository',
            'Reference Prefix': 'a1x10'
        })
        self.browser.click('Save')

        prefix_adapter = IReferenceNumberPrefix(
            self.repo.get('test-repository'))
        self.assertEquals('a1x10', prefix_adapter.reference_number_prefix)
 def assert_organization_folder_created(self, root):
     folder_organisation = root.get('organisation')
     self.assertEqual('0. Organisation', folder_organisation.Title())
     self.assertEqual(u'Organisation', folder_organisation.title_de)
     self.assertIsNone(folder_organisation.title_fr)
     self.assertEqual('organisation', folder_organisation.getId())
     self.assertEqual(date(2016, 10, 1),
                      ILifeCycle(folder_organisation).date_of_cassation)
     self.assertEqual(date(2016, 10, 2),
                      ILifeCycle(folder_organisation).date_of_submission)
     self.assertEqual(u'unchecked',
                      ILifeCycle(folder_organisation).archival_value)
     self.assertEqual(
         u'',
         ILifeCycle(folder_organisation).archival_value_annotation)
     self.assertEqual(u'unprotected',
                      IClassification(folder_organisation).classification)
     self.assertEqual(30, ILifeCycle(folder_organisation).custody_period)
     self.assertEqual(date(2016, 10, 1),
                      ILifeCycle(folder_organisation).date_of_cassation)
     self.assertEqual(date(2016, 10, 2),
                      ILifeCycle(folder_organisation).date_of_submission)
     self.assertEqual(u'', folder_organisation.description)
     self.assertEqual(u'Aktenschrank 123', folder_organisation.location)
     self.assertEqual(u'privacy_layer_no',
                      IClassification(folder_organisation).privacy_layer)
     self.assertEqual(u'unchecked',
                      IClassification(folder_organisation).public_trial)
     self.assertEqual(
         u'',
         IClassification(folder_organisation).public_trial_statement)
     self.assertEqual(
         "0",
         IReferenceNumberPrefix(
             folder_organisation).reference_number_prefix)
     self.assertEqual(u'', folder_organisation.referenced_activity)
     self.assertEqual(5, ILifeCycle(folder_organisation).retention_period)
     self.assertEqual(date(2005, 1, 1), folder_organisation.valid_from)
     self.assertEqual(date(2030, 1, 1), folder_organisation.valid_until)
     self.assertEqual('repositoryfolder-state-active',
                      api.content.get_state(folder_organisation))
     self.assertIsNone(getattr(folder_organisation, 'guid', None))
     self.assertIsNone(getattr(folder_organisation, 'parent_guid', None))
     self.assertEqual(
         IAnnotations(folder_organisation)[BUNDLE_GUID_KEY],
         index_data_for(folder_organisation)[GUID_INDEX_NAME])
     return folder_organisation
    def test_using_a_free_value_lower_than_the_next_one_is_valid(
            self, browser):
        self.login(self.administrator, browser)
        create(
            Builder('repository').within(
                self.repository_root).having(reference_number_prefix='27'))

        browser.open(self.repository_root)
        factoriesmenu.add('RepositoryFolder')
        browser.fill({
            'Title': u'Test repository',
            'Reference Prefix': '26',
        }).save()
        statusmessages.assert_no_error_messages()

        prefix_adapter = IReferenceNumberPrefix(browser.context)
        self.assertEquals('26', prefix_adapter.reference_number_prefix)
    def assert_leaf_repofolder_created(self, parent):
        leaf_repofolder = parent.get('personal')
        self.assertEqual('0.3. Personal', leaf_repofolder.Title())
        self.assertEqual(u'Personal', leaf_repofolder.title_de)
        self.assertIsNone(leaf_repofolder.title_fr)
        self.assertEqual('personal', leaf_repofolder.getId())
        self.assertEqual(u'prompt', ILifeCycle(leaf_repofolder).archival_value)
        self.assertEqual(u'confidential',
                         IClassification(leaf_repofolder).classification)
        self.assertEqual(100, ILifeCycle(leaf_repofolder).custody_period)
        self.assertEqual(u'', leaf_repofolder.description)
        self.assertEqual(u'', leaf_repofolder.former_reference)
        self.assertEqual(u'privacy_layer_yes',
                         IClassification(leaf_repofolder).privacy_layer)
        self.assertEqual(u'private',
                         IClassification(leaf_repofolder).public_trial)
        self.assertEqual(
            u'Enth\xe4lt vertrauliche Personaldossiers.',
            IClassification(leaf_repofolder).public_trial_statement)
        self.assertEqual(
            "3",
            IReferenceNumberPrefix(leaf_repofolder).reference_number_prefix)
        self.assertEqual(u'', leaf_repofolder.referenced_activity)
        self.assertEqual(10, ILifeCycle(leaf_repofolder).retention_period)
        self.assertEqual(
            u'',
            ILifeCycle(leaf_repofolder).retention_period_annotation)
        self.assertEqual(date(2005, 1, 1), leaf_repofolder.valid_from)
        self.assertEqual(date(2050, 1, 1), leaf_repofolder.valid_until)
        self.assertEqual('repositoryfolder-state-active',
                         api.content.get_state(leaf_repofolder))
        self.assertIsNone(getattr(leaf_repofolder, 'guid', None))
        self.assertIsNone(getattr(leaf_repofolder, 'parent_guid', None))
        self.assertEqual(
            IAnnotations(leaf_repofolder)[BUNDLE_GUID_KEY],
            index_data_for(leaf_repofolder)[GUID_INDEX_NAME])

        self.assertDictContainsSubset(
            {
                'privileged_users':
                ['Contributor', 'Reviewer', 'Editor', 'Reader'],
                'admin_users': ['Publisher']
            }, leaf_repofolder.__ac_local_roles__)
        self.assertTrue(leaf_repofolder.__ac_local_roles_block__)

        return leaf_repofolder
    def test_using_a_free_value_lower_than_the_next_one_is_valid(self):
        create(
            Builder('repository').within(
                self.repo).having(reference_number_prefix='8'))
        create(
            Builder('repository').within(
                self.repo).having(reference_number_prefix='9'))

        self.browser.open('%s/++add++opengever.repository.repositoryfolder' %
                          (self.repo.absolute_url()))
        self.browser.fill({
            'Title': u'Test repository',
            'Reference Prefix': '7'
        })
        self.browser.click('Save')

        prefix_adapter = IReferenceNumberPrefix(
            self.repo.get('test-repository'))
        self.assertEquals('7', prefix_adapter.reference_number_prefix)
Example #11
0
    def get_local_number(self):
        prefix = IReferenceNumberPrefix(self.context).reference_number_prefix

        return prefix or ''