1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00

[history]modified repo_history, repo_history_view;added repo_view_snapshot

This commit is contained in:
llj
2012-09-21 14:01:39 +08:00
parent d538789428
commit 3e1fd75e9f
5 changed files with 149 additions and 23 deletions

View File

@@ -5,48 +5,36 @@
{% block main_panel %} {% block main_panel %}
<div class="w100 ovhd"> <div class="w100 ovhd">
<h2 class="fleft">{{repo.props.name}} 修改历史</h2> <h2 class="fleft">{{repo.props.name}} 修改历史</h2>
<button data="{{ SITE_ROOT }}repo/{{ repo.props.id }}/" class="fright" id="history-back-to-repo">返回同步目录</button> <button data="{{ SITE_ROOT }}repo/{{ repo.props.id }}/" class="fright" id="back">返回同步目录</button>
</div> </div>
<p class="tip">Tip在每次修改后会生成一个镜像记录修改后的目录状态。</p> <p class="tip">Tip在每次修改后会生成一个镜像记录修改后的目录状态。<a href="{% url 'repo_view_snapshot' repo.props.id %}">查看镜像</a></p>
<div class="commit-list-outer-container"> <div class="commit-list-outer-container">
<div class="commit-list-inner-container"> <div class="commit-list-inner-container">
<table class="commit-list"> <table class="commit-list">
<tr> <tr>
<th width="13%" class="time">修改时间</th> <th width="20%" class="time">修改时间</th>
<th width="15%">修改者</th> <th width="20%">修改者</th>
<th width="57%">描述</th> <th width="60%">描述</th>
<th width="15%">操作</th>
</tr> </tr>
{% for commit in commits %} {% for commit in commits %}
<tr> <tr>
<td class="time">{{ commit.ctime|translate_commit_time }}</td> <td class="time">{{ commit.ctime|translate_commit_time }}</td>
{% if commit.creator_name %}
<td> <td>
{% if commit.creator_name %}
<a href="{{ SITE_ROOT }}profile/{{ commit.creator_name }}/">{% avatar commit.creator_name 16 %}</a> <a href="{{ SITE_ROOT }}profile/{{ commit.creator_name }}/">{% avatar commit.creator_name 16 %}</a>
<a href="{{ SITE_ROOT }}profile/{{ commit.creator_name }}/">{{ commit.creator_name|email2nickname }}</a> <a href="{{ SITE_ROOT }}profile/{{ commit.creator_name }}/">{{ commit.creator_name|email2nickname }}</a>
</td>
{% else %} {% else %}
<td>未知</td> 未知
{% endif %} {% endif %}
</td>
<td> <td>
{{ commit.props.desc|translate_commit_desc }} {{ commit.props.desc|translate_commit_desc }}
{% if page_next or not forloop.last %} {% if page_next or not forloop.last %}
<a class="lsch" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a> <a class="lsch" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a>
{% endif %} {% endif %}
</td> </td>
{% if forloop.first and current_page == 1 %}
<td>这是当前版本</td>
{% else %}
<td>
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ commit.id }}" class="op">查看镜像</a>
</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
@@ -82,9 +70,8 @@
{% block extra_script %} {% block extra_script %}
<script type="text/javascript"> <script type="text/javascript">
{% include 'snippets/list_commit_detail.html' %} {% include 'snippets/list_commit_detail.html' %}
$('#history-back-to-repo').click(function() { $('#back').click(function() {
location.href = $(this).attr('data'); location.href = $(this).attr('data');
}); });
addConfirmTo($(".repo-revert"), '确定要还原该目录?');
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -6,7 +6,7 @@
{% block main_panel %} {% block main_panel %}
<div class="w100 ovhd"> <div class="w100 ovhd">
<h2 class="fleft">{{repo.props.name}} 历史镜像<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span></h2> <h2 class="fleft">{{repo.props.name}} 历史镜像<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span></h2>
<button data="{{ SITE_ROOT }}repo/history/{{ repo.id }}/" class="fright" id="back-to-history-list">返回历史列表</button> <button data="{% url 'repo_view_snapshot' repo.id %}" class="fright" id="back">返回镜像列表</button>
</div> </div>
<div id="repo-latest-commit"> <div id="repo-latest-commit">
@@ -77,5 +77,8 @@
{% block extra_script %} {% block extra_script %}
<script type="text/javascript"> <script type="text/javascript">
$('#back').click(function() {
location.href = $(this).attr('data');
});
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,86 @@
{% extends base_template %}
{% load seahub_tags avatar_tags %}
{% load url from future %}
{% block main_panel %}
<div class="w100 ovhd">
<h2 class="fleft">{{repo.props.name}} 镜像查看</h2>
<button data="{{ SITE_ROOT }}repo/history/{{ repo.props.id }}/" class="fright" id="history-back-to-repo">返回修改历史</button>
</div>
<div class="commit-list-outer-container">
<div class="commit-list-inner-container">
<table class="commit-list">
<tr>
<th width="15%" class="time">生成时间</th>
<th width="15%">修改者</th>
<th width="55%">描述</th>
<th width="15%">操作</th>
</tr>
{% for commit in commits %}
<tr>
<td class="time">{{ commit.ctime|translate_commit_time }}</td>
<td>
{% if commit.creator_name %}
<a href="{{ SITE_ROOT }}profile/{{ commit.creator_name }}/">{% avatar commit.creator_name 16 %}</a>
<a href="{{ SITE_ROOT }}profile/{{ commit.creator_name }}/">{{ commit.creator_name|email2nickname }}</a>
{% else %}
未知
{% endif %}
</td>
<td>
{{ commit.props.desc|translate_commit_desc }}
{% if page_next or not forloop.last %}
<a class="lsch" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a>
{% endif %}
</td>
<td>
{% if forloop.first and current_page == 1 %}
这是当前版本
{% else %}
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ commit.id }}" class="op">查看</a>
<a href="#" data="{% url 'seahub.views.repo_history_revert' repo.id %}?commit_id={{ commit.id }}" class="repo-revert op">还原</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<div id="paginator">
{% if current_page != 1 %}
<a href="?page={{ prev_page }}&per_page={{ per_page }}">上一页</a>
{% endif %}
{% if page_next %}
<a href="?page={{ next_page }}&per_page={{ per_page }}">下一页</a>
{% endif %}
<span>每页:</span>
{% if per_page == 25 %}
<span> 25 </span>
{% else %}
<a href="?per_page=25" class="per-page">25</a>
{% endif %}
{% if per_page == 50 %}
<span> 50 </span>
{% else %}
<a href="?per_page=50" class="per-page">50</a>
{% endif %}
{% if per_page == 100 %}
<span> 100 </span>
{% else %}
<a href="?per_page=100" class="per-page">100</a>
{% endif %}
</div>
<div id="ls-ch" class="hide"></div><!--list modification details of a commit-->
</div>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
{% include 'snippets/list_commit_detail.html' %}
$('#history-back-to-repo').click(function() {
location.href = $(this).attr('data');
});
addConfirmTo($(".repo-revert"), '确定要还原该目录?');
</script>
{% endblock %}

