def test_adding(self, browser):
        browser.login().open(self.portal)
        factoriesmenu.add('Template Dossier')
        browser.fill({'Title': 'Templates',
                      'Responsible': TEST_USER_ID}).save()

        self.assertEquals('tabbed_view', plone.view())
Exemplo n.º 2
0
    def test_dossier_from_template(self, browser):
        toggle_feature(IDossierTemplateSettings, enabled=True)

        root = create(Builder('repository_root'))
        leaf_node = create(Builder('repository').within(root))

        create(Builder("dossiertemplate")
               .titled(DOSSIER_REQUIREDS['title']))

        with freeze(FROZEN_NOW):
            browser.login().open(leaf_node)
            factoriesmenu.add(u'Dossier with template')

            token = browser.css(
                'input[name="form.widgets.template"]').first.attrib.get('value')

            browser.fill({'form.widgets.template': token}).submit()
            browser.click_on('Save')
            dossier = browser.context

        persisted_values = get_persisted_values_for_obj(dossier)
        expected = self.get_z3c_form_defaults()

        # XXX: Don't know why this happens
        expected['public_trial_statement'] = None

        self.assertDictEqual(expected, persisted_values)
Exemplo n.º 3
0
 def test_custody_period_default_choices(self, browser):
     browser.login().open()
     factoriesmenu.add(u'Business Case Dossier')
     form_field = browser.find('Custody period (years)')
     self.assertEqual(
         ['0', '30', '100', '150'],
         form_field.options_values)
Exemplo n.º 4
0
    def test_all_team_members_are_notified_for_a_new_team_task(self, browser):
        self.login(self.regular_user, browser)

        with self.observe_children(self.dossier) as children:
            browser.open(self.dossier)
            factoriesmenu.add('Task')
            browser.fill({'Title': u'Team Task', 'Task Type': 'To comment'})
            form = browser.find_form_by_field('Responsible')
            form.find_widget('Responsible').fill('team:2')
            browser.find('Save').click()
            create_session().flush()

        task = children.get('added').pop()
        center = notification_center()
        # Assign watchers to a local variable in order to avoid having
        # a "stale association proxy" when the GC collects within the
        # list comprehension.
        watchers = center.get_watchers(task)
        self.assertEquals(
            [u'team:2', u'kathi.barfuss'],
            [watcher.actorid for watcher in watchers]
        )

        activity = Activity.query.one()

        self.assertEquals(
            [u'franzi.muller', u'herbert.jager'],
            [note.userid for note in activity.notifications])
Exemplo n.º 5
0
    def test_propagation_is_depth_limited(self, browser):
        """Propagation of archival value is depth limited to 2 levels.
        Not sure why this was implemented this way, but here we test for it.
        """
        self.login(self.administrator, browser=browser)

        # Start with a loose archival value
        self.set_archival_value(self.branch_repofolder, u'unchecked')
        repofolder2 = create(Builder('repository').within(self.branch_repofolder))
        repofolder3 = create(Builder('repository').within(repofolder2))

        browser.open(repofolder3)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        dossier = browser.context

        value = self.get_archival_value(dossier)
        # Dossier should have inherited archival value from repofolder2
        self.assertEqual(u'unchecked', value)

        browser.open(self.branch_repofolder, view='edit')
        # Make archival value more strict on top level repofolder
        browser.fill({'Archival value': 'prompt'}).save()

        # Stricter archival value should have propagated to repofolder2, but
        # not dossier (because of depth limitation)
        self.assertEqual(u'prompt', self.get_archival_value(repofolder2))
        self.assertEqual(u'unchecked', self.get_archival_value(dossier))
Exemplo n.º 6
0
    def test_propagation_is_depth_limited(self, browser):
        """Propagation of custody period is depth limited to 2 levels.
        Not sure why this was implemented this way, but here we test for it.
        """
        # Start with a short custody period
        self.set_custody_period(self.repofolder, 30)
        repofolder2 = create(Builder('repository').within(self.repofolder))
        repofolder3 = create(Builder('repository').within(repofolder2))

        browser.login().open(repofolder3)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        dossier = browser.context

        value = self.get_custody_period(dossier)
        # Dossier should have inherited custody period from repofolder2
        self.assertEqual(30, value)

        browser.open(self.repofolder, view='edit')
        # Increase custody period on top level repofolder
        browser.fill({'Custody period (years)': '100'}).save()
        transaction.commit()

        # Increased custody period should have propagated to repofolder2, but
        # not dossier (because of depth limitation)
        self.assertEqual(100, self.get_custody_period(repofolder2))
        self.assertEqual(30, self.get_custody_period(dossier))
    def test_visible_fields_in_forms(self, browser):
        """Some fields should only be displayed when the word feature is
        enabled.
        Therefore we test the appearance of all fields.
        """
        fields = ['Title',
                  'Committeeresponsible',
                  'Protocol header template',
                  'Protocol suffix template',
                  'Agenda item header template for the protocol',
                  'Agenda item suffix template for the protocol',
                  'Excerpt header template',
                  'Excerpt suffix template',
                  'Agendaitem list template',
                  'Table of contents template',
                  'Linked repository folder',
                  'Ad hoc agenda item template',
                  'Paragraph template',
                  'Allowed proposal templates']
        with self.login(self.administrator, browser):
            browser.open(self.committee_container)
            factoriesmenu.add('Committee')
            self.assertEquals(
                fields,
                map(methodcaller('normalized_text', recursive=False),
                    browser.css('form#form > div.field > label')))

        with self.login(self.committee_responsible, browser):
            browser.open(self.committee, view='edit')
            self.assertEquals(
                fields,
                map(methodcaller('normalized_text', recursive=False),
                    browser.css('form#form > div.field > label')))
