diff --git a/base/context_processors.py b/base/context_processors.py index 9d9becd65d..772989ec9f 100644 --- a/base/context_processors.py +++ b/base/context_processors.py @@ -8,9 +8,12 @@ RequestContext. """ import settings -def version(request): +def base(request): """ - Add seafile version to the context. + Add seahub base configure to the context. """ - return {'seafile_version': settings.SEAFILE_VERSION} + return { + 'seafile_version': settings.SEAFILE_VERSION, + 'seahub_title': settings.SEAHUB_TITLE, + } diff --git a/settings.py b/settings.py index 6e8e3b87e5..a8bc34df5a 100644 --- a/settings.py +++ b/settings.py @@ -88,7 +88,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.media', 'djblets.util.context_processors.siteRoot', 'django.core.context_processors.request', - 'seahub.base.context_processors.version', + 'seahub.base.context_processors.base', ) @@ -129,6 +129,8 @@ CCNET_APPLET_ROOT = "http://localhost:8081" SEAFILE_VERSION = '0.9.2' +SEAHUB_TITLE = 'SeaHub' + # Add supported file extensions and file icon name. # Icons will show in repo page. FILEEXT_ICON_MAP = { @@ -179,6 +181,7 @@ AVATAR_GRAVATAR_BACKUP = False AVATAR_DEFAULT_URL = '/avatars/default.png' AUTO_GENERATE_AVATAR_SIZES = (80, 16) AVATAR_MAX_AVATARS_PER_USER = 1 +AVATAR_CACHE_TIMEOUT = 0 LOGIN_URL = SITE_ROOT + 'accounts/login' diff --git a/templates/base.html b/templates/base.html index e4154e7df6..c417b73b4a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,7 +1,7 @@ -SeaHub +{{ seahub_title }} diff --git a/views.py b/views.py index 5be70ab53e..3b7fb2b515 100644 --- a/views.py +++ b/views.py @@ -137,18 +137,11 @@ def render_repo(request, repo_id, error=''): repo_ap = 'own' if not access_to_repo(request, repo_id, repo_ap): - raise Http404 + return go_permission_error(request, u'该同步目录未公开') repo = get_repo(repo_id) if not repo: - raise Http404 - - latest_commit = get_commits(repo_id, 0, 1)[0] - - is_owner = False - if request.user.is_authenticated(): - if validate_owner(request, repo_id): - is_owner = True + return go_error(request, u'该同步目录不存在') password_set = False if repo.props.encrypted: @@ -160,6 +153,7 @@ def render_repo(request, repo_id, error=''): return go_error(request, e.msg) repo_size = seafserv_threaded_rpc.server_repo_size(repo_id) + latest_commit = get_commits(repo_id, 0, 1)[0] dirs = [] path = '' @@ -170,27 +164,38 @@ def render_repo(request, repo_id, error=''): path = request.GET.get('p', '/') if path[-1] != '/': path = path + '/' - - try: - dirs = seafserv_rpc.list_dir_by_path(latest_commit.id, - path.encode('utf-8')) - except SearpcError, e: - return go_error(request, e.msg) - for dirent in dirs: - if stat.S_ISDIR(dirent.props.mode): - dir_list.append(dirent) - else: - file_list.append(dirent) - try: - dirent.file_size = seafserv_rpc.get_file_size(dirent.obj_id) - except: - dirent.file_size = 0 - dir_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower())) - file_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower())) - - # generate path and link - zipped = gen_path_link(path, repo.name) + if latest_commit.root_id == '0000000000000000000000000000000000000000': + dirs = [] + else: + try: + dirs = seafserv_rpc.list_dir_by_path(latest_commit.id, + path.encode('utf-8')) + except SearpcError, e: + return go_error(request, e.msg) + for dirent in dirs: + if stat.S_ISDIR(dirent.props.mode): + dir_list.append(dirent) + else: + file_list.append(dirent) + try: + dirent.file_size = seafserv_rpc.get_file_size(dirent.obj_id) + except: + dirent.file_size = 0 + dir_list.sort(lambda x, y : cmp(x.obj_name.lower(), + y.obj_name.lower())) + file_list.sort(lambda x, y : cmp(x.obj_name.lower(), + y.obj_name.lower())) + + # generate path and link + zipped = gen_path_link(path, repo.name) + + # check whether use is repo owner + is_owner = False + if request.user.is_authenticated(): + if validate_owner(request, repo_id): + is_owner = True + # used to determin whether show repo content in repo.html # if a repo is shared to me, or repo shared to the group I joined, # then I can view repo content on the web