Ejemplo n.º 1
0
    def test_transport_to_returns_a_dict_with_the_path_to_the_new_object(self):
        source_dossier = create(Builder("dossier").titled(u"Source"))
        target_dossier = create(Builder("dossier").titled(u"Target"))
        document = create(Builder("document")
                          .within(source_dossier)
                          .titled(u'Fo\xf6')
                          .with_dummy_content())

        data = Transporter().transport_to(
            document, 'client1', '/'.join(target_dossier.getPhysicalPath()))
        transported_doc = self.portal.unrestrictedTraverse(
            data.get('path').encode('utf-8'))

        # data
        self.assertEquals(u'Fo\xf6', transported_doc.title)
        self.assertEquals('Test data', transported_doc.file.data)

        # behavior data
        self.assertEquals(u'unprotected',
                          IClassification(transported_doc).classification)
        self.assertEquals(u'unchecked',
                          IClassification(transported_doc).public_trial)

        # dublin core
        self.assertEquals(document.created(), transported_doc.created())
        self.assertEquals(TEST_USER_ID, transported_doc.Creator())
 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 assert_dossier_peter_created(self, parent):
        dossier_peter = parent.get('dossier-2')
        self.assertEqual(
            u'archival worthy',
            ILifeCycle(dossier_peter).archival_value)
        self.assertEqual(
            u'Beinhaltet Informationen zum Verfahren',
            ILifeCycle(dossier_peter).archival_value_annotation)
        self.assertEqual(
            u'classified',
            IClassification(dossier_peter).classification)
        self.assertEqual(
            150,
            ILifeCycle(dossier_peter).custody_period)
        self.assertEqual(
            u'Wir haben Hanspeter M\xfcller in einem Verfahren entlassen.',
            dossier_peter.description)
        self.assertEqual(
            date(2007, 1, 1),
            IDossier(dossier_peter).start)
        self.assertEqual(
            date(2011, 1, 6),
            IDossier(dossier_peter).end)
        self.assertEqual(
            tuple(),
            IDossier(dossier_peter).keywords)
        self.assertEqual(
            u'privacy_layer_yes',
            IClassification(dossier_peter).privacy_layer)
        self.assertEqual(
            '7',
            IDossier(dossier_peter).reference_number)
        self.assertEqual(
            [],
            IDossier(dossier_peter).relatedDossier)
        self.assertEqual(
            u'lukas.graf',
            IDossier(dossier_peter).responsible)
        self.assertEqual(
            5,
            ILifeCycle(dossier_peter).retention_period)
        self.assertIsNone(
            ILifeCycle(dossier_peter).retention_period_annotation)

        self.assertEqual(
            'dossier-state-resolved',
            api.content.get_state(dossier_peter))

        self.assertEqual(
            u'Hanspeter M\xfcller',
            dossier_peter.title)

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

        return dossier_peter
Ejemplo n.º 4
0
    def test_transport_from_copies_the_object_inclusive_metadata_and_dublin_core_data(self):
        self.login(self.regular_user)

        transported_doc = Transporter().transport_from(
            self.empty_dossier, 'plone', '/'.join(self.document.getPhysicalPath()))

        self.assertEquals(self.document.title, transported_doc.title)
        self.assertEquals(self.document.file.data, transported_doc.file.data)

        self.assertEquals(u'unprotected',
                          IClassification(transported_doc).classification)
        self.assertEquals(u'unchecked',
                          IClassification(transported_doc).public_trial)

        self.assertEquals(self.document.created(), transported_doc.created())
        self.assertEquals(self.document.Creator(), transported_doc.Creator())
 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 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 assert_document_2_created(self, parent):
        document_2 = parent.get('document-2')

        self.assertTrue(document_2.digitally_available)
        self.assertIsNotNone(document_2.file)
        self.assertEqual(22198, len(document_2.file.data))

        self.assertEqual(
            u'david.erni',
            document_2.document_author)
        self.assertEqual(
            date(2011, 1, 1),
            document_2.document_date)
        self.assertEqual(
            u'directive',
            document_2.document_type)
        self.assertEqual(
            tuple(),
            document_2.keywords)
        self.assertTrue(
            document_2.preserved_as_paper)
        self.assertEqual(
            u'private',
            IClassification(document_2).public_trial)
        self.assertEqual(
            u'Enth\xe4lt private Daten',
            IClassification(document_2).public_trial_statement)
        self.assertEqual(
            date(2011, 1, 1),
            document_2.receipt_date)
        self.assertEqual(
            [],
            document_2.relatedItems)
        self.assertEqual(
            'document-state-draft',
            api.content.get_state(document_2))
        self.assertEqual(
            u'Entlassung Hanspeter M\xfcller',
            document_2.title)

        repo_tool = api.portal.get_tool('portal_repository')
        history = repo_tool.getHistoryMetadata(document_2)
        self.assertEqual(1, len(history))
