Пример #1
0
def create_language_permissions_and_group(sender, instance, **kwargs):
    """Create a new `Translator` role with it's required permissions.

    :param sender: Sender model
    :param instance: Language instance
    :param kwargs: kwargs e.g. created

    """
    if not kwargs.get('created'):
        return

    group = get_or_create_language_group(instance)
    create_group_permissions(group, instance)
Пример #2
0
    def test_create_group_page_permission(self):
        permissions.create_group_page_permission(self.last_page,
                                                 self.default_language)
        group = permissions.get_or_create_language_group(self.default_language)
        permissions.create_group_permissions(group, self.default_language)

        perms = Permission.objects.get(codename='delete_translatablepage')
        self.editor_user.user_permissions.add(perms)

        permission = permissions.TranslatableUserPagePermissionsProxy(
            self.editor_user)
        # Only Super user can delete, Though permission has given
        assert not permission.for_page(self.last_page).can_delete()