Exemplo n.º 8
0
    def test_change_propagates_to_children(self, browser):
        self.login(self.administrator, browser=browser)

        set_retention_period_restricted(True)

        # Start with a long retention period
        self.set_retention_period(self.branch_repofolder, 25)
        self.set_retention_period(self.leaf_repofolder, 25)

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        dossier = browser.context

        value = self.get_retention_period(dossier)
        # Dossier should have inherited retention period from repofolder
        self.assertEqual(25, value)

        browser.open(self.leaf_repofolder, view='edit')
        # Reduce retention period
        browser.fill({'Retention period (years)': '15'}).save()

        value = self.get_retention_period(dossier)
        # Reduced retention period should have propagated to dossier
        self.assertEqual(15, value)
Exemplo n.º 9
0
    def test_propagation_is_depth_limited(self, browser):
        """Propagation of retention period is depth limited to 2 levels.
        Not sure why this was implemented this way, but here we test for it.
        """
        self.login(self.administrator, browser=browser)

        set_retention_period_restricted(True)
        # Start with a long retention period
        self.set_retention_period(self.branch_repofolder, 25)
        repofolder2 = create(Builder('repository').within(self.branch_repofolder))
        repofolder3 = create(Builder('repository').within(repofolder2))

        browser.open(repofolder3)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        dossier = browser.context

        value = self.get_retention_period(dossier)
        # Dossier should have inherited retention period from repofolder2
        self.assertEqual(25, value)

        browser.open(self.branch_repofolder, view='edit')
        # Reduce retention period on top level repofolder
        browser.fill({'Retention period (years)': '15'}).save()

        # Reduced retention period should have propagated to repofolder2, but
        # not dossier (because of depth limitation)
        self.assertEqual(15, self.get_retention_period(repofolder2))
        self.assertEqual(25, self.get_retention_period(dossier))
Exemplo n.º 10
0
    def test_configure_trigger_on_news_folder(self, browser):
        self.grant('Manager')
        browser.login().open()
        factoriesmenu.add('News Folder')
        browser.fill(
            {'Title': 'News Folder',
             'Mopage trigger enabled': True,
             'Mopage trigger URL': (
                 'https://*****:*****@xml.mopage.ch/infoservice/xml.php'),
             'Mopage data endpoint URL (Plone)': (
                 'http://nohost/plone/news-folder/mopage.news.xml'
                 '?partnerid=123&imported=456')}).save()

        statusmessages.assert_no_error_messages()

        mopage_trigger = IPublisherMopageTrigger(browser.context)
        self.assertTrue(mopage_trigger.is_enabled())

        trigger_url = mopage_trigger.build_trigger_url()
        self.assertEquals('https://*****:*****@xml.mopage.ch/infoservice/xml.php'
                          '?url=http%3A%2F%2Fnohost%2Fplone%2Fnews-folder'
                          '%2Fmopage.news.xml%3Fpartnerid%3D123%26imported%3D456',
                          trigger_url)

        params =  urlparse.parse_qs(urlparse.urlparse(trigger_url)[4])['url']
        self.assertEquals(['http://nohost/plone/news-folder/'
                           'mopage.news.xml?partnerid=123&imported=456'],
                          params)
Exemplo n.º 11
0
    def test_document_from_dossiertemplate(self, browser):
        toggle_feature(IDossierTemplateSettings, enabled=True)

        root = create(Builder('repository_root'))
        leaf_node = create(Builder('repository').within(root))
        template = create(Builder("dossiertemplate")
                          .titled(DOSSIER_REQUIREDS['title']))
        create(Builder('document')
               .titled(DOCUMENT_REQUIREDS['title'])
               .within(template)
               .with_dummy_content())

        with freeze(FROZEN_NOW):
            browser.login().open(leaf_node)
            factoriesmenu.add(u'Dossier with template')
            token = browser.css(
                'input[name="form.widgets.template"]').first.attrib.get('value')
            browser.fill({'form.widgets.template': token}).submit()
            browser.click_on('Save')

            doc = browser.context.listFolderContents()[0]

        persisted_values = get_persisted_values_for_obj(doc)
        expected = self.get_type_defaults()

        expected['digitally_available'] = True
        expected['file'] = doc.file

        self.assertDictEqual(expected, persisted_values)
