예제 #1
0
    def get_context_data(self, **kwargs):
        kwargs['repo'] = self.repo
        kwargs['user_perm'] = self.user_perm
        kwargs['is_repo_owner'] = self.is_repo_owner(self.get_user().username,
                                                     self.repo.id)
        kwargs['current_commit'] = self.get_current_commit()
        kwargs['password_set'] = self.password_set
        kwargs['repo_size'] = self.repo_size
        kwargs['dir_list'] = self.dir_list
        kwargs['file_list'] = self.file_list
        kwargs['path'] = self.path
        kwargs['parent_dir'] = self.parent_dir
        kwargs['zipped'] = self.zipped
        kwargs['accessible_repos'] = self.get_accessible_repos()
        kwargs['applet_root'] = self.applet_root
        kwargs['groups'] = self.get_repo_shared_groups()
        kwargs['is_starred'] = self.is_starred_dir()
        kwargs['next'] = self.get_success_url()
        if len(kwargs['groups']) > 1:
            ctx = {}
            ctx['groups'] = kwargs['groups']
            repogrp_str = render_to_string("snippets/repo_group_list.html",
                                           ctx)
            kwargs['repo_group_str'] = repogrp_str
        else:
            kwargs['repo_group_str'] = ''
        kwargs['no_quota'] = self.is_no_quota()
        kwargs['max_upload_file_size'] = self.get_max_upload_file_size()
        kwargs['upload_url'] = self.get_upload_url()
        kwargs['update_url'] = self.get_update_url()
        kwargs['httpserver_root'] = self.get_httpserver_root()
        kwargs['head_id'] = self.repo.head_cmmt_id
        kwargs['protocol'] = self.protocol
        kwargs['domain'] = self.domain
        kwargs['contacts'] = self.contacts
        kwargs['fileshare'] = self.get_fileshare(\
            self.repo_id, self.request.user.username, self.path)
        kwargs['dir_shared_link'] = self.get_shared_link(kwargs['fileshare'])
        kwargs['history_limit'] = get_repo_history_limit(self.repo.id)
        if not self.repo.encrypted:
            kwargs['search_repo_id'] = self.repo.id

        return kwargs
예제 #2
0
파일: repo.py 프로젝트: bearstech/seahub
    def get_context_data(self, **kwargs):
        kwargs['repo'] = self.repo
        kwargs['user_perm'] = self.user_perm
        kwargs['is_repo_owner'] = self.is_repo_owner(self.get_user().username, self.repo.id)
        kwargs['current_commit'] = self.get_current_commit()
        kwargs['password_set'] = self.password_set
        kwargs['repo_size'] = self.repo_size
        kwargs['dir_list'] = self.dir_list
        kwargs['file_list'] = self.file_list
        kwargs['path'] = self.path
        kwargs['parent_dir'] = self.parent_dir
        kwargs['zipped'] = self.zipped
        kwargs['accessible_repos'] = self.get_accessible_repos()
        kwargs['applet_root'] = self.applet_root
        kwargs['groups'] = self.get_repo_shared_groups()
        kwargs['is_starred'] = self.is_starred_dir()
        kwargs['next'] = self.get_success_url()
        if len(kwargs['groups']) > 1:
            ctx = {}
            ctx['groups'] = kwargs['groups']
            repogrp_str = render_to_string("snippets/repo_group_list.html", ctx)
            kwargs['repo_group_str'] = repogrp_str
        else:
            kwargs['repo_group_str'] = ''
        kwargs['no_quota'] = self.is_no_quota()
        kwargs['max_upload_file_size'] = self.get_max_upload_file_size()
        kwargs['upload_url'] = self.get_upload_url()
        kwargs['update_url'] = self.get_update_url()
        kwargs['httpserver_root'] = self.get_httpserver_root()
        kwargs['head_id'] = self.repo.head_cmmt_id
        kwargs['protocol'] = self.protocol
        kwargs['domain'] = self.domain
        kwargs['contacts'] = self.contacts
        kwargs['fileshare'] = self.get_fileshare(\
            self.repo_id, self.request.user.username, self.path)
        kwargs['dir_shared_link'] = self.get_shared_link(kwargs['fileshare'])
        kwargs['history_limit'] = get_repo_history_limit(self.repo.id)
        if not self.repo.encrypted:
            kwargs['search_repo_id'] = self.repo.id

        return kwargs
