def smart_link_condition_delete(request, smart_link_condition_pk):
    smart_link_condition = get_object_or_404(
        SmartLinkCondition, pk=smart_link_condition_pk
    )

    try:
        Permission.check_permissions(
            request.user, (permission_smart_link_edit,)
        )
    except PermissionDenied:
        AccessControlList.objects.check_access(
            (permission_smart_link_edit,), request.user,
            smart_link_condition.smart_link
        )

    next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))))
    previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))))

    if request.method == 'POST':
        try:
            smart_link_condition.delete()
            messages.success(
                request, _(
                    'Smart link condition: "%s" deleted successfully.'
                ) % smart_link_condition
            )
        except Exception as exception:
            messages.error(
                request, _(
                    'Error deleting smart link condition: '
                    '%(smart_link_condition)s; %(exception)s.'
                ) % {
                    'smart_link_condition': smart_link_condition,
                    'exception': exception
                }
            )
        return HttpResponseRedirect(next)

    return render_to_response('appearance/generic_confirm.html', {
        'condition': smart_link_condition,
        'delete_view': True,
        'navigation_object_list': ('object', 'condition'),
        'next': next,
        'object': smart_link_condition.smart_link,
        'previous': previous,
        'title': _('Delete smart link condition: "%s"?') % smart_link_condition,
    }, context_instance=RequestContext(request))
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/linking/views.py/smart_link_condition_delete/original