Exemplo n.º 12
0
    def test_propagation_is_depth_limited(self, browser):
        """Propagation of privacy layer is depth limited to 2 levels.
        Not sure why this was implemented this way, but here we test for it.
        """
        # Start with a loose privacy layer
        self.set_privacy_layer(self.repofolder, u'privacy_layer_no')
        repofolder2 = create(Builder('repository').within(self.repofolder))
        repofolder3 = create(Builder('repository').within(repofolder2))

        browser.login().open(repofolder3)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        dossier = browser.context

        value = self.get_privacy_layer(dossier)
        # Dossier should have inherited privacy layer from repofolder2
        self.assertEqual(u'privacy_layer_no', value)

        browser.open(self.repofolder, view='edit')
        # Reduce privacy layer on top level repofolder
        browser.fill({'Privacy layer': 'privacy_layer_yes'}).save()
        transaction.commit()

        # Reduced privacy layer should have propagated to repofolder2, but
        # not dossier (because of depth limitation)
        self.assertEqual(
            u'privacy_layer_yes', self.get_privacy_layer(repofolder2))
        self.assertEqual(
            u'privacy_layer_no', self.get_privacy_layer(dossier))
Exemplo n.º 13
0
    def test_subdossier_from_template(self, browser):
        toggle_feature(IDossierTemplateSettings, enabled=True)

        root = create(Builder('repository_root'))
        leaf_node = create(Builder('repository').within(root))
        template = create(Builder("dossiertemplate")
                          .titled(u'Main template'))
        subdossier_template = create(Builder("dossiertemplate")
                                     .within(template)
                                     .titled(DOSSIER_REQUIREDS['title']))

        with freeze(FROZEN_NOW):
            browser.login().open(leaf_node)
            factoriesmenu.add(u'Dossier with template')
            token = browser.css(
                'input[name="form.widgets.template"]').first.attrib.get('value')
            browser.fill({'form.widgets.template': token}).submit()
            browser.click_on('Save')

            subdossier = browser.context.listFolderContents()[0]

        persisted_values = get_persisted_values_for_obj(subdossier)
        expected = self.get_type_defaults()

        # Because the main-dossier is made through the ++add++-form and the
        # subdossier is created trough the object-creator with some attribute
        # inheritance, we get a mix of z3c_form_defaults and the type_defaults.
        # A subdossier has the type_defaults with addiional form_defaults
        expected.update(self.form_defaults)

        self.assertDictEqual(expected, persisted_values)
Exemplo n.º 14
0
 def test_oneoffixx_form_errors_on_missing_config(self, browser):
     self.login(self.regular_user, browser)
     browser.open(self.dossier)
     browser.exception_bubbling = True
     # Do note this will not fail if you actually do have the config file!
     with self.assertRaises(OneoffixxConfigurationException):
         factoriesmenu.add('document_with_oneoffixx_template')
Exemplo n.º 15
0
    def test_document_creation_from_oneoffixx_template_creates_shadow_doc(self, browser):
        self.login(self.regular_user, browser)
        browser.open(self.dossier)
        factoriesmenu.add('document_with_oneoffixx_template')

        node = browser.css("#form-widgets-template-2574d08d-95ea-4639-beab-3103fe4c3bc7").first
        browser.fill({'Title': 'A doc'})
        browser.fill({'Template': node.get("title")})
        browser.find('Save').click()

        document = browser.context
        self.assertEqual(
            'document-state-shadow', api.content.get_state(document))
        self.assertTrue(document.is_shadow_document())

        annotations = IAnnotations(document)
        self.assertEqual(self.template_word['id'], annotations['template-id'])
        self.assertEqual(
            self.template_word['languages'], annotations['languages'])
        self.assertIn(
            self.template_word['localizedName'], annotations['filename'])
        self.assertEqual('3 Example Word file.docx', annotations['filename'])
        self.assertEqual(
            'application/vnd.openxmlformats-officedocument.wordprocessingml'
            '.document',
            annotations['content-type'],
        )

        whitelisted_content_types = [
            template['content-type']
            for template in whitelisted_template_types.values()
        ]
        self.assertIn(annotations['content-type'], whitelisted_content_types)
    def test_adding_paragraphtemplate_cannot_be_added_to_the_templatefolder(self, browser):
        self.login(self.administrator, browser=browser)

        browser.open(self.templates)

        with self.assertRaises(ValueError):
            factoriesmenu.add('Paragraph Template')
    def test_creating_a_new_graphicblock(self, browser):
        book = create(Builder('book').titled('The book'))
        chapter = create(Builder('chapter').titled('The chapter').within(book))

        browser.login().open(chapter)
        factoriesmenu.add('Graphic Block')

        with asset('diagram.pdf') as diagram:
            browser.fill({'Title': 'The Graphicblock',
                          'PDF document': diagram}).save()

        self.assertEquals(chapter, browser.context,
                          'Expected redirect to chapter view after savin')

        image = browser.css('.BlockOverallWrapper.graphicblock'
                            ' .simplelayout-block-wrapper img').first

        self.assertDictContainsSubset(
            {'height': '1228',
             'width': '868'},
            image.attrib)

        browser.open(image.attrib['src'])
        self.assertEquals('image/jpeg',
                          browser.headers.get('Content-Type'))
