def copy_permissions(original, duplicate, model, apps):
    """Copy permissions from original object to it's duplicate."""
    UserObjectPermission = apps.get_model('guardian', 'UserObjectPermission')
    GroupObjectPermission = apps.get_model('guardian', 'GroupObjectPermission')
    kwargs = {'permission__content_type__model': model, 'object_pk':
        original.id}
    for perm in UserObjectPermission.objects.filter(**kwargs):
        perm.id = None
        perm.object_pk = duplicate.id
        perm.content_object = duplicate
        perm.save(force_insert=True)
    for perm in GroupObjectPermission.objects.filter(**kwargs):
        perm.id = None
        perm.object_pk = duplicate.id
        perm.content_object = duplicate
        perm.save(force_insert=True)
