예제 #1
0
def documents(request):
    if request.user.is_authenticated:
        extra_context = {}
        ppath = request.GET.get('path', '')
        ppath = urllib.unquote(ppath.rstrip('/'))
        path = clean_path(ppath)
        if path != ppath:
            path = ''

        extra_context['path'] = path

        if request.user.is_anonymous():
            extra_context['bpersonal_folder'] = False
        else:
            extra_context['bpersonal_folder'] = SiteOptions.objects.is_access_valid(
                request.user, 'zorna_personal_documents')
            extra_context['bpersonal_dir'] = 'U%s/' % request.user.pk
            get_upload_user(request.user)
        communities = get_communities(request.user)
        ao = [com.pk for com in communities if com.enable_documents]
        if ao:
            extra_context['bcommunities_folder'] = True
        else:
            extra_context['bcommunities_folder'] = False
        ao = get_allowed_shared_folders(
            request.user, ['reader', 'manager', 'writer'])
        if ao:
            extra_context['bshared_folder'] = True
        else:
            extra_context['bshared_folder'] = False

        if path and path[0] == 'U':
            extra_context['dir_url'] = reverse('personal_folder_content')
            extra_context['bshared_folder'] = False
            extra_context['bcommunities_folder'] = False
        elif path and path[0] == 'F':
            extra_context['dir_url'] = reverse('shared_folder_content')
            extra_context['bpersonal_folder'] = False
            extra_context['bcommunities_folder'] = False
        elif path and path[0] == 'C':
            extra_context['dir_url'] = reverse('communities_folder_content')
            extra_context['bshared_folder'] = False
            extra_context['bpersonal_folder'] = False
        else:
            extra_context['dir_url'] = ''

        if extra_context['bpersonal_folder'] or extra_context['bcommunities_folder'] or extra_context['bshared_folder']:
            context = RequestContext(request)
            return render_to_response('fileman/fm_home.html', extra_context, context_instance=context)
        else:
            return HttpResponseForbidden()
    else:
        return HttpResponseForbidden()
예제 #2
0
파일: views.py 프로젝트: kamni/zorna
def documents(request):
    if request.user.is_authenticated:
        extra_context = {}
        ppath = request.GET.get('path', '')
        ppath = urllib.unquote(ppath.rstrip('/'))
        path = clean_path(ppath)
        if path != ppath:
            path = ''

        extra_context['path'] = path

        if request.user.is_anonymous():
            extra_context['bpersonal_folder'] = False
        else:
            extra_context['bpersonal_folder'] = SiteOptions.objects.is_access_valid(
                request.user, 'zorna_personal_documents')
            extra_context['bpersonal_dir'] = 'U%s/' % request.user.pk
            get_upload_user(request.user)
        communities = get_communities(request.user)
        ao = [com.pk for com in communities if com.enable_documents]
        if ao:
            extra_context['bcommunities_folder'] = True
        else:
            extra_context['bcommunities_folder'] = False
        ao = get_allowed_shared_folders(
            request.user, ['reader', 'manager', 'writer'])
        if ao:
            extra_context['bshared_folder'] = True
        else:
            extra_context['bshared_folder'] = False

        if path and path[0] == 'U':
            extra_context['dir_url'] = reverse('personal_folder_content')
            extra_context['bshared_folder'] = False
            extra_context['bcommunities_folder'] = False
        elif path and path[0] == 'F':
            extra_context['dir_url'] = reverse('shared_folder_content')
            extra_context['bpersonal_folder'] = False
            extra_context['bcommunities_folder'] = False
        elif path and path[0] == 'C':
            extra_context['dir_url'] = reverse('communities_folder_content')
            extra_context['bshared_folder'] = False
            extra_context['bpersonal_folder'] = False
        else:
            extra_context['dir_url'] = ''

        if extra_context['bpersonal_folder'] or extra_context['bcommunities_folder'] or extra_context['bshared_folder']:
            context = RequestContext(request)
            return render_to_response('fileman/fm_home.html', extra_context, context_instance=context)
        else:
            return HttpResponseForbidden()
    else:
        return HttpResponseForbidden()
예제 #3
0
파일: api.py 프로젝트: somair/zorna
def get_user_calendars(user, permissions=['viewer']):
    allowed_objects = set([])
    for perm in permissions:
        objects = get_allowed_objects(user, ZornaCalendar, perm)
        allowed_objects = allowed_objects.union(set(objects))
    b_personal_calendar = SiteOptions.objects.is_access_valid(
        user, 'zorna_personal_calendar')
    if b_personal_calendar:
        pcal = get_personal_calendar(User.objects.get(pk=user.pk))
        allowed_objects.update([pcal.pk])

    communities = get_communities(user)
    for com in communities:
        if com.enable_calendar:
            cal = com.get_calendar()
            allowed_objects.update([cal.pk])

    allowed_objects = ZornaCalendar.objects.filter(pk__in=allowed_objects)
    return allowed_objects