Exemplo n.º 18
0
    def test_adding_fails_when_no_factoriesmenu_visible(self, browser):
        browser.open()
        with self.assertRaises(ValueError) as cm:
            factoriesmenu.add('Folder')

        self.assertEquals('Cannot add "Folder": no factories menu visible.',
                          str(cm.exception))
Exemplo n.º 19
0
    def test_create_a_task_for_every_selected_person_with_one_orgunit(self, browser):
        user = create(Builder('ogds_user')
                      .assign_to_org_units([self.org_unit])
                      .having(userid='some.user'))

        dossier = create(Builder('dossier'))

        responsible_users = [
            self.get_org_unit().id() + ':' + TEST_USER_ID,
            self.get_org_unit().id() + ':' + user.userid
        ]

        browser.login().visit(dossier)
        factoriesmenu.add('Task')
        browser.fill({'Title': 'Task title',
                      'Task Type': 'To comment'})

        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill(responsible_users)

        browser.find('Save').click()

        tasks = dossier.objectValues()
        self.assertEquals(2, len(tasks), 'Expect 2 tasks')
        self.assertEquals(TEST_USER_ID, tasks[0].responsible)
        self.assertEquals('client1', tasks[0].responsible_client)
        self.assertEquals(user.userid, tasks[1].responsible)
        self.assertEquals('client1', tasks[1].responsible_client)

        activities = Activity.query.all()
        self.assertEquals(2, len(activities))
        self.assertEquals(u'task-added', activities[0].kind)
        self.assertEquals(TEST_USER_ID, activities[0].actor_id)
        self.assertEquals(u'task-added', activities[1].kind)
        self.assertEquals(TEST_USER_ID, activities[1].actor_id)
Exemplo n.º 20
0
    def test_responsible_client_for_multiple_orgunits(self, browser):
        create(Builder('org_unit')
               .with_default_groups()
               .id('client2')
               .having(title='Client2',
                       admin_unit=self.admin_unit))

        dossier = create(Builder('dossier'))

        browser.login().visit(dossier)
        factoriesmenu.add('Task')

        browser.fill({'Title': 'Task title',
                      'Task Type': 'To comment'})
        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill(
            self.get_org_unit().id() + ':' + TEST_USER_ID)
        browser.find('Save').click()

        task = dossier.objectValues()[0]
        self.assertEquals(
            'client1',
            task.responsible_client,
            'The client should be stored after submitting the form')
        self.assertEquals(
            TEST_USER_ID,
            task.responsible,
            'The user should be stored after submitting the form')
Exemplo n.º 21
0
 def test_privacy_layer_default_choices(self, browser):
     browser.login().open(self.repofolder)
     factoriesmenu.add(u'Business Case Dossier')
     form_field = browser.find('Privacy layer')
     self.assertEqual(
         ['privacy_layer_no', 'privacy_layer_yes'],
         form_field.options_values)
Exemplo n.º 22
0
 def test_public_trial_default_choices(self, browser):
     browser.login().open(self.dossier)
     factoriesmenu.add(u'Document')
     form_field = browser.find('Public Trial')
     self.assertEqual(
         ['unchecked', 'public', 'limited-public', 'private'],
         form_field.options_values)
Exemplo n.º 23
0
    def test_propagation_is_depth_limited(self, browser):
        """Propagation of classification is depth limited to 2 levels.
        Not sure why this was implemented this way, but here we test for it.
        """
        # Start with a loose classification
        self.set_classification(self.repofolder, u'unprotected')
        repofolder2 = create(Builder('repository').within(self.repofolder))
        repofolder3 = create(Builder('repository').within(repofolder2))

        browser.login().open(repofolder3)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        dossier = browser.context

        value = self.get_classification(dossier)
        # Dossier should have inherited classification from repofolder2
        self.assertEqual(u'unprotected', value)

        browser.open(self.repofolder, view='edit')
        # Make classification more strict on top level repofolder
        browser.fill({'Classification': 'confidential'}).save()
        transaction.commit()

        # Stricter classification should have propagated to repofolder2, but
        # not dossier (because of depth limitation)
        self.assertEqual(u'confidential', self.get_classification(repofolder2))
        self.assertEqual(u'unprotected', self.get_classification(dossier))
 def test_text_is_used_as_title(self, browser):
     browser.login().open(self.contentpage)
     factoriesmenu.add('TextBlock')
     browser.fill({'Text': '<p>Hello World</p>'}).save()
     statusmessages.assert_no_error_messages()
     block = self.contentpage.objectValues()[0]
     self.assertEquals('Hello World', block.Title())