Ejemplo n.º 8
0
    def test_classification_acquires_default_with_quickupload(self, browser):
        self.login(self.regular_user, browser=browser)

        IClassification(self.dossier).classification = 'confidential'
        document = create(
            Builder('quickuploaded_document').within(
                self.dossier).with_data('text'))

        value = self.get_classification(document)
        self.assertEqual(u'confidential', value)
Ejemplo n.º 9
0
def set_classification_attributes(binding, obj):
    classification = IClassification(obj)
    binding.klassifizierungskategorie = voc_term_title(
        IClassification['classification'], classification.classification)
    binding.datenschutz = (True if classification.privacy_layer
                           == 'privacy_layer_yes' else False)
    binding.oeffentlichkeitsstatus = voc_term_title(
        IClassification['public_trial'], classification.public_trial)
    binding.oeffentlichkeitsstatusBegruendung = (
        classification.public_trial_statement)
Ejemplo n.º 10
0
    def test_transport_from_copies_the_object_inclusive_metadata_and_dublin_core_data(self):
        dossier = create(Builder("dossier").titled(u"Dossier"))
        document = create(Builder("document")
                          .within(dossier)
                          .titled(u'Testdocument')
                          .with_dummy_content())

        transported_doc = Transporter().transport_from(
            dossier, 'client1', '/'.join(document.getPhysicalPath()))

        self.assertEquals('Testdocument', transported_doc.title)
        self.assertEquals('Test data', transported_doc.file.data)

        self.assertEquals(u'unprotected',
                          IClassification(transported_doc).classification)
        self.assertEquals(u'unchecked',
                          IClassification(transported_doc).public_trial)

        self.assertEquals(document.created(), transported_doc.created())
        self.assertEquals(TEST_USER_ID, transported_doc.Creator())
    def assert_mail_1_created(self, parent):
        mail = parent.get('document-3')

        self.assertTrue(mail.digitally_available)
        self.assertIsNotNone(mail.message)
        self.assertEqual(920, len(mail.message.data))

        self.assertEqual(
            u'Peter Muster <*****@*****.**>',
            mail.document_author)
        self.assertEqual(
            date(2013, 1, 1),
            mail.document_date)
        self.assertEqual(
            None,
            mail.document_type)
        self.assertEqual(
            tuple(),
            mail.keywords)
        self.assertTrue(
            mail.preserved_as_paper)
        self.assertEqual(
            u'unchecked',
            IClassification(mail).public_trial)
        self.assertEqual(
            u'',
            IClassification(mail).public_trial_statement)
        self.assertEqual(
            FROZEN_NOW.date(),
            mail.receipt_date)
        self.assertEqual(
            'mail-state-active',
            api.content.get_state(mail))

        self.assertEqual(
            u'Ein Mail',
            mail.title)

        repo_tool = api.portal.get_tool('portal_repository')
        history = repo_tool.getHistoryMetadata(mail)
        self.assertEqual(0, len(history))