View File

@@ -59,6 +59,7 @@ urlpatterns = patterns('',
(r'^repo/history/(?P<repo_id>[^/]+)/$', repo_history), (r'^repo/history/(?P<repo_id>[^/]+)/$', repo_history),
(r'^repo/history/revert/(?P<repo_id>[^/]+)/$', repo_history_revert), (r'^repo/history/revert/(?P<repo_id>[^/]+)/$', repo_history_revert),
url(r'^repo/history/view/(?P<repo_id>[^/]+)/$', RepoHistoryView.as_view(), name='repo_history_view'), url(r'^repo/history/view/(?P<repo_id>[^/]+)/$', RepoHistoryView.as_view(), name='repo_history_view'),
url(r'^repo/snapshot/view/(?P<repo_id>[^/]+)/$', repo_view_snapshot, name='repo_view_snapshot'),
# (r'^repo/token/modify/(?P<repo_id>[^/]+)/$', modify_token), # (r'^repo/token/modify/(?P<repo_id>[^/]+)/$', modify_token),
(r'^repo/history/changes/(?P<repo_id>[^/]+)/$', repo_history_changes), (r'^repo/history/changes/(?P<repo_id>[^/]+)/$', repo_history_changes),
(r'^repo/remove/(?P<repo_id>[^/]+)/$', remove_repo), (r'^repo/remove/(?P<repo_id>[^/]+)/$', remove_repo),

View File

@@ -549,6 +549,55 @@ def repo_history(request, repo_id):
'page_next': page_next, 'page_next': page_next,
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))
@login_required
@ctx_switch_required
def repo_view_snapshot(request, repo_id):
"""
View repo history.
"""
if not access_to_repo(request, repo_id, ''):
return render_permission_error(request, u'无法浏览该同步目录修改历史')
repo = get_repo(repo_id)
password_set = False
if repo.props.encrypted:
try:
ret = seafserv_rpc.is_passwd_set(repo_id, request.user.username)
if ret == 1:
password_set = True
except SearpcError, e:
return render_error(request, e.msg)
if repo.props.encrypted and not password_set:
return HttpResponseRedirect(reverse('repo', args=[repo_id]))
try:
current_page = int(request.GET.get('page', '1'))
per_page= int(request.GET.get('per_page', '25'))
except ValueError:
current_page = 1
per_page = 25
commits_all = get_commits(repo_id, per_page * (current_page -1),
per_page + 1)
commits = commits_all[:per_page]
if len(commits_all) == per_page + 1:
page_next = True
else:
page_next = False
return render_to_response('repo_view_snapshot.html', {
"repo": repo,
"commits": commits,
'current_page': current_page,
'prev_page': current_page-1,
'next_page': current_page+1,
'per_page': per_page,
'page_next': page_next,
}, context_instance=RequestContext(request))
@login_required @login_required
def repo_history_revert(request, repo_id): def repo_history_revert(request, repo_id):
repo = get_repo(repo_id) repo = get_repo(repo_id)