Exemplo n.º 25
0
 def test_classification_default_choices(self, browser):
     browser.login().open(self.repofolder)
     factoriesmenu.add(u'Business Case Dossier')
     form_field = browser.find('Classification')
     self.assertEqual(
         ['unprotected', 'confidential', 'classified'],
         form_field.options_values)
Exemplo n.º 26
0
    def test_repository_folder(self, browser):
        self.grant('Manager')

        browser.login().open()
        factoriesmenu.add('RepositoryRoot')
        browser.fill({'Title': 'Registraturplan'}).save()
        self.assertEquals(('tabbed_view', 'opengever-repository-repositoryroot'),
                          plone.view_and_portal_type())
        registraturplan = browser.context

        # This will cause a WRITE to registraturplan the first time it is accessed.
        browser.open(registraturplan, view='++add++opengever.repository.repositoryfolder',
                     data={'_authenticator': createToken()})
        browser.fill({'Title': 'Accounting'}).save()
        self.assertEquals(('tabbed_view', 'opengever-repository-repositoryfolder'),
                          plone.view_and_portal_type())
        accounting = browser.context
        self.assertEquals(u'1', IReferenceNumberPrefix(accounting).reference_number_prefix)
        self.assertEquals(('test_user_1_',), accounting.listCreators())

        browser.open(registraturplan)
        factoriesmenu.add('RepositoryFolder')
        browser.fill({'Title': 'Custody'}).save()
        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_add_recursive_documents_and_subdossiers(self, browser):
        self.login(self.administrator, browser=browser)

        create(Builder('document')
               .titled('Document 1')
               .within(self.subdossiertemplate)
               .with_dummy_content())

        create(Builder("dossiertemplate")
               .within(self.subdossiertemplate)
               .titled(u'Anfragen 2017'))

        self.login(self.regular_user, browser=browser)
        browser.open(self.leaf_repofolder)
        factoriesmenu.add('Dossier with template')
        token = browser.css(
            'input[name="form.widgets.template"]').first.attrib.get('value')
        browser.fill({'form.widgets.template': token}).submit()
        browser.click_on('Save')

        dossier = browser.context

        self.assertEqual('Bauvorhaben klein', dossier.title)
        self.assertEqual(
            [u'Anfragen'],
            [obj.title for obj in dossier.listFolderContents()],
            "The content of the root-dossier is not correct."
            )

        subdossier = dossier.listFolderContents()[0]
        self.assertEqual(
            ['Document 1', u'Anfragen 2017'],
            [obj.title for obj in subdossier.listFolderContents()],
            "The content of the subdossiertemplate is not correct"
        )
    def test_dossiertemplate_restrict_keywords(self, browser):
        self.login(self.regular_user, browser=browser)

        self.dossiertemplate.restrict_keywords = True
        self.dossiertemplate.predefined_keywords = True

        browser.open(self.leaf_repofolder)
        factoriesmenu.add('Dossier with template')

        token = browser.css(
            'input[name="form.widgets.template"]').first.attrib.get('value')

        browser.fill({'form.widgets.template': token}).submit()
        keywords = browser.find_field_by_text(u'Keywords')

        # The field is there but not visible.
        # It's not really possible to change the behavior of a widget in
        # the update method of a group form. So many update/updateWidget
        # happen in this process.
        # new = browser.css('#' + keywords.attrib['id'] + '_new')
        # self.assertFalse(new, 'It should not be possible to add new terms')

        self.assertItemsEqual([u'secret', u'special'], keywords.options_labels)
        browser.click_on('Save')
        self.assertItemsEqual((u'secret', u'special'),
                              IDossier(browser.context).keywords)
 def test_title_is_cropped_chars_when_filled_with_text(self, browser):
     browser.login().open(self.contentpage)
     factoriesmenu.add('TextBlock')
     browser.fill({'Text': '<p>%s</p>' % ('X' * 50)}).save()
     statusmessages.assert_no_error_messages()
     block = self.contentpage.objectValues()[0]
     self.assertEquals(29, len(block.Title()))
Exemplo n.º 30
0
 def test_retention_period_default_choices_are_unrestricted(self, browser):
     browser.login().open(self.repofolder)
     factoriesmenu.add(u'Business Case Dossier')
     form_field = browser.find('Retention period (years)')
     self.assertEqual(
         ['5', '10', '15', '20', '25'],
         form_field.options_values)
 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)
