예제 #1
0
    def test_fields(self):
        form = UserProfileEditForm(self.profile1, self.request)
        form.update()
        fields = form.fields.keys()

        # By default should include all core fields apart from portrait
        # and recent_contacts
        for fieldname in schema.getFieldNames(IUserProfile):
            if fieldname not in ('portrait', 'recent_contacts'):
                self.assertIn(
                    fieldname, fields,
                    '{0} missing from edit form'.format(fieldname)
                )
            else:
                self.assertNotIn(
                    fieldname, fields,
                    '{0} in edit form'.format(fieldname)
                )

        # And any additional fields
        for fieldname in schema.getFieldNames(IUserProfileAdditional):
            self.assertIn(
                'IUserProfileAdditional.{0}'.format(fieldname),
                fields,
                '{0} missing from edit form'.format(fieldname)
            )
예제 #2
0
    def test_hidden_fields(self):
        api.portal.set_registry_record(
            'ploneintranet.userprofile.hidden_fields',
            (u'first_name', u'last_name', ),
        )

        form = UserProfileEditForm(self.profile1, self.request)
        form.update()
        fields = form.fields.keys()

        self.assertNotIn('first_name', fields)
        self.assertNotIn('last_name', fields)
예제 #3
0
    def test_read_only_fields(self):
        api.portal.set_registry_record(
            'ploneintranet.userprofile.read_only_fields',
            (u'first_name', u'last_name', ),
        )

        form = UserProfileEditForm(self.profile1, self.request)
        form.update()
        fields = form.fields.keys()

        self.assertIn('first_name', fields)
        self.assertIn('last_name', fields)

        self.assertEqual(form.widgets['first_name'].mode,
                         'display')
        self.assertEqual(form.widgets['last_name'].mode,
                         'display')
예제 #4
0
    def test_fields(self):
        form = UserProfileEditForm(self.profile1, self.request)
        form.update()
        fields = form.fields.keys()

        # By default should include all core fields apart from portrait
        for fieldname in schema.getFieldNames(IUserProfile):
            if fieldname != 'portrait':
                self.assertIn(
                    fieldname, fields,
                    '{0} missing from edit form'.format(fieldname)
                )

        # And any additional fields
        for fieldname in schema.getFieldNames(IUserProfileAdditional):
            self.assertIn(
                'IUserProfileAdditional.{0}'.format(fieldname),
                fields,
                '{0} missing from edit form'.format(fieldname)
            )