1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-16 22:17:59 +00:00

Fixed head commit bug in repo page

This commit is contained in:
zhengxie 2014-03-24 17:41:08 +08:00
parent bbdfa51e49
commit d56c070c7c
3 changed files with 28 additions and 19 deletions

View File

@ -1,19 +1,15 @@
{% load seahub_tags avatar_tags i18n %}
<span class="commit-msg vam" data-cmtid="{{ current_commit.id }}">
{{ current_commit.props.desc|translate_commit_desc }}
<a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ current_commit.id }}" data-time="{{ current_commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
{{ info_commit.props.desc|translate_commit_desc }}
<a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ info_commit.id }}" data-time="{{ info_commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
</span>
<span class="meta-info split">
{% if current_commit.props.creator_name %}
{% if not current_commit.second_parent_id %}
{% avatar current_commit.props.creator_name 20 %}
<a class="vam" href="{% url 'user_profile' current_commit.creator_name|id_or_email %}">{{ current_commit.creator_name|email2nickname }}</a>
{% else %}
<span class="vam">{% trans "Generated by system"%}</span>
{% endif %}
{% if info_commit.props.creator_name %}
{% avatar info_commit.props.creator_name 20 %}
<a class="vam" href="{% url 'user_profile' info_commit.creator_name|id_or_email %}">{{ info_commit.creator_name|email2nickname }}</a>
{% else %}
<span class="vam">{% trans "Unknown"%}</span>
{% endif %}
<span class="time vam">{{ current_commit.props.ctime|translate_seahub_time }}</span>
<span class="time vam">{{ info_commit.props.ctime|translate_seahub_time }}</span>
</span>
<a href="{% url 'seahub.views.repo_history' repo.id %}" class="more vam split">{% trans "History"%}</a>

View File

@ -238,8 +238,8 @@ def list_dir(request, repo_id):
server_crypto = UserOptions.objects.is_server_crypto(username)
except CryptoOptionNotSetError:
# Assume server_crypto is ``False`` if this option is not set.
server_crypto = False
server_crypto = False
if repo.encrypted and \
(repo.enc_version == 1 or (repo.enc_version == 2 and server_crypto)) \
and not seafile_api.is_password_set(repo.id, username):
@ -253,9 +253,14 @@ def list_dir(request, repo_id):
return HttpResponse(json.dumps({'error': err_msg}),
status=500, content_type=content_type)
if new_merge_with_no_conflict(head_commit):
info_commit = get_commit_before_new_merge(head_commit)
else:
info_commit = head_commit
path = request.GET.get('p', '/')
if path[-1] != '/':
path = path + '/'
path = path + '/'
more_start = None
file_list, dir_list, dirent_more = get_repo_dirents(request, repo.id, head_commit, path, offset=0, limit=100)
@ -284,6 +289,7 @@ def list_dir(request, repo_id):
'ENABLE_SUB_LIBRARY': settings.ENABLE_SUB_LIBRARY,
"sub_lib_enabled": sub_lib_enabled,
'current_commit': head_commit,
'info_commit': info_commit,
}
html = render_to_string('snippets/repo_dir_data.html', ctx,
context_instance=RequestContext(request))
@ -958,12 +964,15 @@ def get_current_commit(request, repo_id):
err_msg = _(u'Error: no head commit id')
return HttpResponse(json.dumps({'error': err_msg}),
status=500, content_type=content_type)
if new_merge_with_no_conflict(head_commit):
head_commit = get_commit_before_new_merge(head_commit)
info_commit = get_commit_before_new_merge(head_commit)
else:
info_commit = head_commit
ctx = {
'repo': repo,
'current_commit': head_commit
'info_commit': info_commit
}
html = render_to_string('snippets/current_commit.html', ctx,
context_instance=RequestContext(request))

View File

@ -187,7 +187,7 @@ def render_repo(request, repo):
applet_root = get_ccnetapplet_root()
httpserver_root = get_httpserver_root()
max_upload_file_size = get_max_upload_file_size()
protocol = request.is_secure() and 'https' or 'http'
domain = RequestSite(request).domain
@ -196,15 +196,18 @@ def render_repo(request, repo):
head_commit = get_commit(repo.head_cmmt_id)
if not head_commit:
raise Http404
if new_merge_with_no_conflict(head_commit):
head_commit = get_commit_before_new_merge(head_commit)
info_commit = get_commit_before_new_merge(head_commit)
else:
info_commit = head_commit
repo_size = get_repo_size(repo.id)
no_quota = is_no_quota(repo.id)
search_repo_id = None if repo.encrypted else repo.id
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if repo_owner == username else False
more_start = None
file_list, dir_list, dirent_more = get_repo_dirents(request, repo.id, head_commit, path, offset=0, limit=100)
if dirent_more:
@ -229,6 +232,7 @@ def render_repo(request, repo):
'repo_owner': repo_owner,
'is_repo_owner': is_repo_owner,
'current_commit': head_commit,
'info_commit': info_commit,
'password_set': True,
'repo_size': repo_size,
'dir_list': dir_list,