Exemplo n.º 32
0
    def test_acquired_value_is_suggested_as_default(self, browser):
        self.login(self.regular_user, browser=browser)

        self.set_privacy_layer(self.leaf_repofolder, u'privacy_layer_yes')

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')

        form_field = browser.find('Privacy layer')

        self.assertEqual('privacy_layer_yes', form_field.value)
        # Default listed first
        self.assertEqual('privacy_layer_yes', form_field.options_values[0])
Exemplo n.º 33
0
    def test_default_document_date_is_today(self, browser):
        self.login(self.regular_user, browser)

        now = datetime.now()
        today = now.date()
        browser.open(self.dossier)

        with freeze(now):
            factoriesmenu.add('Document')
            browser.fill({'Title': u'My Document'}).save()

        document = self.dossier['document-41']
        self.assertEqual(today, document.document_date)
Exemplo n.º 34
0
 def test_add_notice(self, browser):
     board, category = self._create_content()
     browser.login().visit(category)
     factoriesmenu.add('Notice')
     browser.fill({
         'Title': u'This is a Notice',
         'Price': '100',
         'Terms and Conditions': True,
         'E-Mail': u'*****@*****.**',
         'Text': u'Anything',
     })
     browser.find_button_by_label('Save').click()
     self.assertEquals(u'This is a Notice', plone.first_heading())
    def test_uploading_non_docx_files_is_not_allowed(self, browser):
        vorlagen = create(Builder('templatefolder').titled(u'Vorlagen'))
        browser.login().open(vorlagen)
        factoriesmenu.add('Proposal Template')

        browser.fill({
            'Title': u'Geb\xfchren',
            'File': ('DATA', 'Wrong.txt', 'text/plain')
        }).save()
        statusmessages.assert_message('There were some errors.')
        self.assertEquals(
            ['Only word files (.docx) can be added here.'],
            browser.css('#formfield-form-widgets-file .error').text)
Exemplo n.º 36
0
    def test_add_recursive_documents_and_subdossiers_local_roles_block_not_set(
            self, browser):
        self.login(self.regular_user, browser)

        browser.open(self.leaf_repofolder)
        factoriesmenu.add('Dossier with template')
        token = browser.css(
            'input[name="form.widgets.template"]').first.attrib.get('value')
        browser.fill({'form.widgets.template': token}).submit()
        browser.click_on('Save')

        subdossier = browser.context.listFolderContents()[1]
        self.assertFalse(hasattr(subdossier, '__ac_local_roles_block__'))
    def test_label_is_renamed_to_title_for_sites_with_only_one_active_language(
            self, browser):
        self.login(self.manager, browser=browser)

        self.lang_tool.supported_langs = ['fr-ch']

        browser.open(self.portal)
        factoriesmenu.add('RepositoryRoot')

        self.assertEquals(
            'Title',
            browser.css('label[for=form-widgets-ITranslatedTitle-title_fr]').
            first.text)
Exemplo n.º 38
0
    def test_vocab_is_restricted_if_indicated_by_aq_value(self, browser):
        self.login(self.administrator, browser=browser)

        set_retention_period_restricted(True)

        self.set_retention_period(self.leaf_repofolder, 15)

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')

        form_field = browser.find('Retention period (years)')
        self.assertSetEqual(set(['5', '10', '15']),
                            set(form_field.options_values))
    def test_add_collection_block(self, browser):
        browser.login().visit(self.page)
        factoriesmenu.add('Collection block')
        title = u'A collection block'
        browser.fill({'Title': title, 'Show title': True})
        browser.find_button_by_label('Save').click()
        self.assertTrue(
            len(browser.css('.ftw-collectionblock-collectionblock')),
            'Expect on collection block')

        # Since there is no query configured, there should be no result
        self.assertEquals(u'No content available',
                          browser.css('.sl-block-content p').first.text)
Exemplo n.º 40
0
    def test_acquired_value_is_suggested_as_default(self, browser):
        self.login(self.administrator, browser=browser)

        self.set_custody_period(self.leaf_repofolder, 100)

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')

        form_field = browser.find('Custody period (years)')

        self.assertEqual('100', form_field.value)
        # Default listed first
        self.assertEqual('100', form_field.options_values[0])
Exemplo n.º 41
0
    def test_acquired_value_is_suggested_as_default(self, browser):
        self.login(self.administrator, browser=browser)

        self.set_archival_value(self.leaf_repofolder, u'prompt')

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')

        form_field = browser.find('Archival value')

        self.assertEqual('prompt', form_field.value)
        # Default listed first
        self.assertEqual('prompt', form_field.options_values[0])
    def test_add_dossier_will_enable_dossier_protection(self, browser):
        self.login(self.dossier_manager, browser)

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'})
        form = browser.find_form_by_field('Reading')
        form.find_widget('Reading').fill(self.regular_user.getId())
        browser.click_on('Save')

        self.assert_local_roles(
            IProtectDossier(self.dossier).READING_ROLES,
            self.regular_user.getId(), browser.context)
