Ejemplo n.º 1
0
    def wrapper(request, *args, **kwargs):
        file_id = kwargs['file_id']

        if file_id == "None":
            return func(request, *args, **kwargs)

        file_object = get_object_or_404(core_models.File, pk=file_id)

        if can_view_file(request, request.user, file_object):
            return func(request, *args, **kwargs)
        else:
            messages.add_message(request, messages.ERROR, 'File is not accessible to this user.')
            deny_access(request)
Ejemplo n.º 2
0
def can_view_file(context, file_object):
    return logic.can_view_file(context['request'], context['request'].user,
                               file_object)