Ejemplo n.º 12
0
    def test_transport_to_returns_a_dict_with_the_path_to_the_new_object(self):
        self.login(self.regular_user)

        data = Transporter().transport_to(
            self.document, 'plone', '/'.join(self.empty_dossier.getPhysicalPath()))

        transported_doc = self.portal.unrestrictedTraverse(data.get('path').encode('utf-8'))

        # data
        self.assertEquals(self.document.title, transported_doc.title)
        self.assertEquals(self.document.file.data, transported_doc.file.data)

        # behavior data
        self.assertEquals(u'unprotected',
                          IClassification(transported_doc).classification)
        self.assertEquals(u'unchecked',
                          IClassification(transported_doc).public_trial)

        # dublin core
        self.assertEquals(self.document.created(), transported_doc.created())
        self.assertEquals(self.document.Creator(), transported_doc.Creator())
    def assert_mail1_created(self, parent):
        mail = self.find_by_title(parent, u'Ein Mail')

        self.assertTrue(mail.digitally_available)
        self.assertIsNotNone(mail.message)
        self.assertEqual(920, len(mail.message.data))

        self.assertEqual(u'Peter Muster <*****@*****.**>',
                         mail.document_author)
        self.assertEqual(date(2013, 1, 1), mail.document_date)
        self.assertEqual(None, mail.document_type)
        self.assertEqual(tuple(), mail.keywords)
        self.assertTrue(mail.preserved_as_paper)
        self.assertEqual(u'unchecked', IClassification(mail).public_trial)
        self.assertEqual(u'', IClassification(mail).public_trial_statement)
        self.assertEqual(FROZEN_NOW.date(), mail.receipt_date)
        self.assertEqual('mail-state-active', api.content.get_state(mail))

        self.assertEqual(
            IAnnotations(mail)[BUNDLE_GUID_KEY],
            index_data_for(mail)[GUID_INDEX_NAME])
Ejemplo n.º 14
0
 def __init__(self, dossier, disposition):
     self.title = dossier.title
     self.intid = getUtility(IIntIds).getId(dossier)
     self.url = dossier.absolute_url()
     self.reference_number = dossier.get_reference_number()
     self.parent = aq_parent(aq_inner(dossier))
     self.start = IDossier(dossier).start
     self.end = IDossier(dossier).end
     self.public_trial = IClassification(dossier).public_trial
     self.archival_value = ILifeCycle(dossier).archival_value
     self.archival_value_annotation = ILifeCycle(dossier).archival_value_annotation
     self.appraisal = IAppraisal(disposition).get(dossier)
     self.former_state = dossier.get_former_state()
    def assert_document_2_created(self, parent):
        document_2 = parent.objectValues()[1]

        self.assertTrue(document_2.digitally_available)
        self.assertIsNotNone(document_2.file)
        self.assertEqual(22198, len(document_2.file.data))

        self.assertEqual(u'david.erni', document_2.document_author)
        self.assertEqual(date(2011, 1, 1), document_2.document_date)
        self.assertEqual(u'directive', document_2.document_type)
        self.assertEqual(tuple(), document_2.keywords)
        self.assertTrue(document_2.preserved_as_paper)
        self.assertEqual(u'private', IClassification(document_2).public_trial)
        self.assertEqual(u'Enth\xe4lt private Daten',
                         IClassification(document_2).public_trial_statement)
        self.assertEqual(date(2011, 1, 1), document_2.receipt_date)
        self.assertEqual([], document_2.relatedItems)
        self.assertEqual('document-state-draft',
                         api.content.get_state(document_2))
        self.assertEqual(u'Entlassung Hanspeter M\xfcller', document_2.title)
        self.assertEqual(
            IAnnotations(document_2)[BUNDLE_GUID_KEY],
            index_data_for(document_2)[GUID_INDEX_NAME])