Exemplo n.º 43
0
    def test_restriction_works_in_edit_form(self, browser):
        self.login(self.administrator, browser=browser)

        self.set_custody_period(self.leaf_repofolder, 100)

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()

        browser.click_on('Edit')
        form_field = browser.find('Custody period (years)')
        self.assertSetEqual(set(['100', '150']),
                            set(form_field.options_values))
Exemplo n.º 44
0
    def test_restriction_works_in_edit_form(self, browser):
        self.login(self.regular_user, browser=browser)

        self.set_classification(self.leaf_repofolder, u'confidential')

        browser.open(self.leaf_repofolder)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()

        browser.click_on('Edit')
        form_field = browser.find('Classification')
        self.assertSetEqual(set(['confidential', 'classified']),
                            set(form_field.options_values))
Exemplo n.º 45
0
    def test_supports_translated_title(self, browser):
        add_languages(['de-ch', 'fr-ch'])
        self.grant('Manager')
        browser.login().open()
        factoriesmenu.add('Template Folder')
        browser.fill({'Title (German)': u'Vorlagen',
                      'Title (French)': u'mod\xe8le'})
        browser.find('Save').click()

        browser.find(u'Français').click()
        self.assertEquals(u'mod\xe8le', browser.css('h1').first.text)

        browser.find('Deutsch').click()
        self.assertEquals(u'Vorlagen', browser.css('h1').first.text)
Exemplo n.º 46
0
    def test_portlets_are_inherited_on_sub_templatefolder(self, browser):
        templatefolder = create(Builder('templatefolder'))
        self.grant('Manager')
        add_languages(['de-ch'])
        browser.login().open(templatefolder)
        factoriesmenu.add('Template Folder')
        browser.fill({'Title': 'Templates'}).save()

        manager = getUtility(IPortletManager,
                             name=u'plone.leftcolumn',
                             context=browser.context)
        assignable = getMultiAdapter((browser.context, manager),
                                     ILocalPortletAssignmentManager)
        self.assertFalse(assignable.getBlacklistStatus(CONTEXT_CATEGORY))
Exemplo n.º 47
0
    def test_object_addable_without_delete_permission(self, browser):
        user = create(Builder('user').with_roles('Contributor'))
        self.revoke_permission('Delete portal content',
                               on=self.layer['portal'])
        transaction.commit()

        browser.login(user).open()
        factoriesmenu.add(self.folder_name)
        browser.fill({'Title': 'Foo'}).save()
        statusmessages.assert_no_error_messages()
        if IS_PLONE_5_OR_GREATER:
            self.assertEquals('listing_view', plone.view())
        else:
            self.assertEquals('folder_listing', plone.view())
Exemplo n.º 48
0
    def test_retention_period_choices_configurable_via_registry(self, browser):
        # Note: The static fallback default (5) needs to be part of this
        # value range for the default to validate
        api.portal.set_registry_record(
            'retention_period',
            interface=IRetentionPeriodRegister,
            value=[u'1', u'2', u'3', u'4', u'5', u'99'])
        transaction.commit()
        browser.login().open(self.repofolder)
        factoriesmenu.add(u'Business Case Dossier')
        form_field = browser.find('Retention period (years)')

        self.assertEqual([u'1', u'2', u'3', u'4', u'5', u'99'],
                         form_field.options_values)
    def test_both_title_fields_are_accessible_on_add_form(self, browser):
        self.grant('Manager')
        browser.login().open()
        factoriesmenu.add('RepositoryRoot')

        browser.fill({
            "Title (German)": "Ablage",
            "Title (French)": u"syst\xe8me d'ordre"
        })
        browser.find('Save').click()

        repository_root = browser.context
        self.assertEquals(u"Ablage", repository_root.title_de)
        self.assertEquals(u"syst\xe8me d'ordre", repository_root.title_fr)
Exemplo n.º 50
0
    def test_invalid_acquired_value_falls_back_to_all_choices(self, browser):
        # If vocab is supposed to be restricted, but we find an invalid value
        # via acquisition, the vocab should fall back to offering all choices
        set_retention_period_restricted(True)

        invalid_value = 7
        self.set_retention_period(self.repofolder, invalid_value)

        browser.login().open(self.repofolder)
        factoriesmenu.add(u'Business Case Dossier')

        form_field = browser.find('Retention period (years)')
        self.assertEqual(['5', '10', '15', '20', '25'],
                         form_field.options_values)
Exemplo n.º 51
0
    def test_choices_not_limited_by_parent_when_unrestricted(self, browser):
        # When is_restriced is False, choices shall not be limited by
        # an acquired value -  i.e., we always have the full set of choices
        set_retention_period_restricted(False)
        all_choices = ['5', '10', '15', '20', '25']

        for value in all_choices:
            self.set_retention_period(self.repofolder, value)
            transaction.commit()
            browser.login().open(self.repofolder)

            factoriesmenu.add(u'Business Case Dossier')
            form_field = browser.find('Retention period (years)')
            self.assertEqual(all_choices, form_field.options_values)
