mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
Add pubfile support
This commit is contained in:
@@ -196,6 +196,9 @@ p {
|
||||
.icon-star {
|
||||
color:#505050;
|
||||
}
|
||||
.edit-icon {
|
||||
cursor:pointer;
|
||||
}
|
||||
.op,
|
||||
.more {
|
||||
font-weight:normal;
|
||||
@@ -958,6 +961,9 @@ textarea:-moz-placeholder {/* for FF */
|
||||
width:260px;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
.input-area {
|
||||
height:80px;
|
||||
}
|
||||
#repo-desc {
|
||||
height:70px;
|
||||
}
|
||||
@@ -1289,17 +1295,24 @@ textarea:-moz-placeholder {/* for FF */
|
||||
display:block;
|
||||
padding:0 12px;
|
||||
}
|
||||
#mv-form {
|
||||
.file-choose-form {
|
||||
width:500px;
|
||||
padding:10px 20px;
|
||||
}
|
||||
#mv-dir-list {
|
||||
.file-tree-cont, .dir-tree-cont {
|
||||
padding:5px;
|
||||
height:280px;
|
||||
overflow:auto;
|
||||
border:1px solid #eee;
|
||||
margin:5px 0 10px;
|
||||
}
|
||||
.file-tree-cont .jstree-leaf a ins.jstree-icon {
|
||||
background: transparent url('../img/file-icon-16.png') no-repeat left center;
|
||||
vertical-align:top;
|
||||
}
|
||||
.file-tree-cont .jstree-leaf[repo_id] a ins.jstree-icon {
|
||||
background:transparent url('../jstree_pre1.0_stable/themes/classic/d.png') no-repeat scroll -56px -36px;
|
||||
}
|
||||
#mv-dir-list .tri-bg {
|
||||
margin-right:20px;
|
||||
margin-bottom:3px;
|
||||
|
BIN
media/img/file-icon-16.png
Normal file
BIN
media/img/file-icon-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 483 B |
@@ -15,6 +15,9 @@
|
||||
<li class="tabnav-tab"><a href="{% url 'group_info' group.id %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Discussion" %}</li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_wiki' group.id %}">{% trans "Wiki" %}</a></li>
|
||||
{% if group.is_pub %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
{% endif %}
|
||||
{% if group.view_perm != 'pub' %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_members' group.id %}">{% trans "Members" %}</a></li>
|
||||
{% endif %}
|
||||
|
@@ -16,6 +16,9 @@
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Libraries" %}</li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_wiki' group.id %}">{% trans "Wiki" %}</a></li>
|
||||
{% if group.is_pub %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
{% endif %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_members' group.id %}">{% trans "Members" %}</a></li>
|
||||
{% if is_staff %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_manage' group.id %}">{% trans "Admin" %}</a></li>
|
||||
|
@@ -16,6 +16,7 @@
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Libraries" %}</li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_wiki' group.id %}">{% trans "Wiki" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@@ -14,6 +14,9 @@
|
||||
<li class="tabnav-tab"><a href="{% url 'group_info' group.id %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_wiki' group.id %}">{% trans "Wiki" %}</a></li>
|
||||
{% if group.is_pub %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
{% endif %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_members' group.id %}">{% trans "Members" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Admin" %}</li>
|
||||
</ul>
|
||||
@@ -36,7 +39,7 @@
|
||||
<h3 class="info-item-top">{% trans "Operations" %}</h3>
|
||||
<ul class="info-item-bottom op-list">
|
||||
<li><a id="group-dismiss" href="#" data-url="{% url 'group_dismiss' group.id %}">{% trans "Dismiss" %}</a></li>
|
||||
{% if is_pub %}
|
||||
{% if group.is_pub %}
|
||||
<li><a href="{% url 'group_revoke_pub' group.id %}">{% trans "Revoke Public" %}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'group_make_pub' group.id %}">{% trans "Make Public" %}</a></li>
|
||||
|
@@ -16,6 +16,9 @@
|
||||
<li class="tabnav-tab"><a href="{% url 'group_info' group.id %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_wiki' group.id %}">{% trans "Wiki" %}</a></li>
|
||||
{% if group.is_pub %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
{% endif %}
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Members" %}</li>
|
||||
{% if is_staff %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_manage' group.id %}">{% trans "Admin" %}</a></li>
|
||||
|
@@ -16,6 +16,9 @@
|
||||
<li class="tabnav-tab"><a href="{% url 'group_info' group.id %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Wiki" %}</li>
|
||||
{% if group.is_pub %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
{% endif %}
|
||||
{% if group.view_perm != 'pub' %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_members' group.id %}">{% trans "Members" %}</a></li>
|
||||
{% endif %}
|
||||
|
@@ -15,6 +15,9 @@
|
||||
<li class="tabnav-tab"><a href="{% url 'group_info' group.id %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Wiki" %}</li>
|
||||
{% if group.is_pub %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_pubfiles' group.id %}">{% trans "Files" %}</a></li>
|
||||
{% endif %}
|
||||
{% if group.view_perm != 'pub' %}
|
||||
<li class="tabnav-tab"><a href="{% url 'group_members' group.id %}">{% trans "Members" %}</a></li>
|
||||
{% endif %}
|
||||
|
@@ -36,3 +36,17 @@ urlpatterns = patterns('',
|
||||
url(r'^attention/$', attention, name='group_attention'),
|
||||
url(r'^joinrequest/(?P<group_id>[\d]+)/$', group_joinrequest, name='group_joinrequest'),
|
||||
)
|
||||
|
||||
import seahub.settings as settings
|
||||
|
||||
if settings.ENABLE_PUBFILE:
|
||||
from seahub_extra.pubfile.views import group_pubfiles, group_pubfile_add, group_pubfile_delete, group_pubfile_edit, group_pubfile_download
|
||||
|
||||
urlpatterns += patterns('',
|
||||
url(r'^(?P<group_id>\d+)/files/$', group_pubfiles, name='group_pubfiles'),
|
||||
url(r'^(?P<group_id>\d+)/file/add/$', group_pubfile_add, name='group_pubfile_add'),
|
||||
url(r'^(?P<group_id>\d+)/file/(?P<file_id>\d+)/delete/$', group_pubfile_delete, name='group_pubfile_delete'),
|
||||
url(r'^(?P<group_id>\d+)/file/(?P<file_id>\d+)/edit/$', group_pubfile_edit, name='group_pubfile_edit'),
|
||||
url(r'^(?P<group_id>\d+)/file/(?P<file_id>\d+)/$', group_pubfile_download, name='group_pubfile_download'),
|
||||
)
|
||||
|
||||
|
@@ -84,9 +84,13 @@ def group_check(func):
|
||||
if not group:
|
||||
return HttpResponseRedirect(reverse('group_list', args=[]))
|
||||
group.is_staff = False
|
||||
if PublicGroup.objects.filter(group_id=group.id):
|
||||
group.is_pub = True
|
||||
else:
|
||||
group.is_pub = False
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
if not PublicGroup.objects.filter(group_id=group_id_int):
|
||||
if not group.is_pub:
|
||||
return render_to_response('group/group_pubinfo.html', {
|
||||
'group': group,
|
||||
}, context_instance=RequestContext(request))
|
||||
@@ -104,8 +108,7 @@ def group_check(func):
|
||||
group.view_perm = "sys_admin"
|
||||
return func(request, group, *args, **kwargs)
|
||||
|
||||
pub = PublicGroup.objects.filter(group_id=group_id_int)
|
||||
if pub:
|
||||
if group.is_pub:
|
||||
group.view_perm = "pub"
|
||||
return func(request, group, *args, **kwargs)
|
||||
|
||||
@@ -465,12 +468,6 @@ def group_info(request, group):
|
||||
request.user.username)
|
||||
cmt.tp = cmt.props.desc.split(' ')[0]
|
||||
|
||||
if PublicGroup.objects.filter(group_id=group.id):
|
||||
group.is_pub = True
|
||||
else:
|
||||
group.is_pub = False
|
||||
|
||||
|
||||
return render_to_response("group/group_info.html", {
|
||||
"members": members,
|
||||
"repos": repos,
|
||||
@@ -609,16 +606,15 @@ def group_manage(request, group_id):
|
||||
contacts = Contact.objects.filter(user_email=username)
|
||||
|
||||
if PublicGroup.objects.filter(group_id=group.id):
|
||||
is_pub = True
|
||||
group.is_pub = True
|
||||
else:
|
||||
is_pub = False
|
||||
group.is_pub = False
|
||||
|
||||
return render_to_response('group/group_manage.html', {
|
||||
'group' : group,
|
||||
'members': members_all,
|
||||
'admins': admins,
|
||||
'contacts': contacts,
|
||||
'is_pub': is_pub,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
|
@@ -169,6 +169,7 @@ INSTALLED_APPS = (
|
||||
'seahub.share',
|
||||
)
|
||||
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'seahub.base.accounts.AuthBackend',
|
||||
)
|
||||
@@ -326,6 +327,12 @@ LOGGING = {
|
||||
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True # Whether to send email when a system staff adding new member.
|
||||
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True # Whether to send email when a system staff resetting user's password.
|
||||
|
||||
##########################
|
||||
# Settings for Extra App #
|
||||
##########################
|
||||
|
||||
ENABLE_PUBFILE = False
|
||||
|
||||
#####################
|
||||
# External settings #
|
||||
#####################
|
||||
@@ -388,3 +395,4 @@ SEAFILE_VERSION = '1.6'
|
||||
# Put here after loading other settings files if `SITE_ROOT` is modified in
|
||||
# other settings files.
|
||||
LOGIN_URL = SITE_ROOT + 'accounts/login'
|
||||
|
||||
|
@@ -40,7 +40,7 @@
|
||||
<td>
|
||||
<div class="share-permission">
|
||||
<span class="share-permission-cur-value">{{ repo.share_permission }}</span>
|
||||
<img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%} icon" title="{% trans "Edit"%}" class="share-permission-edit-icon vh" />
|
||||
<img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="share-permission-edit-icon vh" />
|
||||
</div>
|
||||
<select name="permission" class="share-permission-select hide">
|
||||
<option value="{{ repo.props.permission }}" selected="selected">{{ repo.share_permission }}</option>
|
||||
|
@@ -312,10 +312,10 @@
|
||||
<button class="simplemodal-close">{% trans "Cancel"%}</button>
|
||||
</form>
|
||||
|
||||
<form id="mv-form" action="{{ SITE_ROOT }}file/move/" method="post" class="hide">{% csrf_token %}
|
||||
<form id="mv-form" action="{{ SITE_ROOT }}file/move/" method="post" class="file-choose-form hide">{% csrf_token %}
|
||||
<h3 id="mv-hd"></h3>
|
||||
<h4 id="mv-detail"></h4>
|
||||
<div id="mv-dir-list">
|
||||
<div id="mv-dir-list" class="dir-tree-cont">
|
||||
<h5><span class="tri-bg tri-down-bg"></span>{% trans "Current Library"%}</h5>
|
||||
<div id="current-repo-dirs"></div>
|
||||
<h5><span class="tri-bg tri-right-bg"></span>{% trans "Other Libraries"%}</h5>
|
||||
@@ -871,17 +871,17 @@ function renderDirTree(container, repo_data) {
|
||||
}
|
||||
})
|
||||
.bind('select_node.jstree', function(e, data) {
|
||||
var path;
|
||||
var repo_id = data.rslt.obj.attr('repo_id') || data.inst._get_parent(data.rslt.obj).attr('repo_id');
|
||||
$('input[name="dst_repo"]').attr('value', repo_id);
|
||||
var path = data.inst.get_path(data.rslt.obj);
|
||||
var mv_dst_path = '';
|
||||
if (path.length == 1) {
|
||||
mv_dst_path = '/';
|
||||
var path_array = data.inst.get_path(data.rslt.obj);
|
||||
if (path_array.length == 1) {
|
||||
path = '/';
|
||||
} else {
|
||||
path.shift();
|
||||
mv_dst_path = '/' + path.join('/') + '/';
|
||||
path_array.shift();
|
||||
path = '/' + path_array.join('/') + '/';
|
||||
}
|
||||
$('input[name="dst_path"]').attr('value', mv_dst_path);
|
||||
$('input[name="dst_repo"]').val(repo_id);
|
||||
$('input[name="dst_path"]').val(path);
|
||||
})
|
||||
.jstree({
|
||||
'json_data': {
|
||||
@@ -896,7 +896,7 @@ function renderDirTree(container, repo_data) {
|
||||
path.shift();
|
||||
path = '/' + path.join('/') + '/';
|
||||
}
|
||||
return '{{ SITE_ROOT }}file/move/get_subdir/?repo_id=' + e(repo_id) + '&path=' + e(path);
|
||||
return '{{ SITE_ROOT }}ajax/repo/' + repo_id + '/dir/?path=' + e(path);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -86,7 +86,8 @@ urlpatterns = patterns('',
|
||||
(r'^pdf_full_view/$', pdf_full_view),
|
||||
url(r'^i18n/$', i18n, name='i18n'),
|
||||
(r'^download/repo/$', repo_download),
|
||||
(r'^file/move/get_subdir/$', get_subdir),
|
||||
(r'^ajax/repo/(?P<repo_id>[-0-9a-f]{36})/dir/$', get_subdir),
|
||||
(r'^ajax/repo/(?P<repo_id>[-0-9a-f]{36})/file/$', get_dirents),
|
||||
(r'^file/move/$', file_move),
|
||||
(r'^seafile_access_check/$', seafile_access_check),
|
||||
url(r'^org/remove/(?P<org_id>[\d]+)/$', org_remove, name="org_remove"),
|
||||
|
@@ -407,8 +407,15 @@ def update_file_error(request, repo_id):
|
||||
'err_msg': err_msg,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
def get_subdir(request):
|
||||
repo_id = request.GET.get('repo_id', '')
|
||||
@login_required
|
||||
def get_subdir(request, repo_id):
|
||||
'''
|
||||
Get only subdirs in a dir for file tree
|
||||
'''
|
||||
user_perm = get_user_permission(request, repo_id)
|
||||
if not user_perm:
|
||||
return render_error(request)
|
||||
|
||||
path = request.GET.get('path', '')
|
||||
|
||||
if not (repo_id and path):
|
||||
@@ -426,7 +433,7 @@ def get_subdir(request):
|
||||
continue
|
||||
|
||||
dirent.has_subdir = False
|
||||
path_ = os.path.join (path, dirent.obj_name)
|
||||
path_ = os.path.join(path, dirent.obj_name)
|
||||
try:
|
||||
dirs_ = seafserv_threaded_rpc.list_dir_by_path(latest_commit.id, path_.encode('utf-8'))
|
||||
except SearpcError, e:
|
||||
@@ -451,6 +458,42 @@ def get_subdir(request):
|
||||
return HttpResponse(json.dumps(subdirs),
|
||||
content_type=content_type)
|
||||
|
||||
@login_required
|
||||
def get_dirents(request, repo_id):
|
||||
'''
|
||||
Get dirents in a dir for file tree
|
||||
'''
|
||||
user_perm = get_user_permission(request, repo_id)
|
||||
if not user_perm:
|
||||
return render_error(request)
|
||||
|
||||
path = request.GET.get('path', '')
|
||||
|
||||
if not (repo_id and path):
|
||||
return render_error(request)
|
||||
|
||||
latest_commit = get_commits(repo_id, 0, 1)[0]
|
||||
try:
|
||||
dirents = seafserv_threaded_rpc.list_dir_by_path(latest_commit.id, path.encode('utf-8'))
|
||||
except SearpcError, e:
|
||||
return render_error(request, e.msg)
|
||||
|
||||
dirent_list = []
|
||||
for dirent in dirents:
|
||||
if stat.S_ISDIR(dirent.props.mode):
|
||||
subdir = {
|
||||
'data': dirent.obj_name,
|
||||
'attr': {'repo_id': repo_id },
|
||||
'state': 'closed'
|
||||
}
|
||||
dirent_list.append(subdir)
|
||||
else:
|
||||
dirent_list.append(dirent.obj_name)
|
||||
|
||||
content_type = 'application/json; charset=utf-8'
|
||||
return HttpResponse(json.dumps(dirent_list),
|
||||
content_type=content_type)
|
||||
|
||||
@login_required
|
||||
def repo_history(request, repo_id):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user