예제 #3
0
def render_repo(request, repo):
    """Steps to show repo page:
    If user has permission to view repo
      If repo is encrypt and password is not set on server
        return decrypt repo page
      If repo is not encrypt or password is set on server
        Show repo direntries based on requested path
    If user does not have permission to view repo
      return permission deny page
    """
    username = request.user.username
    user_perm = check_repo_access_permission(repo.id, username)
    if user_perm is None:
        return render_to_response('repo_access_deny.html', {
            'repo': repo,
        },
                                  context_instance=RequestContext(request))

    if repo.encrypted and not is_password_set(repo.id, username):
        return render_to_response('decrypt_repo_form.html', {
                'repo': repo,
                'next': get_next_url_from_request(request) or \
                    reverse('repo', args=[repo.id])
                }, context_instance=RequestContext(request))

    # query context args
    applet_root = get_ccnetapplet_root()
    httpserver_root = get_httpserver_root()
    max_upload_file_size = MAX_UPLOAD_FILE_SIZE

    protocol = request.is_secure() and 'https' or 'http'
    domain = RequestSite(request).domain
    path = get_path_from_request(request)

    contacts = Contact.objects.get_contacts_by_user(username)
    accessible_repos = [
        repo
    ] if repo.encrypted else get_unencry_rw_repos_by_user(username)

    head_commit = get_commit(repo.head_cmmt_id)
    if not head_commit:
        raise Http404
    repo_size = get_repo_size(repo.id)
    no_quota = is_no_quota(repo.id)
    history_limit = seaserv.get_repo_history_limit(repo.id)
    search_repo_id = None if repo.encrypted else repo.id

    is_repo_owner = seafile_api.is_repo_owner(username, repo.id)
    file_list, dir_list = get_repo_dirents(request, repo.id, head_commit, path)
    zipped = get_nav_path(path, repo.name)
    repo_groups = get_shared_groups_by_repo_and_user(repo.id, username)
    if len(repo_groups) > 1:
        repo_group_str = render_to_string("snippets/repo_group_list.html",
                                          {'groups': repo_groups})
    else:
        repo_group_str = ''
    upload_url = get_upload_url(request, repo.id)
    update_url = get_update_url(request, repo.id)
    fileshare = get_fileshare(repo.id, username, path)
    dir_shared_link = get_shared_link(request, fileshare)

    return render_to_response('repo.html', {
        'repo': repo,
        'user_perm': user_perm,
        'is_repo_owner': is_repo_owner,
        'current_commit': head_commit,
        'password_set': True,
        'repo_size': repo_size,
        'dir_list': dir_list,
        'file_list': file_list,
        'path': path,
        'zipped': zipped,
        'accessible_repos': accessible_repos,
        'applet_root': applet_root,
        'groups': repo_groups,
        'repo_group_str': repo_group_str,
        'no_quota': no_quota,
        'max_upload_file_size': max_upload_file_size,
        'upload_url': upload_url,
        'update_url': update_url,
        'httpserver_root': httpserver_root,
        'protocol': protocol,
        'domain': domain,
        'contacts': contacts,
        'fileshare': fileshare,
        'dir_shared_link': dir_shared_link,
        'history_limit': history_limit,
        'search_repo_id': search_repo_id,
        'ENABLE_SUB_LIBRARY': ENABLE_SUB_LIBRARY,
    },
                              context_instance=RequestContext(request))
예제 #4
0
파일: repo.py 프로젝트: jjjasont/seahub
def render_repo(request, repo):
    """Steps to show repo page:
    If user has permission to view repo
      If repo is encrypt and password is not set on server
        return decrypt repo page
      If repo is not encrypt or password is set on server
        Show repo direntries based on requested path
    If user does not have permission to view repo
      return permission deny page

    """
    username = request.user.username
    user_perm = check_repo_access_permission(repo.id, username)
    if user_perm is None:
        return render_to_response('repo_access_deny.html', {
                'repo': repo,
                }, context_instance=RequestContext(request))

    if repo.encrypted and not is_password_set(repo.id, username):
        return render_to_response('decrypt_repo_form.html', {
                'repo': repo,
                'next': get_next_url_from_request(request) or \
                    reverse('repo', args=[repo.id])
                }, context_instance=RequestContext(request))

    # query context args
    applet_root = get_ccnetapplet_root()
    httpserver_root = get_httpserver_root()
    max_upload_file_size = MAX_UPLOAD_FILE_SIZE
    
    protocol = request.is_secure() and 'https' or 'http'
    domain = RequestSite(request).domain
    path = get_path_from_request(request)

    contacts = Contact.objects.get_contacts_by_user(username)
    accessible_repos = [repo] if repo.encrypted else get_unencry_rw_repos_by_user(username)

    head_commit = get_commit(repo.head_cmmt_id)
    if not head_commit:
        raise Http404
    repo_size = get_repo_size(repo.id)
    no_quota = is_no_quota(repo.id)
    history_limit = seaserv.get_repo_history_limit(repo.id)
    search_repo_id = None if repo.encrypted else repo.id
    
    is_repo_owner = seafile_api.is_repo_owner(username, repo.id)
    file_list, dir_list = get_repo_dirents(request, repo.id, head_commit, path)
    zipped = get_nav_path(path, repo.name)
    repo_groups = get_shared_groups_by_repo_and_user(repo.id, username)
    if len(repo_groups) > 1:
        repo_group_str = render_to_string("snippets/repo_group_list.html",
                                          {'groups': repo_groups})
    else:
        repo_group_str = ''
    upload_url = get_upload_url(request, repo.id)
    update_url = get_update_url(request, repo.id)
    fileshare = get_fileshare(repo.id, username, path)
    dir_shared_link = get_shared_link(request, fileshare)

    return render_to_response('repo.html', {
            'repo': repo,
            'user_perm': user_perm,
            'is_repo_owner': is_repo_owner,
            'current_commit': head_commit,
            'password_set': True,
            'repo_size': repo_size,
            'dir_list': dir_list,
            'file_list': file_list,
            'path': path,
            'zipped': zipped,
            'accessible_repos': accessible_repos,
            'applet_root': applet_root,
            'groups': repo_groups,
            'repo_group_str': repo_group_str,
            'no_quota': no_quota,
            'max_upload_file_size': max_upload_file_size,
            'upload_url': upload_url,
            'update_url': update_url,
            'httpserver_root': httpserver_root,
            'protocol': protocol,
            'domain': domain,
            'contacts': contacts,
            'fileshare': fileshare,
            'dir_shared_link': dir_shared_link,
            'history_limit': history_limit,
            'search_repo_id': search_repo_id,
            }, context_instance=RequestContext(request))