Exemplo n.º 52
0
    def test_z3c_add_form(self, browser):
        with freeze(FROZEN_NOW):
            browser.login().open(self.contactfolder)
            factoriesmenu.add(u'Contact')
            browser.fill({
                u'Firstname': CONTACT_REQUIREDS['firstname'],
                u'Lastname': CONTACT_REQUIREDS['lastname']
            }).save()
            contact = browser.context

        persisted_values = get_persisted_values_for_obj(contact)
        expected = self.get_z3c_form_defaults()

        self.assertDictEqual(expected, persisted_values)
Exemplo n.º 53
0
    def test_restriction_works_in_edit_form(self, browser):
        set_retention_period_restricted(True)

        self.set_retention_period(self.repofolder, 15)

        browser.login().open(self.repofolder)
        factoriesmenu.add(u'Business Case Dossier')
        browser.fill({'Title': 'My Dossier'}).save()
        transaction.commit()

        browser.click_on('Edit')
        form_field = browser.find('Retention period (years)')
        self.assertSetEqual(set(['5', '10', '15']),
                            set(form_field.options_values))
Exemplo n.º 54
0
    def test_preserved_as_paper_default_true(self, browser):
        browser.login()

        # registry default of True
        api.portal.set_registry_record('preserved_as_paper_default',
                                       True,
                                       interface=IDocumentSettings)
        transaction.commit()

        browser.open(self.dossier)
        factoriesmenu.add('Document')
        browser.fill({'Title': u'My Document'}).save()
        document = self.dossier['document-1']
        self.assertTrue(document.preserved_as_paper)
Exemplo n.º 55
0
    def test_z3c_add_form(self, browser):
        with freeze(FROZEN_NOW):
            browser.login().open()
            factoriesmenu.add(u'Business Case Dossier')
            browser.fill({u'Title': DOSSIER_REQUIREDS['title']}).save()
            dossier = browser.context

        persisted_values = get_persisted_values_for_obj(dossier)
        expected = self.get_z3c_form_defaults()

        # XXX: Don't know why this happens
        expected['public_trial_statement'] = None

        self.assertDictEqual(expected, persisted_values)
    def test_dossiertemplate_do_not_copy_keywords(self, browser):
        self.login(self.regular_user, browser=browser)

        self.dossiertemplate.predefined_keywords = False

        browser.open(self.leaf_repofolder)
        factoriesmenu.add('Dossier with template')

        token = browser.css(
            'input[name="form.widgets.template"]').first.attrib.get('value')
        browser.fill({'form.widgets.template': token}).submit()
        browser.click_on('Save')

        self.assertEqual((), IDossier(browser.context).keywords)
Exemplo n.º 57
0
    def test_todolist_is_addable_in_workspace(self, browser):
        self.login(self.workspace_member, browser)
        browser.visit(self.workspace)
        factoriesmenu.add('ToDo list')

        form = browser.find_form_by_field('Title')
        form.fill({'Title': u'Retrospektive'})
        form.save()

        assert_no_error_messages(browser)

        todolist = browser.context
        self.assertEqual('todolist-3', todolist.id)
        self.assertEqual('Retrospektive', todolist.title)
Exemplo n.º 58
0
    def test_supports_translated_title(self, browser):
        browser.login().open()
        factoriesmenu.add('ContactFolder')
        browser.fill({
            'Title (German)': u'Kontakte',
            'Title (French)': u'Contacts'
        })
        browser.find('Save').click()

        browser.find(u'Français').click()
        self.assertEquals(u"Contacts", browser.css('h1').first.text)

        browser.find('Deutsch').click()
        self.assertEquals("Kontakte", browser.css('h1').first.text)
    def test_using_already_used_prefix_is_not_possible(self, browser):
        self.login(self.administrator, browser)
        browser.open(self.repository_root)
        factoriesmenu.add('RepositoryFolder')
        browser.fill({
            'Title': 'Test repository',
            'Reference Prefix': '1',
        }).save()

        self.assertEquals(
            {
                'Reference Prefix':
                ['A Sibling with the same reference number is existing.']
            }, z3cform.erroneous_fields(browser.forms['form']))
    def test_z3c_add_form(self, browser):
        self.login(self.manager, browser)

        with freeze(FROZEN_NOW):
            browser.open()
            factoriesmenu.add(u'RepositoryRoot')
            browser.fill({u'Title': REPOROOT_REQUIREDS['title_de']}).save()

        reporoot = browser.context

        persisted_values = get_persisted_values_for_obj(reporoot)
        expected = self.get_z3c_form_defaults()

        self.assertDictEqual(expected, persisted_values)