def smart_link_condition_create(request, smart_link_pk):
    smart_link = get_object_or_404(SmartLink, pk=smart_link_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
        )

    if request.method == 'POST':
        form = SmartLinkConditionForm(data=request.POST)
        if form.is_valid():
            new_smart_link_condition = form.save(commit=False)
            new_smart_link_condition.smart_link = smart_link
            new_smart_link_condition.save()
            messages.success(
                request, _(
                    'Smart link condition: "%s" created successfully.'
                ) % new_smart_link_condition
            )
            return HttpResponseRedirect(
                reverse(
                    'linking:smart_link_condition_list', args=(smart_link.pk,)
                )
            )
    else:
        form = SmartLinkConditionForm()

    return render_to_response('appearance/generic_form.html', {
        'form': form,
        'title': _('Add new conditions to smart link: "%s"') % smart_link,
        'object': smart_link,
    }, context_instance=RequestContext(request))
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/linking/views.py/smart_link_condition_create/original