Ejemplo n.º 16
0
    def test_classification_attributes_and_schutzfrist(self):
        self.login(self.regular_user)

        classification = IClassification(self.dossier)
        classification.privacy_layer = 'privacy_layer_yes'
        classification.public_trial = 'private'
        classification.public_trial_statement = u'Enth\xe4lt sch\xfctzenswerte Daten.'

        binding = Dossier(self.dossier).binding()

        self.assertEquals(u'30', binding.schutzfrist)
        self.assertEquals('unprotected', binding.klassifizierungskategorie)
        self.assertEquals(1, binding.datenschutz)
        self.assertEquals('private', binding.oeffentlichkeitsstatus)
        self.assertEquals(u'Enth\xe4lt sch\xfctzenswerte Daten.',
                          binding.oeffentlichkeitsstatusBegruendung)
Ejemplo n.º 17
0
    def binding(self):
        d = ech0147t0.dossierType()
        d.uuid = self.obj.UID()

        wftool = getToolByName(self.obj, "portal_workflow")
        status = wftool.getInfoFor(self.obj, 'review_state')
        d.status = DOSSIER_STATUS_MAPPING[status]

        d.titles = ech0039.titlesType()
        d.titles.append(
            ech0039.titleType(self.obj.Title().decode('utf8'), lang=u'DE'))

        c_obj = IClassification(self.obj)
        d.classification = ech0039.classificationType(
            CLASSIFICATION_MAPPING[c_obj.classification])
        d.hasPrivacyProtection = PRIVACY_LAYER_MAPPING[c_obj.privacy_layer]

        d.caseReferenceLocalId = IReferenceNumber(self.obj).get_number()

        dossier_obj = IDossier(self.obj)
        d.openingDate = dossier_obj.start

        if dossier_obj.keywords:
            d.keywords = ech0039.keywordsType()
            for keyword in dossier_obj.keywords:
                d.keywords.append(ech0039.keywordType(keyword, lang=u'DE'))

        if self.dossiers:
            d.dossiers = ech0147t0.dossiersType()
            for dossier in self.dossiers:
                d.dossiers.append(dossier.binding())

        if self.documents:
            d.documents = ech0147t0.documentsType()
            for document in self.documents:
                d.documents.append(document.binding())

        # Optional, currently not supported properties
        d.openToThePublic = None
        d.comments = None
        d.links = None
        d.folders = None
        d.addresses = None
        d.applicationCustom = None

        return d
Ejemplo n.º 18
0
    def binding(self):
        d = ech0147t0.documentType()
        d.uuid = self.obj.UID()
        d.titles = ech0039.titlesType()
        d.titles.append(
            ech0039.titleType(self.obj.Title().decode('utf8'), lang=u'DE'))
        d.status = u'undefined'

        d.files = ech0147t0.filesType()
        f = ech0147t0.fileType()
        f.pathFileName = self.path
        f.mimeType = self.obj.file.contentType
        f.hashCodeAlgorithm, f.hashCode = file_checksum(self.blobpath)
        d.files.append(f)

        c_obj = IClassification(self.obj)
        d.classification = ech0039.classificationType(
            CLASSIFICATION_MAPPING[c_obj.classification])
        d.hasPrivacyProtection = PRIVACY_LAYER_MAPPING[c_obj.privacy_layer]
        d.openToThePublic = PUBLIC_TRIAL_MAPPING[c_obj.public_trial]

        md = IDocumentMetadata(self.obj)
        d.documentKind = md.document_type
        d.openingDate = md.document_date
        d.ourRecordReference = md.foreign_reference
        d.owner = md.document_author

        if md.keywords:
            d.keywords = ech0039.keywordsType()
            for keyword in md.keywords:
                d.keywords.append(ech0039.keywordType(keyword, lang=u'DE'))

        # Optional, currently not supported properties
        d.signer = None
        d.comments = None
        d.isLeadingDocument = None
        d.sortOrder = None
        d.applicationCustom = None

        return d
Ejemplo n.º 19
0
def public_trial(obj):
    public_trial = IClassification(obj).public_trial
    if public_trial:
        return public_trial

    return ''