mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-01 15:23:05 +00:00
split repo into repo & repo_history
This commit is contained in:
parent
be712e3a8e
commit
f4f05ab034
@ -17,7 +17,7 @@ ul > li { list-style:none; }
|
||||
a { color:#ee8833; text-decoration:none; font-weight:bold; }
|
||||
a:hover { color: #ff9933; text-decoration: underline; }
|
||||
/* table */
|
||||
table { border-spacing: 0; border-collapse: collapse; width:770px; margin:3px 0 5px; }
|
||||
table { border-spacing: 0; border-collapse: collapse; width:100%; margin:3px 0 5px; }
|
||||
td, th { padding: 3px; word-break:break-word; }
|
||||
th { /*color:#808;*/ color:#333; text-align:left; }
|
||||
tr.even { background-color: #FAFAFA; }
|
||||
@ -205,13 +205,16 @@ input.ccnet_id { width: 400px; }
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
/*repo page*/
|
||||
#token-show-switch {
|
||||
.repo-desc {
|
||||
margin:0;
|
||||
}
|
||||
#repo-access-switch {
|
||||
height:auto;
|
||||
}
|
||||
.ui-tabs {
|
||||
padding:1em;
|
||||
.tip {
|
||||
color:#808080;
|
||||
font-size:12px;
|
||||
}
|
||||
.ui-tabs .ui-tabs-nav,
|
||||
.ui-tabs .ui-tabs-panel {
|
||||
padding: 0;
|
||||
.simplemodal-close {
|
||||
margin-left:5px;
|
||||
}
|
||||
|
@ -1,22 +1,49 @@
|
||||
{% extends "myhome_base.html" %}
|
||||
{% load seahub_tags %}
|
||||
|
||||
{% block nav_home_class %}class="cur"{% endblock %}
|
||||
{% block left_panel %}
|
||||
<ul>
|
||||
{% if is_owner %}
|
||||
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
||||
{% else %}
|
||||
{% if repo_ap == 'public' %}
|
||||
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if is_owner %}
|
||||
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
||||
{% else %}
|
||||
{% if repo_ap == 'public' %}
|
||||
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% block right_panel %}
|
||||
|
||||
<h2>{{repo.props.name}}</h2>
|
||||
<p class="repo-desc">{{repo.props.desc}}</p>
|
||||
<p>
|
||||
<span class="item-name">WEB匿名访问:</span>
|
||||
{% if is_owner %}
|
||||
{% if repo_ap == 'public' %}
|
||||
<input type="checkbox" name="repo-access-switch" id="repo-access-switch" checked="checked" autocomplete="off" /><label for="repo-access-switch">开启</label>
|
||||
{% else %}
|
||||
<input type="checkbox" name="repo-access-switch" id="repo-access-switch" autocomplete="off" /><label for="repo-access-switch">开启</label>
|
||||
{% endif %}
|
||||
<span class="tip">开启后,任何人都能够访问该目录</span>
|
||||
{% else %}
|
||||
<span>只有同步目录拥有者可设置</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<h3>最近修改</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="20%">修改时间</th>
|
||||
<th width="80%">描述</th>
|
||||
</tr>
|
||||
{% for commit in recent_commits %}
|
||||
<tr>
|
||||
<td>{{ commit.props.ctime|tsstr_sec }}</td>
|
||||
<td>{{ commit.props.desc }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<a href="{{ SITE_ROOT }}repo/history/{{repo.props.id}}/">查看全部修改</a>
|
||||
|
||||
<form id="modify-token-form" action="{{ SITE_ROOT }}repo/token/modify/{{repo.props.id}}/" method="post" class="hide">
|
||||
<h3>新口令:</h3>
|
||||
@ -24,119 +51,28 @@
|
||||
<input id="id_summit" type="submit" value="提交" />
|
||||
</form>
|
||||
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#basic-info">基本信息</a></li>
|
||||
<li><a href="#history">历史</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="basic-info">
|
||||
<h3>基本信息</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="12%">ID</th>
|
||||
<td width="88%">{{repo.props.id}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>描述</th>
|
||||
<td>{{repo.props.desc}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>访问口令</th>
|
||||
{% if is_owner %}
|
||||
<td><span id="token">*****</span> <input type="checkbox" name="token-show-switch" id="token-show-switch" /><label for="token-show-switch">显示</label> <button id="modify-token-btn">修改</button></td>
|
||||
{% else %}
|
||||
<td>只有同步目录拥有者可见</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th>HTTP访问</th>
|
||||
{% if is_owner %}
|
||||
<td>
|
||||
{% if repo_ap == 'public' %}
|
||||
<input type="checkbox" name="repo-access-switch" id="repo-access-switch" value="public" checked />
|
||||
{% else %}
|
||||
<input type="checkbox" name="repo-access-switch" id="repo-access-switch" value="own" />
|
||||
{% endif %}
|
||||
<label for="repo-access-switch">开启</label>
|
||||
<span id="repo-access-tips" style="color:#808080;">开启后,任何人都能够访问该目录。</span>
|
||||
</td>
|
||||
{% else %}
|
||||
<td>只有同步目录拥有者可选</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="history">
|
||||
<h3>修改记录</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<!-- <th>ID</th> -->
|
||||
<th width="20%">修改时间</th>
|
||||
<th width="80%">描述</th>
|
||||
</tr>
|
||||
{% for commit in commits %}
|
||||
<tr>
|
||||
<!-- <td>{{ commit.props.id }}</td> -->
|
||||
<td>{{ commit.props.ctime|tsstr_sec }}</td>
|
||||
<td>{{ commit.props.desc }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div id="paginator">
|
||||
{% if current_page != 1 %}
|
||||
<a href="{{ SITE_ROOT }}repo/{{repo.props.id}}/?page={{ prev_page }}&per_page={{ per_page }}">上一页</a>
|
||||
{% endif %}
|
||||
{% if page_next %}
|
||||
<a href="{{ SITE_ROOT }}repo/{{repo.props.id}}/?page={{ next_page }}&per_page={{ per_page }}">下一页</a>
|
||||
{% endif %}
|
||||
<span>每页:</span>
|
||||
{% if per_page == 25 %}
|
||||
<span> 25 </span>
|
||||
{% else %}
|
||||
<a href="{{ SITE_ROOT }}repo/{{repo.props.id}}/?per_page=25" class="per-page">25</a>
|
||||
{% endif %}
|
||||
{% if per_page == 50 %}
|
||||
<span> 50 </span>
|
||||
{% else %}
|
||||
<a href="{{ SITE_ROOT }}repo/{{repo.props.id}}/?per_page=50" class="per-page">50</a>
|
||||
{% endif %}
|
||||
{% if per_page == 100 %}
|
||||
<span> 100 </span>
|
||||
{% else %}
|
||||
<a href="{{ SITE_ROOT }}repo/{{repo.props.id}}/?per_page=100" class="per-page">100</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div id="public-access-start-confirm" class="hide">
|
||||
<p>确定要开启吗?</p>
|
||||
<button id="public-access-start-btn">确定</button>
|
||||
<button id="public-access-start-cancel-btn" class="simplemodal-close">取消</button>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("#modify-token-btn").click(function() {
|
||||
$("#modify-token-form").modal({appendTo: "#main"});
|
||||
});
|
||||
})
|
||||
$('#repo-access-switch').click(function() {
|
||||
var a = $("input[name='repo-access-switch']:checked").val();
|
||||
if (a) {
|
||||
location.href = "{{ SITE_ROOT }}repo/setap/{{ repo.props.id}}/public/";
|
||||
} else {
|
||||
location.href = "{{ SITE_ROOT }}repo/setap/{{ repo.props.id}}/own/";
|
||||
}
|
||||
});
|
||||
|
||||
$('#token-show-switch').click(function() {
|
||||
if ($(this).attr('checked')) {
|
||||
$('#token').html('{{token}}');
|
||||
} else {
|
||||
$('#token').html('*****');
|
||||
}
|
||||
});
|
||||
|
||||
$('#tabs').tabs({cookie: {expires: 1}});
|
||||
if ($(this).attr('checked')) {
|
||||
$('#public-access-start-confirm').modal({appendTo:"#main", containerCss:{padding:18}});
|
||||
} else {
|
||||
location.href = "{{ SITE_ROOT }}repo/setap/{{ repo.props.id}}/own/";
|
||||
}
|
||||
});
|
||||
|
||||
$('#public-access-start-btn').click(function() {
|
||||
location.href = "{{ SITE_ROOT }}repo/setap/{{ repo.props.id}}/public/";
|
||||
});
|
||||
$('#public-access-start-cancel-btn').click(function() {
|
||||
$('#repo-access-switch').attr('checked', false);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
48
templates/repo_history.html
Normal file
48
templates/repo_history.html
Normal file
@ -0,0 +1,48 @@
|
||||
{% extends "myhome_base.html" %}
|
||||
{% load seahub_tags %}
|
||||
|
||||
{% block left_panel %}
|
||||
<ul>
|
||||
<li><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">返回同步目录页面</a></li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% block right_panel %}
|
||||
<h2>{{repo.props.name}} 修改历史</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="20%">修改时间</th>
|
||||
<th width="80%">描述</th>
|
||||
</tr>
|
||||
{% for commit in commits %}
|
||||
<tr>
|
||||
<td>{{ commit.props.ctime|tsstr_sec }}</td>
|
||||
<td>{{ commit.props.desc }}</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>
|
||||
{% endblock %}
|
3
urls.py
3
urls.py
@ -3,7 +3,7 @@ from django.conf import settings
|
||||
from django.views.generic.simple import direct_to_template
|
||||
|
||||
from seahub.views import root, peers, groups, myhome, \
|
||||
repo, group, modify_token, remove_repo, seafadmin, useradmin, \
|
||||
repo, repo_history, group, modify_token, remove_repo, seafadmin, useradmin, \
|
||||
role_add, role_remove, activate_user, user_add, user_remove, \
|
||||
ownerhome, remove_fetched_repo, repo_set_public, repo_unset_public, \
|
||||
repo_list_dir, user_info, repo_set_access_property, repo_operation_file
|
||||
@ -30,6 +30,7 @@ urlpatterns = patterns('',
|
||||
url(r'^home/owner/(?P<owner_name>[^/]+)/$', ownerhome, name='ownerhome'),
|
||||
(r'^download/$', direct_to_template, { 'template': 'download.html' } ),
|
||||
(r'^repo/(?P<repo_id>[^/]+)/$', repo),
|
||||
(r'^repo/history/(?P<repo_id>[^/]+)/$', repo_history),
|
||||
(r'^repo/token/modify/(?P<repo_id>[^/]+)/$', modify_token),
|
||||
(r'^repo/remove/(?P<repo_id>[^/]+)/$', remove_repo),
|
||||
(r'^repo/removefetched/(?P<user_id>[^/]+)/(?P<repo_id>[^/]+)/$', remove_fetched_repo),
|
||||
|
43
views.py
43
views.py
@ -122,6 +122,31 @@ def validate_owner(request, repo_id):
|
||||
def repo(request, repo_id):
|
||||
# TODO: check permission
|
||||
repo = get_repo(repo_id)
|
||||
|
||||
recent_commits = get_commits(repo_id, 0, 3)
|
||||
|
||||
token = ""
|
||||
is_owner = False
|
||||
repo_ap = ""
|
||||
|
||||
if request.user.is_authenticated():
|
||||
if validate_owner(request, repo_id):
|
||||
is_owner = True
|
||||
token = seafserv_threaded_rpc.get_repo_token(repo_id)
|
||||
repo_ap = seafserv_threaded_rpc.repo_query_access_property(repo_id)
|
||||
|
||||
return render_to_response('repo.html', {
|
||||
"repo": repo,
|
||||
"recent_commits": recent_commits,
|
||||
"is_owner": is_owner,
|
||||
"repo_ap": repo_ap,
|
||||
"token": token,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def repo_history(request, repo_id):
|
||||
# TODO: check permission
|
||||
repo = get_repo(repo_id)
|
||||
try:
|
||||
current_page = int(request.GET.get('page', '1'))
|
||||
per_page= int(request.GET.get('per_page', '25'))
|
||||
@ -138,19 +163,7 @@ def repo(request, repo_id):
|
||||
page_next = False
|
||||
|
||||
|
||||
branches = get_branches(repo_id)
|
||||
|
||||
token = ""
|
||||
is_owner = False
|
||||
repo_ap = ""
|
||||
|
||||
if request.user.is_authenticated():
|
||||
if validate_owner(request, repo_id):
|
||||
is_owner = True
|
||||
token = seafserv_threaded_rpc.get_repo_token(repo_id)
|
||||
repo_ap = seafserv_threaded_rpc.repo_query_access_property(repo_id)
|
||||
|
||||
return render_to_response('repo.html', {
|
||||
return render_to_response('repo_history.html', {
|
||||
"repo": repo,
|
||||
"commits": commits,
|
||||
'current_page': current_page,
|
||||
@ -158,10 +171,6 @@ def repo(request, repo_id):
|
||||
'next_page': current_page+1,
|
||||
'per_page': per_page,
|
||||
'page_next': page_next,
|
||||
"branches": branches,
|
||||
"is_owner": is_owner,
|
||||
"repo_ap": repo_ap,
|
||||
"token": token,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user