'Syncs (creates) Document2Permissions based on the DocumentPermissions found for a given document.'

def _sync_permissions(self, document, document2):

    doc_permissions = DocumentPermission.objects.filter(doc=document)
    for perm in doc_permissions:
        (doc2_permission, created) = Document2Permission.objects.get_or_create(doc=document2, perms=perm.perms)
        if perm.users:
            doc2_permission.users.add(*perm.users.all())
        if perm.groups:
            doc2_permission.groups.add(*perm.groups.all())
