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

Merge pull request #827 from haiwen/misc

Misc
This commit is contained in:
llj
2015-09-23 13:52:26 +08:00
9 changed files with 103 additions and 248 deletions

View File

@@ -1785,15 +1785,13 @@ textarea:-moz-placeholder {/* for FF */
border: 1px solid #bbb;
margin: 2px 0 5px;
}
.repo-file-list-outer-container,
.commit-list-outer-container {
.repo-file-list-outer-container {
padding:3px;
background:#eee;
border-radius:3px;
margin:10px 0 25px;
}
.repo-file-list-inner-container,
.commit-list-inner-container {
.repo-file-list-inner-container {
min-height:250px;
background:#fff;
border:1px solid #ddd;
@@ -1802,7 +1800,6 @@ textarea:-moz-placeholder {/* for FF */
.repo-file-list-not-show {
padding-left:10px;
}
.commit-list-inner-container .commit-list-topbar,
.repo-file-list-inner-container .repo-file-list-topbar {
padding:8px 10px;
}
@@ -2165,7 +2162,7 @@ textarea:-moz-placeholder {/* for FF */
margin-top:3px;
}
.commit-list {
margin:0 0 20px;
margin-bottom:20px;
}
.commit-list .time {
padding-left:10px;
@@ -2173,6 +2170,16 @@ textarea:-moz-placeholder {/* for FF */
.commit-list .avatar {
border-radius:2px;
}
.repo-trash-hd,
.repo-snapshot-hd {
margin-bottom:10px;
}
.repo-snapshot-commit {
margin-bottom:6px;
}
#online-gc {
margin-left:5px;
}
/*repo-share-form*/
#email_or_group,
#share-link,

View File

@@ -5,10 +5,8 @@
{% block sub_title %}{% trans "History" %} - {% endblock %}
{% block main_panel %}
<h2>{{ u_filename }}{% trans "'s Version History" %}</h2>
<p class="tip">{% trans "Tip:a new version will be generated after each modification, and you can restore the file to a previous version." %}</p>
<div class="commit-list-outer-container">
<div class="commit-list-inner-container">
<h2>{% blocktrans %}<span class="op-target">{{ u_filename }}</span> Version History{% endblocktrans %}</h2>
<p class="tip">{% trans "Tip: a new version will be generated after each modification, and you can restore the file to a previous version." %}</p>
<div class="commit-list-topbar ovhd">
<p class="path fleft">
{% trans 'Current Path:' %}
@@ -41,8 +39,8 @@
</div>
<table class="commit-list">
<tr>
<th width="30%" class="time">{% trans 'Time' %}</th>
<th width="20%">{% trans 'Modifier' %}</th>
<th width="25%" class="time">{% trans 'Time' %}</th>
<th width="25%">{% trans 'Modifier' %}</th>
<th width="20%">{% trans 'Size' %}</th>
<th width="30%">{% trans 'Operations' %}</th>
</tr>
@@ -84,6 +82,4 @@
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}

View File

@@ -5,25 +5,30 @@
{% block sub_title %}{% trans "History" %} - {% endblock %}
{% block main_panel %}
<h2><span class="op-target">{{repo.props.name}}</span> {% trans "modification history" %}</h2>
<h2>{% blocktrans with repo_name=repo.props.name %}<span class="op-target">{{repo_name}}</span> Modification History{% endblocktrans %}</h2>
{% if user_perm == 'rw' %}
<p class="tip">{% trans "Tip: A snapshot will be generated after modification, which records the library state before this modification."%}<a href="{% url 'repo_view_snapshot' repo.props.id %}">{% trans "View Snapshot"%}</a></p>
<p class="tip">{% trans "Tip: a snapshot will be generated after modification, which records the library state after the modification."%}</p>
{% endif %}
<div class="commit-list-outer-container">
<div class="commit-list-inner-container">
<table class="commit-list">
<tr>
<th width="20%" class="time">{% trans "Time" %}</th>
<th width="20%">{% trans "Modifier"%}</th>
<th width="60%">{% trans "Description"%}</th>
<th width="40%">{% trans "Description"%}</th>
<th width="19%">{% trans "Time" %}</th>
<th width="22%">{% trans "Modifier"%}</th>
<th width="19%">{% trans "Operations" %}</th>
</tr>
{% for commit in commits %}
{% if commit.show %}
<tr>
<td class="time">{{ commit.ctime|translate_seahub_time }}</td>
<td>
{{ commit.props.desc|translate_commit_desc }}
{% if page_next or not forloop.last %}
<a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ commit.id }}" data-time="{{ commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
{% endif %}
</td>
<td>{{ commit.ctime|translate_seahub_time }}</td>
<td>
{% if commit.creator_name %}
{% if not commit.second_parent_id %}
@@ -37,9 +42,12 @@
{% endif %}
</td>
<td>
{{ commit.props.desc|translate_commit_desc }}
{% if page_next or not forloop.last %}
<a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ commit.id }}" data-time="{{ commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
{% if user_perm == 'rw' %}
{% if forloop.first and current_page == 1 %}
<span class="op vh">{% trans "Current Version" %}</span>
{% else %}
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ commit.id }}" class="op vh">{% trans "View Snapshot" %}</a>
{% endif %}
{% endif %}
</td>
</tr>
@@ -73,15 +81,10 @@
<a href="?per_page=100" class="per-page">100</a>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
{% include 'snippets/list_commit_detail.html' %}
$('#back').click(function() {
location.href = $(this).attr('data');
});
</script>
{% endblock %}

View File

@@ -3,38 +3,45 @@
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}
{% block extra_style %}
<style type="text/css">
#main { position: relative; }
.go-back { top:-3px; }
</style>
{% endblock %}
{% block main_panel %}
<div class="w100 ovhd">
<h2 class="fleft"><span class="op-target">{{repo.props.name}}</span> {% trans "snapshot"%}<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span></h2>
<button data="{% url 'repo_view_snapshot' repo.id %}" class="fright" id="back">{% trans "Back to snapshots"%}</button>
</div>
<h2 class="repo-snapshot-hd">{% blocktrans with repo_name=repo.props.name %}<span class="op-target">{{repo_name}}</span> Snapshot{% endblocktrans %}<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span></h2>
{% if path == '/' %}
<div id="repo-latest-commit">
<p class="commit-msg">{{ current_commit.props.desc|translate_commit_desc }}</p>
<p class="meta-info">
<span class="author">
{% if current_commit.props.creator_name %}
{% avatar current_commit.props.creator_name 20 %}
<a class="name" href="{% url 'user_profile' current_commit.props.creator_name %}">{{ current_commit.props.creator_name|short_email }}</a>
{% else %}
{% trans "Unknown"%}
{% endif %}
</span>
<span class="time">{{ current_commit.props.ctime|translate_seahub_time }}</span>
</p>
</div>
{% endif %}
<a href="{% url 'repo_history' repo.props.id %}" class="go-back" title="{% trans "Back to modification history"%}">
<span class="icon-chevron-left"></span>
</a>
<div class="repo-file-list-outer-container">
<div class="repo-file-list-inner-container">
{% if not user_perm %}
<div class="repo-file-list-not-show">
<p class="access-notice">{% trans "Can't view this library"%}</p>
</div>
{% else %}
<div class="repo-file-list-topbar">
<p class="path">
{% if path == '/' %}
<div id="repo-latest-commit" class="repo-snapshot-commit">
<span class="commit-msg">{{ current_commit.props.desc|translate_commit_desc }}</span>
<span class="meta-info split">
<span class="author">
{% if current_commit.props.creator_name %}
{% avatar current_commit.props.creator_name 20 %}
<a class="name" href="{% url 'user_profile' current_commit.props.creator_name %}">{{ current_commit.props.creator_name|short_email }}</a>
{% else %}
{% trans "Unknown"%}
{% endif %}
</span>
<span class="time">{{ current_commit.props.ctime|translate_seahub_time }}</span>
</span>
</div>
{% endif %}
<div class="repo-file-list-topbar ovhd">
<p class="path fleft">
{% trans "Current path: "%}
{% for name, link in zipped %}
{% if not forloop.last %}
@@ -44,14 +51,18 @@
{% endif %}
{% endfor %}
</p>
{% if path == '/' and is_repo_owner %}
<button data-url="{% url 'repo_history_revert' repo.id %}?commit_id={{ current_commit.id }}" id="repo-revert" class="op-btn fright">{% trans "Restore"%}</button>
{% endif %}
</div>
<!-- /.repo-file-list-topbar -->
<table class="repo-file-list">
<tr>
<th width="5%"></th>
<th width="45%">{% trans "Name"%}</th>
<th width="30%">{% trans "Size"%}</th>
<th width="20%">{% trans "Operations"%}</th>
<th width="23%">{% trans "Size"%}</th>
<th width="27%">{% trans "Operations"%}</th>
</tr>
{% for dirent in dir_list %}
@@ -77,14 +88,13 @@
</table>
<!-- /.repo-file-list -->
{% endif %}
</div>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$('#back').click(function() {
location.href = $(this).attr('data');
addConfirmTo($('#repo-revert'), {
'title':"{% trans "Restore Library" %}",
'con':"{% trans "Are you sure you want to restore this library?" %}"
});
</script>
{% endblock %}

View File

@@ -4,32 +4,29 @@
{% load url from future %}
{% block main_panel %}
<div class="w100 ovhd">
<h2 class="fleft">{% blocktrans with repo_name=repo.props.name %}{{repo_name}} Trash{% endblocktrans %}</h2>
{% if enable_clean %}
<button id="online-gc" class="fright">{% trans "Clean" %}</button>
{% endif %}
</div>
<h2 class="repo-trash-hd">{% blocktrans with repo_name=repo.props.name %}<span class="op-target">{{repo_name}}</span> Trash{% endblocktrans %}</h2>
<div class="repo-file-list-outer-container">
<div class="repo-file-list-inner-container">
<div class="repo-file-list-topbar ovhd">
<p class="path fleft">
{% trans "Current path: " %}
<a href="?days={{days}}">{% blocktrans with repo_name=repo.props.name %}{{repo_name}} Trash{% endblocktrans %}</a>
{% if not show_recycle_root %}
<a href="?days={{days}}">{{repo.name}}</a>
{% for name, link in zipped %}
{% if not forloop.last %}
/ <a href="?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ link|urlencode }}&days={{days}}">{{ name }}</a>
{% else %}
/ {{ name }}
{% endif %}
{% if not forloop.last %}
/ <a href="?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ link|urlencode }}&days={{days}}">{{ name }}</a>
{% else %}
/ {{ name }}
{% endif %}
{% endfor %}
{% else %}
{{repo.name}}
{% endif %}
</p>
{% if show_recycle_root %}
<span class="fright">
<div class="fright">
<span>
{% if days != 7 %}
<a href="?days=7">{% trans "a week" %}</a> /
{% else %}
@@ -46,16 +43,20 @@
{% trans "all" %}
{% endif %}
</span>
{% if enable_clean %}
<button id="online-gc" class="op-btn">{% trans "Clean" %}</button>
{% endif %}
</div>
{% endif %}
</div>
<!-- /.repo-file-list-topbar -->
<table class="repo-file-list">
<tr>
<th width="5%"></th>
<th width="60%">{% trans "Name" %}</th>
<th width="15%">{% trans "Delete Time" %}</th>
<th width="10%">{% trans "Size" %}</th>
<th width="10%">{% trans "Operations" %}</th>
<th width="45%">{% trans "Name" %}</th>
<th width="20%">{% trans "Delete Time" %}</th>
<th width="15%">{% trans "Size" %}</th>
<th width="15%">{% trans "Operations" %}</th>
</tr>
{% for dirent in dir_list %}
@@ -92,10 +93,8 @@
</tr>
{% endfor %}
</table>
</div>
</div>
{% if enable_clean %}
{% if enable_clean and show_recycle_root %}
<form id="gc-form" class="hide" method="post" action="{% url "repo_online_gc" repo.id %}">{% csrf_token %}
<h3>{% trans "Clean" %}</h3>
<p>{% trans "Clear files in trash and history" %}</p>
@@ -115,7 +114,7 @@
<script type="text/javascript">
$('#main-panel').removeClass('ovhd');
{% if enable_clean %}
{% if enable_clean and show_recycle_root %}
$('#online-gc').click(function() {
$('#gc-form').modal({focus:false});
$("#simplemodal-container").css({'height':'auto'});

View File

@@ -1,100 +0,0 @@
{% extends base_template %}
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}
{% block extra_style %}
<style type="text/css">
#main { position: relative; }
.go-back { top:-3px; }
</style>
{% endblock %}
{% block main_panel %}
<h2><span class="op-target">{{repo.props.name}}</span> {% trans "snapshots"%}</h2>
<a href="{{ SITE_ROOT }}repo/history/{{ repo.props.id }}/" class="go-back" title="{% trans "Back to modification history"%}">
<span class="icon-chevron-left"></span>
</a>
<div class="commit-list-outer-container">
<div class="commit-list-inner-container">
<table class="commit-list">
<tr>
<th width="15%" class="time">{% trans "Create Time"%}</th>
<th width="15%">{% trans "Last Modifier"%}</th>
<th width="55%">{% trans "Detail"%}</th>
<th width="15%">{% trans "Operations"%}</th>
</tr>
{% for commit in commits %}
<tr>
<td class="time">{{ commit.ctime|translate_seahub_time }}</td>
<td>
{% if commit.creator_name %}
{% if not commit.second_parent_id %}
{% avatar commit.creator_name 16 %} <a href="{% url 'user_profile' commit.creator_name %}" class="vam">{{ commit.creator_name|email2nickname }}</a>
{% else %}
{% trans "None"%}
{% endif %}
{% else %}
{% trans "Unknown"%}
{% endif %}
</td>
<td>
{{ commit.props.desc|translate_commit_desc }}
{% if page_next or not forloop.last %}
<a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ commit.id }}" data-time="{{ commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
{% endif %}
</td>
<td>
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ commit.id }}" class="op vh">{% trans "View"%}</a>
{% if is_repo_owner %}
<a href="#" data-url="{% url 'seahub.views.repo_history_revert' repo.id %}?commit_id={{ commit.id }}" class="repo-revert op vh">{% trans "Restore"%}</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<div id="paginator">
{% if current_page != 1 %}
<a href="?page={{ prev_page }}&per_page={{ per_page }}">{% trans "Previous"%}</a>
{% endif %}
{% if page_next %}
<a href="?page={{ next_page }}&per_page={{ per_page }}">{% trans "Next"%}</a>
{% endif %}
{% if current_page != 1 or page_next %}
|
{% endif %}
<span>{% trans "Per page: "%}</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>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
{% include 'snippets/list_commit_detail.html' %}
$('#back').click(function() {
location.href = $(this).attr('data');
});
addConfirmTo($('.repo-revert'), {
'title':"{% trans "Restore Library" %}",
'con':"{% trans "Are you sure you want to restore this library?" %}"
});
</script>
{% endblock %}

View File

@@ -70,11 +70,10 @@ urlpatterns = patterns(
url(r'^repo/text_diff/(?P<repo_id>[-0-9a-f]{36})/$', text_diff, name='text_diff'),
url(r'^repo/(?P<repo_id>[-0-9a-f]{36})/$', repo, name='repo'),
url(r'^repo/history/(?P<repo_id>[-0-9a-f]{36})/$', repo_history, name='repo_history'),
(r'^repo/history/revert/(?P<repo_id>[-0-9a-f]{36})/$', repo_history_revert),
url(r'^repo/history/revert/(?P<repo_id>[-0-9a-f]{36})/$', repo_history_revert, name='repo_history_revert'),
url(r'^repo/history/view/(?P<repo_id>[-0-9a-f]{36})/$', repo_history_view, name='repo_history_view'),
url(r'^repo/recycle/(?P<repo_id>[-0-9a-f]{36})/$', repo_recycle_view, name='repo_recycle_view'),
url(r'^repo/(?P<repo_id>[-0-9a-f]{36})/online_gc/$', repo_online_gc, name='repo_online_gc'),
url(r'^repo/snapshot/view/(?P<repo_id>[-0-9a-f]{36})/$', repo_view_snapshot, name='repo_view_snapshot'),
url(r'^repo/(?P<repo_id>[-0-9a-f]{36})/files/$', view_repo_file, name="repo_view_file"),
url(r'^repo/(?P<repo_id>[-0-9a-f]{36})/raw/(?P<file_path>.*)$', view_raw_file, name="view_raw_file"),
url(r'^repo/(?P<repo_id>[-0-9a-f]{36})/history/files/$', view_history_file, name="view_history_file"),

View File

@@ -971,69 +971,6 @@ def repo_history(request, repo_id):
'user_perm': user_perm,
}, context_instance=RequestContext(request))
@login_required
def repo_view_snapshot(request, repo_id):
"""List repo snapshots.
"""
repo = get_repo(repo_id)
if not repo:
raise Http404
# perm check
if check_repo_access_permission(repo.id, request.user) is None:
raise Http404
username = request.user.username
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if username == repo_owner else False
try:
server_crypto = UserOptions.objects.is_server_crypto(username)
except CryptoOptionNotSetError:
# Assume server_crypto is ``False`` if this option is not set.
server_crypto = False
password_set = False
if repo.props.encrypted and \
(repo.enc_version == 1 or (repo.enc_version == 2 and server_crypto)):
try:
ret = seafserv_rpc.is_passwd_set(repo_id, username)
if ret == 1:
password_set = True
except SearpcError, e:
return render_error(request, e.msg)
if 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
# don't show the current commit
commits_all = get_commits(repo_id, per_page * (current_page -1) + 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,
"is_repo_owner": is_repo_owner,
"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
def repo_history_revert(request, repo_id):

View File

@@ -352,8 +352,12 @@ def repo_history_view(request, repo_id):
current_commit, path)
zipped = get_nav_path(path, repo.name)
repo_owner = seafile_api.get_repo_owner(repo.id)
is_repo_owner = True if username == repo_owner else False
return render_to_response('repo_history_view.html', {
'repo': repo,
"is_repo_owner": is_repo_owner,
'user_perm': user_perm,
'current_commit': current_commit,
'dir_list': dir_list,