mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-15 16:04:01 +00:00
parent
f55137c58f
commit
a35af2eea8
@ -14,3 +14,13 @@ DEFAULT_ADMIN = 'default_admin'
|
||||
SYSTEM_ADMIN = 'system_admin'
|
||||
DAILY_ADMIN = 'daily_admin'
|
||||
AUDIT_ADMIN = 'audit_admin'
|
||||
|
||||
HASH_URLS = {
|
||||
'VIEW_COMMON_LIB_DIR': u'/#common/lib/%(repo_id)s/%(path)s',
|
||||
'GROUP_INFO': u'/#group/%(group_id)s/',
|
||||
'GROUP_MEMBERS': u'/#group/%(group_id)s/members/',
|
||||
'GROUP_DISCUSS': u'/#group/%(group_id)s/discussions/',
|
||||
'GROUP_LIST': u'/#groups/',
|
||||
'SYS_REPO_ADMIN': u'/sysadmin/#all-libs/',
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
{% block left_panel %}
|
||||
<div class="hd">
|
||||
<h3>
|
||||
{% grp_avatar group.props.id 32 %} <a title="{{ group.group_name }}" class="grp-name ellipsis vam" href="{% url 'group_info' group.id %}">{{ group.group_name }}</a>
|
||||
{% grp_avatar group.props.id 32 %} <a title="{{ group.group_name }}" class="grp-name ellipsis vam" href="{{ SITE_ROOT }}#group/{{ group.id }}/%}">{{ group.group_name }}</a>
|
||||
</h3>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -38,6 +38,7 @@ from seahub.views import is_registered_user, check_folder_permission
|
||||
from seahub.views.modules import get_enabled_mods_by_group, \
|
||||
get_available_mods_by_group
|
||||
from seahub.share.models import ExtraGroupsSharePermission
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
from seahub.forms import SharedRepoCreateForm
|
||||
|
||||
@ -93,7 +94,7 @@ def group_check(func):
|
||||
group_id_int = int(group_id) # Checked by URL Conf
|
||||
group = get_group(group_id_int)
|
||||
if not group:
|
||||
return HttpResponseRedirect(reverse('group_list', args=[]))
|
||||
return HttpResponseRedirect(HASH_URLS['GROUP_LIST'])
|
||||
group.is_staff = False
|
||||
if PublicGroup.objects.filter(group_id=group.id):
|
||||
group.is_pub = True
|
||||
|
@ -78,7 +78,7 @@
|
||||
{% if repo.encrypted %}
|
||||
<td>{{ repo.name }}</td>
|
||||
{% elif enable_sys_admin_view_repo %}
|
||||
<td><a href="{% url 'sys_admin_repo' repo.id %}">{{ repo.name }}</a></td>
|
||||
<td><a href="{{ SITE_ROOT }}sysadmin/#libs/{{ repo.id }}/">{{ repo.name }}</a></td>
|
||||
{% else %}
|
||||
<td>{{ repo.name }}</td>
|
||||
{% endif %}
|
||||
|
@ -22,6 +22,7 @@ from seahub.avatar.util import get_default_avatar_url
|
||||
from seahub.base.templatetags.seahub_tags import email2nickname
|
||||
from seahub.invitations.models import Invitation
|
||||
from seahub.profile.models import Profile
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
# Get an instance of a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -73,7 +74,7 @@ class Command(BaseCommand):
|
||||
message = d['message']
|
||||
group = ccnet_api.get_group(int(group_id))
|
||||
|
||||
notice.group_url = reverse('group_discuss', args=[group.id])
|
||||
notice.group_url = HASH_URLS['GROUP_DISCUSS'] % {'group_id': group.id}
|
||||
notice.notice_from = escape(email2nickname(d['msg_from']))
|
||||
notice.group_name = group.group_name
|
||||
notice.avatar_src = self.get_avatar_src(d['msg_from'])
|
||||
@ -85,7 +86,7 @@ class Command(BaseCommand):
|
||||
repo_id = d['repo_id']
|
||||
repo = seafile_api.get_repo(repo_id)
|
||||
|
||||
notice.repo_url = reverse("view_common_lib_dir", args=[repo_id, ''])
|
||||
notice.repo_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
notice.notice_from = escape(email2nickname(d['share_from']))
|
||||
notice.repo_name = repo.name
|
||||
notice.avatar_src = self.get_avatar_src(d['share_from'])
|
||||
@ -100,11 +101,11 @@ class Command(BaseCommand):
|
||||
group_id = d['group_id']
|
||||
group = ccnet_api.get_group(group_id)
|
||||
|
||||
notice.repo_url = reverse("view_common_lib_dir", args=[repo_id, ''])
|
||||
notice.repo_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
notice.notice_from = escape(email2nickname(d['share_from']))
|
||||
notice.repo_name = repo.name
|
||||
notice.avatar_src = self.get_avatar_src(d['share_from'])
|
||||
notice.group_url = reverse("group_info", args=[group.id])
|
||||
notice.group_url = HASH_URLS['GROUP_INFO'] % {'group_id': group.id}
|
||||
notice.group_name = group.group_name
|
||||
|
||||
return notice
|
||||
@ -117,7 +118,7 @@ class Command(BaseCommand):
|
||||
uploaded_to = d['uploaded_to'].rstrip('/')
|
||||
file_path = uploaded_to + '/' + file_name
|
||||
file_link = reverse('view_lib_file', args=[repo_id, file_path])
|
||||
folder_link = reverse('view_common_lib_dir', args=[repo_id, uploaded_to.strip('/')])
|
||||
folder_link = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': uploaded_to.strip('/')}
|
||||
folder_name = os.path.basename(uploaded_to)
|
||||
|
||||
notice.file_link = file_link
|
||||
@ -137,7 +138,7 @@ class Command(BaseCommand):
|
||||
|
||||
notice.grpjoin_user_profile_url = reverse('user_profile',
|
||||
args=[username])
|
||||
notice.grpjoin_group_url = reverse('group_members', args=[group_id])
|
||||
notice.grpjoin_group_url = HASH_URLS['GROUP_MEMBERS'] % {'group_id': group_id}
|
||||
notice.notice_from = escape(email2nickname(username))
|
||||
notice.grpjoin_group_name = group.group_name
|
||||
notice.grpjoin_request_msg = join_request_msg
|
||||
@ -155,7 +156,7 @@ class Command(BaseCommand):
|
||||
notice.avatar_src = self.get_avatar_src(group_staff)
|
||||
notice.group_staff_profile_url = reverse('user_profile',
|
||||
args=[group_staff])
|
||||
notice.group_url = reverse('group_info', args=[group_id])
|
||||
notice.group_url = HASH_URLS['GROUP_INFO'] % {'group_id': group_id}
|
||||
notice.group_name = group.group_name
|
||||
return notice
|
||||
|
||||
|
@ -21,6 +21,7 @@ from seahub.invitations.models import Invitation
|
||||
from seahub.utils.repo import get_repo_shared_users
|
||||
from seahub.utils import normalize_cache_key
|
||||
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
# Get an instance of a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -460,12 +461,13 @@ class UserNotification(models.Model):
|
||||
if d['uploaded_to'] == '/':
|
||||
# current upload path is '/'
|
||||
file_path = '/' + filename
|
||||
link = reverse('view_common_lib_dir', args=[repo_id, ''])
|
||||
link = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
name = repo.name
|
||||
else:
|
||||
uploaded_to = d['uploaded_to'].rstrip('/')
|
||||
file_path = uploaded_to + '/' + filename
|
||||
link = reverse('view_common_lib_dir', args=[repo_id, uploaded_to.lstrip('/')])
|
||||
link = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id,
|
||||
'path': uploaded_to.lstrip('/')}
|
||||
name = os.path.basename(uploaded_to)
|
||||
|
||||
file_link = reverse('view_lib_file', args=[repo_id, file_path])
|
||||
@ -521,7 +523,7 @@ class UserNotification(models.Model):
|
||||
|
||||
msg = _(u"%(user)s has shared a library named <a href='%(href)s'>%(repo_name)s</a> to you.") % {
|
||||
'user': escape(share_from),
|
||||
'href': reverse('view_common_lib_dir', args=[repo.id, '']),
|
||||
'href': HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id':repo.id, 'path': ''},
|
||||
'repo_name': escape(repo.name),
|
||||
}
|
||||
|
||||
@ -568,9 +570,9 @@ class UserNotification(models.Model):
|
||||
|
||||
msg = _(u"%(user)s has shared a library named <a href='%(repo_href)s'>%(repo_name)s</a> to group <a href='%(group_href)s'>%(group_name)s</a>.") % {
|
||||
'user': escape(share_from),
|
||||
'repo_href': reverse('view_common_lib_dir', args=[repo.id, '']),
|
||||
'repo_href': HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo.id, 'path': ''},
|
||||
'repo_name': escape(repo.name),
|
||||
'group_href': reverse('group_info', args=[group.id]),
|
||||
'group_href': HASH_URLS['GROUP_INFO'] % {'group_id': group.id},
|
||||
'group_name': escape(group.group_name),
|
||||
}
|
||||
|
||||
@ -598,11 +600,11 @@ class UserNotification(models.Model):
|
||||
|
||||
if msg_from is None:
|
||||
msg = _(u"<a href='%(href)s'>%(group_name)s</a> has a new discussion.") % {
|
||||
'href': reverse('group_discuss', args=[group.id]),
|
||||
'href': HASH_URLS['GROUP_DISCUSS'] % {'group_id': group.id},
|
||||
'group_name': group.group_name}
|
||||
else:
|
||||
msg = _(u"%(user)s posted a new discussion in <a href='%(href)s'>%(group_name)s</a>.") % {
|
||||
'href': reverse('group_discuss', args=[group.id]),
|
||||
'href': HASH_URLS['GROUP_DISCUSS'] % {'group_id': group.id},
|
||||
'user': escape(email2nickname(msg_from)),
|
||||
'group_name': escape(group.group_name)
|
||||
}
|
||||
@ -650,7 +652,7 @@ class UserNotification(models.Model):
|
||||
msg = _(u"User <a href='%(user_profile)s'>%(username)s</a> has asked to join group <a href='%(href)s'>%(group_name)s</a>, verification message: %(join_request_msg)s") % {
|
||||
'user_profile': reverse('user_profile', args=[username]),
|
||||
'username': username,
|
||||
'href': reverse('group_members', args=[group_id]),
|
||||
'href': HASH_URLS['GROUP_MEMBERS'] % {'group_id': group_id},
|
||||
'group_name': escape(group.group_name),
|
||||
'join_request_msg': escape(join_request_msg),
|
||||
}
|
||||
@ -679,7 +681,7 @@ class UserNotification(models.Model):
|
||||
msg = _(u"User <a href='%(user_profile)s'>%(group_staff)s</a> has added you to group <a href='%(href)s'>%(group_name)s</a>") % {
|
||||
'user_profile': reverse('user_profile', args=[group_staff]),
|
||||
'group_staff': group_staff,
|
||||
'href': reverse('group_info', args=[group_id]),
|
||||
'href': HASH_URLS['GROUP_INFO'] % {'group_id': group_id},
|
||||
'group_name': escape(group.group_name)}
|
||||
return msg
|
||||
|
||||
|
@ -118,7 +118,7 @@
|
||||
<div class="setting-item" id="default-lib">
|
||||
<h3>{% trans "Default Library Setting" %}</h3>
|
||||
{% if default_repo %}
|
||||
<p>{% trans "Your default library:" %} <a href="{% url 'view_common_lib_dir' default_repo.id '' %}">{{default_repo.name}}</a>.</p>
|
||||
<p>{% trans "Your default library:" %} <a href="{{ SITE_ROOT }}#common/lib/{{ default_repo.id }}/">{{default_repo.name}}</a>.</p>
|
||||
{% endif %}
|
||||
<p class="txt-before-btn">{% trans "Default library is the default place to store your personal documents and pictures." %}</p>
|
||||
<button id="choose-default-lib">{% trans "Choose Default Library" %}</button>
|
||||
|
@ -10,7 +10,7 @@
|
||||
{% trans 'Current Path:' %}
|
||||
{% for name, link in zipped %}
|
||||
{% if not forloop.last %}
|
||||
<a href="{% url 'view_common_lib_dir' repo.id link|strip_slash %}">{{ name }}</a> /
|
||||
<a href="{{ SITE_ROOT }}#common/lib/{{ repo.id }}/{{ link|strip_slash }}">{{ name }}</a> /
|
||||
{% else %}
|
||||
<a href="{% url 'view_lib_file' repo.id path %}" target="_blank" >{{ name }}</a>
|
||||
{% endif %}
|
||||
|
@ -89,7 +89,7 @@
|
||||
{% trans "Current path: " %}
|
||||
{% for name, link in zipped %}
|
||||
{% if not forloop.last %}
|
||||
<a href="{% url 'view_common_lib_dir' repo.id link|strip_slash %}">{{ name }}</a> /
|
||||
<a href="{{ SITE_ROOT }}#common/lib/{{ repo.id }}/{{ link|strip_slash }}">{{ name }}</a> /
|
||||
{% else %}
|
||||
<a href="{% url 'view_lib_file' repo.id path %}" target="_blank">{{ name }}</a>
|
||||
{% endif %}
|
||||
|
@ -26,7 +26,7 @@
|
||||
{% trans 'Current Path:' %}
|
||||
{% for name, link in zipped %}
|
||||
{% if not forloop.last %}
|
||||
<a href="{% url 'view_common_lib_dir' repo.id link|strip_slash %}">{{ name }}</a> /
|
||||
<a href="{{ SITE_ROOT }}#common/lib/{{ repo.id }}/{{ link|strip_slash }}">{{ name }}</a> /
|
||||
{% else %}
|
||||
<a href="{% url 'view_lib_file' repo.id path %}" target="_blank" >{{ name }}</a>
|
||||
{% endif %}
|
||||
|
@ -23,7 +23,7 @@
|
||||
<a href="#" class="ellipsis" title="{% trans "Shared with groups" %}"><span class="toggle-icon icon-caret-left fright" aria-hidden="true"></span><span class="sf2-icon-group" aria-hidden="true"></span>{% trans "Shared with groups" %}</a>
|
||||
<ul class="grp-list hide">
|
||||
<li>
|
||||
<a href="{% url 'group_list' %}"><span class="sharp" aria-hidden="true">#</span>{% trans "All Groups" %}</a>
|
||||
<a href="{{ SITE_ROOT }}#groups/"><span class="sharp" aria-hidden="true">#</span>{% trans "All Groups" %}</a>
|
||||
</li>
|
||||
{% for grp in grps %}
|
||||
<li>
|
||||
|
@ -104,18 +104,18 @@
|
||||
</ul>
|
||||
<% if (cur_tab == 'libraries') { %>
|
||||
<% if (option == 'all') { %>
|
||||
<form action="{% url 'sys_repo_search' %}" method="get" class="side-search-form" id="libs-search-form">
|
||||
<form action="{{ SITE_ROOT }}sysadmin/#search-libs/" method="get" class="side-search-form" id="libs-search-form">
|
||||
<input type="text" name="name" class="input" value="" placeholder="{% trans "Search libraries by name..." %}" title="{% trans "Search libraries by name..." %}" aria-label="{% trans "Search libraries by name..." %}" />
|
||||
</form>
|
||||
<% } %>
|
||||
<% if (option == 'trash') { %>
|
||||
<form action="{% url 'sys_trash_repo_search' %}" method="get" class="side-search-form" id="trash-libs-search-form">
|
||||
<form action="{{ SITE_ROOT }}sysadmin/#search-trash-libs/" method="get" class="side-search-form" id="trash-libs-search-form">
|
||||
<input type="text" name="name" class="input" value="" placeholder="{% trans "Search libraries by owner..." %}" title="{% trans "Search libraries by owner..." %}" aria-label="{% trans "Search libraries by owner..." %}" />
|
||||
</form>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (cur_tab == 'groups') { %>
|
||||
<form action="{% url 'sys_group_search' %}" method="get" class="side-search-form" id="groups-search-form">
|
||||
<form action="{{ SITE_ROOT }}sysadmin/#search-groups/" method="get" class="side-search-form" id="groups-search-form">
|
||||
<input type="text" name="name" class="input" value="" placeholder="{% trans "Search groups by name..." %}" title="{% trans "Search groups by name..." %}" aria-label="{% trans "Search groups by name..." %}" />
|
||||
</form>
|
||||
<% } %>
|
||||
|
@ -1323,7 +1323,7 @@
|
||||
<li class="tab" id="group-nav">
|
||||
<a href="#" class="ellipsis" title="{% trans "Shared with groups" %}"><span aria-hidden="true" class="toggle-icon icon-caret-down fright"></span><span aria-hidden="true" class="sf2-icon-group"></span>{% trans "Shared with groups" %}</a>
|
||||
<ul class="grp-list">
|
||||
<li<% if (cur_group_tab == 'groups') { %> class="tab-cur"<% }%>><a href="{% url 'group_list' %}"><span class="sharp" aria-hidden="true">#</span>{% trans "All Groups" %}</a></li>
|
||||
<li<% if (cur_group_tab == 'groups') { %> class="tab-cur"<% }%>><a href="{{ SITE_ROOT }}#groups/"><span class="sharp" aria-hidden="true">#</span>{% trans "All Groups" %}</a></li>
|
||||
<% for (var i = 0, len = groups.length; i < len; i++) { %>
|
||||
<% if (cur_group_id == groups[i].id) { %>
|
||||
<li class="tab-cur">
|
||||
@ -1345,7 +1345,7 @@
|
||||
<ul class="grp-list hide">
|
||||
<% } %>
|
||||
<li>
|
||||
<a href="{% url 'group_list' %}"><span class="sharp" aria-hidden="true">#</span>{% trans "All Groups" %}</a>
|
||||
<a href="{{ SITE_ROOT }}#groups/"><span class="sharp" aria-hidden="true">#</span>{% trans "All Groups" %}</a>
|
||||
</li>
|
||||
<% for (var i = 0, len = groups.length; i < len; i++) { %>
|
||||
<li>
|
||||
@ -1452,7 +1452,7 @@
|
||||
{% endif %}
|
||||
</script>
|
||||
<script type="text/template" id="group-path-tmpl">
|
||||
<a href="{% url 'group_list' %}" class="normal">{% trans "Groups" %}</a>
|
||||
<a href="{{ SITE_ROOT }}#groups/" class="normal">{% trans "Groups" %}</a>
|
||||
<span class="path-split">/</span>
|
||||
<span class="group-name"><%- name %></span>
|
||||
</script>
|
||||
|
@ -204,7 +204,7 @@
|
||||
{% if repo.encrypted %}
|
||||
<td>{{ repo.name }}</td>
|
||||
{% elif enable_sys_admin_view_repo %}
|
||||
<td><a href="{% url 'sys_admin_repo' repo.id %}">{{ repo.name }}</a></td>
|
||||
<td><a href="{{ SITE_ROOT }}sysadmin/#libs/{{ repo.id }}/">{{ repo.name }}</a></td>
|
||||
{% else %}
|
||||
<td>{{ repo.name }}</td>
|
||||
{% endif %}
|
||||
@ -249,7 +249,7 @@
|
||||
<td><img src="{{MEDIA_URL}}img/lib/48/lib.png" width="24" title="{% trans "Read-Write" %}" alt="{% trans "library icon" %}" /></td>
|
||||
{% endif %}
|
||||
{% if enable_sys_admin_view_repo %}
|
||||
<td><a href="{% url 'sys_admin_repo' repo.id %}">{{ repo.name }}</a></td>
|
||||
<td><a href="{{ SITE_ROOT }}sysadmin/#libs/{{ repo.id }}/">{{ repo.name }}</a></td>
|
||||
{% else %}
|
||||
<td>{{ repo.name }}</td>
|
||||
{% endif %}
|
||||
|
@ -21,7 +21,7 @@
|
||||
{% trans "Current Path:" %}
|
||||
{% for name, link in zipped %}
|
||||
{% if not forloop.last %}
|
||||
<a href="{% url 'view_common_lib_dir' repo.id link|strip_slash %}">{{ name }}</a> /
|
||||
<a href="{{ SITE_ROOT }}#common/lib/{{ repo.id }}/{{ link|strip_slash }}">{{ name }}</a> /
|
||||
{% else %}
|
||||
<a href="{% url 'view_lib_file' repo.id link %}">{{ name }}</a>
|
||||
{% endif %}
|
||||
|
@ -57,7 +57,7 @@
|
||||
</div>
|
||||
|
||||
<div class="sf-btn-group file-view-op">
|
||||
<a class="sf-btn-group-btn sf-btn-group-btn-first sf-btn-link op-icon sf2-icon-folder" href="{% url 'view_common_lib_dir' repo.id parent_dir|strip_slash %}" title="{% trans "Open parent folder" %}"></a>
|
||||
<a class="sf-btn-group-btn sf-btn-group-btn-first sf-btn-link op-icon sf2-icon-folder" href="{{ SITE_ROOT }}#common/lib/{{ repo.id }}/{{ parent_dir|strip_slash }}" title="{% trans "Open parent folder" %}"></a>
|
||||
|
||||
{% if can_lock_unlock_file %}
|
||||
{% if not file_locked %}
|
||||
|
@ -54,6 +54,7 @@ import seahub.settings as settings
|
||||
from seahub.settings import AVATAR_FILE_STORAGE, ENABLE_STORAGE_CLASSES, \
|
||||
ENABLE_SUB_LIBRARY, ENABLE_FOLDER_PERM, ENABLE_REPO_SNAPSHOT_LABEL, \
|
||||
UNREAD_NOTIFICATIONS_REQUEST_INTERVAL
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
LIBRARY_TEMPLATES = getattr(settings, 'LIBRARY_TEMPLATES', {})
|
||||
|
||||
@ -175,7 +176,7 @@ def get_repo_dirents(request, repo, commit, path, offset=-1, limit=-1):
|
||||
uploadlinks = UploadLinkShare.objects.filter(repo_id=repo.id).filter(username=username)
|
||||
|
||||
|
||||
view_dir_base = reverse("view_common_lib_dir", args=[repo.id, ''])
|
||||
view_dir_base = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo.id, 'path': ''}
|
||||
dl_dir_base = reverse('repo_download_dir', args=[repo.id])
|
||||
file_history_base = reverse('file_revisions', args=[repo.id])
|
||||
for dirent in dirs:
|
||||
@ -471,7 +472,8 @@ def repo_history(request, repo_id):
|
||||
return render_error(request, e.msg)
|
||||
|
||||
if not password_set:
|
||||
return HttpResponseRedirect(reverse("view_common_lib_dir", args=[repo_id, '']))
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
|
||||
try:
|
||||
current_page = int(request.GET.get('page', '1'))
|
||||
@ -555,7 +557,8 @@ def repo_revert_history(request, repo_id):
|
||||
return render_error(request, e.msg)
|
||||
|
||||
if not password_set:
|
||||
return HttpResponseRedirect(reverse("view_common_lib_dir", args=[repo_id, '']))
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
|
||||
commit_id = request.GET.get('commit_id', '')
|
||||
if not commit_id:
|
||||
@ -579,7 +582,7 @@ def repo_revert_history(request, repo_id):
|
||||
def fpath_to_link(repo_id, path, is_dir=False):
|
||||
"""Translate file path of a repo to its view link"""
|
||||
if is_dir:
|
||||
href = reverse("view_common_lib_dir", args=[repo_id, path.encode('utf-8').strip('/')])
|
||||
href = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': path.encode('utf-8').strip('/')}
|
||||
else:
|
||||
if not path.startswith('/'):
|
||||
p = '/' + path
|
||||
@ -736,8 +739,9 @@ def libraries(request):
|
||||
def repo_set_access_property(request, repo_id):
|
||||
ap = request.GET.get('ap', '')
|
||||
seafserv_threaded_rpc.repo_set_access_property(repo_id, ap)
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
|
||||
return HttpResponseRedirect(reverse("view_common_lib_dir", args=[repo_id, '']))
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
|
||||
@login_required
|
||||
def validate_filename(request):
|
||||
@ -1003,15 +1007,14 @@ def convert_cmmt_desc_link(request):
|
||||
elif d.status == 'mov': # Move or Rename non-empty file/folder
|
||||
if '/' in d.new_name:
|
||||
new_dir_name = d.new_name.split('/')[0]
|
||||
return HttpResponseRedirect(
|
||||
reverse('view_common_lib_dir',
|
||||
args=[repo_id, new_dir_name]))
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': new_dir_name}
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
else:
|
||||
return HttpResponseRedirect(
|
||||
reverse('view_lib_file', args=[repo_id, '/' + d.new_name]))
|
||||
elif d.status == 'newdir':
|
||||
return HttpResponseRedirect(
|
||||
reverse('view_common_lib_dir', args=[repo_id, d.name.strip('/')]))
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': d.name.strip('/')},
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
else:
|
||||
continue
|
||||
|
||||
|
@ -55,6 +55,7 @@ from seahub.share.utils import is_repo_admin
|
||||
from seahub.base.templatetags.seahub_tags import translate_seahub_time, \
|
||||
email2nickname, tsstr_sec
|
||||
from seahub.constants import PERMISSION_ADMIN
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
# Get an instance of a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -752,7 +753,7 @@ def mv_dirents(request, src_repo_id, src_path, dst_repo_id, dst_path,
|
||||
success.append(obj_name)
|
||||
|
||||
if len(success) > 0:
|
||||
url = reverse("view_common_lib_dir", args=[dst_repo_id, dst_path.strip('/')])
|
||||
url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': dst_repo_id, 'path': dst_path.strip('/')},
|
||||
|
||||
result = {'success': success, 'failed': failed, 'url': url}
|
||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||
@ -795,7 +796,7 @@ def cp_dirents(request, src_repo_id, src_path, dst_repo_id, dst_path, obj_file_n
|
||||
success.append(obj_name)
|
||||
|
||||
if len(success) > 0:
|
||||
url = reverse("view_common_lib_dir", args=[dst_repo_id, dst_path.strip('/')])
|
||||
url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': dst_repo_id, 'path': dst_path.strip('/')},
|
||||
|
||||
result = {'success': success, 'failed': failed, 'url': url}
|
||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||
|
@ -67,6 +67,8 @@ from seahub.utils.file_op import check_file_lock
|
||||
from seahub.views import check_folder_permission, \
|
||||
get_unencry_rw_repos_by_user
|
||||
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
if HAS_OFFICE_CONVERTER:
|
||||
from seahub.utils import (
|
||||
query_office_convert_status, add_office_convert_task,
|
||||
@ -1381,7 +1383,8 @@ def download_file(request, repo_id, obj_id):
|
||||
raise Http404
|
||||
|
||||
if repo.encrypted and not seafile_api.is_password_set(repo_id, username):
|
||||
return HttpResponseRedirect(reverse('view_common_lib_dir', args=[repo_id, '']))
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
|
||||
# only check the permissions at the repo level
|
||||
# to prevent file can not be downloaded on the history page
|
||||
|
@ -31,6 +31,7 @@ from seahub.settings import ENABLE_UPLOAD_FOLDER, \
|
||||
MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD
|
||||
from seahub.utils.file_types import IMAGE, VIDEO
|
||||
from seahub.thumbnail.utils import get_share_link_thumbnail_src
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
# Get an instance of a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -127,17 +128,18 @@ def repo_history_view(request, repo_id):
|
||||
# Assume server_crypto is ``False`` if this option is not set.
|
||||
server_crypto = False
|
||||
|
||||
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''}
|
||||
if repo.encrypted and \
|
||||
(repo.enc_version == 1 or (repo.enc_version == 2 and server_crypto)) \
|
||||
and not is_password_set(repo.id, username):
|
||||
return render(request, 'decrypt_repo_form.html', {
|
||||
'repo': repo,
|
||||
'next': get_next_url_from_request(request) or reverse("view_common_lib_dir", args=[repo_id, '']),
|
||||
'next': get_next_url_from_request(request) or reverse_url,
|
||||
})
|
||||
|
||||
commit_id = request.GET.get('commit_id', None)
|
||||
if commit_id is None:
|
||||
return HttpResponseRedirect(reverse("view_common_lib_dir", args=[repo_id, '']))
|
||||
return HttpResponseRedirect(reverse_url)
|
||||
current_commit = get_commit(repo.id, repo.version, commit_id)
|
||||
if not current_commit:
|
||||
current_commit = get_commit(repo.id, repo.version, repo.head_cmmt_id)
|
||||
|
@ -36,7 +36,7 @@ from seahub.base.templatetags.seahub_tags import tsstr_sec, email2nickname
|
||||
from seahub.auth import authenticate
|
||||
from seahub.auth.decorators import login_required, login_required_ajax
|
||||
from seahub.constants import GUEST_USER, DEFAULT_USER, DEFAULT_ADMIN, \
|
||||
SYSTEM_ADMIN, DAILY_ADMIN, AUDIT_ADMIN
|
||||
SYSTEM_ADMIN, DAILY_ADMIN, AUDIT_ADMIN, HASH_URLS
|
||||
from seahub.institutions.models import (Institution, InstitutionAdmin,
|
||||
InstitutionQuota)
|
||||
from seahub.institutions.utils import get_institution_space_usage
|
||||
@ -1713,7 +1713,7 @@ def sys_repo_delete(request, repo_id):
|
||||
"""
|
||||
next = request.META.get('HTTP_REFERER', None)
|
||||
if not next:
|
||||
next = reverse('sys_repo_admin')
|
||||
next = HASH_URLS['SYS_REPO_ADMIN']
|
||||
|
||||
if get_system_default_repo_id() == repo_id:
|
||||
messages.error(request, _('System library can not be deleted.'))
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from seahub.test_utils import BaseTestCase
|
||||
from seahub.constants import HASH_URLS
|
||||
|
||||
|
||||
class GroupDiscussTest(BaseTestCase):
|
||||
@ -11,5 +12,5 @@ class GroupDiscussTest(BaseTestCase):
|
||||
self.remove_group()
|
||||
|
||||
def test_can_render(self):
|
||||
resp = self.client.get(reverse('group_discuss', args=[self.group.id]))
|
||||
resp = self.client.get(HASH_URLS['GROUP_DISCUSS']% {'group_id': self.group.id})
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
@ -4,9 +4,12 @@ from django.core.management import call_command
|
||||
from seahub.invitations.models import Invitation
|
||||
from seahub.notifications.models import (
|
||||
UserNotification, repo_share_msg_to_json, file_comment_msg_to_json,
|
||||
guest_invitation_accepted_msg_to_json)
|
||||
guest_invitation_accepted_msg_to_json, repo_share_to_group_msg_to_json,
|
||||
file_uploaded_msg_to_json, group_join_request_to_json,
|
||||
add_user_to_group_to_json, group_msg_to_json)
|
||||
from seahub.profile.models import Profile
|
||||
from seahub.test_utils import BaseTestCase
|
||||
from seahub.notifications.management.commands.send_notices import Command
|
||||
|
||||
|
||||
class CommandTest(BaseTestCase):
|
||||
@ -60,3 +63,51 @@ class CommandTest(BaseTestCase):
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
assert mail.outbox[0].to[0] == self.user.username
|
||||
assert 'Guest test@test.com' in mail.outbox[0].body
|
||||
|
||||
def test_format_repo_share_msg(self):
|
||||
detail = repo_share_msg_to_json('share@share.com', self.repo.id, '', -1)
|
||||
notice = UserNotification.objects.add_repo_share_msg('to@to.com', detail)
|
||||
resp = Command().format_repo_share_msg(notice)
|
||||
|
||||
assert resp.repo_url == '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': ''}
|
||||
|
||||
def test_format_group_message(self):
|
||||
detail = group_msg_to_json(self.group.id, 'from@email.com', 'message')
|
||||
notice = UserNotification(to_user= 'to@user.com', msg_type='group_msg', detail=detail)
|
||||
resp = Command().format_group_message(notice)
|
||||
assert resp.group_url == '/#group/%(group_id)s/discussions/' % {'group_id': self.group.id}
|
||||
|
||||
def test_format_repo_share_to_group_msg(self):
|
||||
detail = repo_share_to_group_msg_to_json('repo@share.com', self.repo.id, self.group.id, '', -1)
|
||||
notice = UserNotification.objects.add_repo_share_to_group_msg('group@share.com', detail)
|
||||
resp = Command().format_repo_share_to_group_msg(notice)
|
||||
|
||||
assert resp.repo_url == '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': ''}
|
||||
assert resp.group_url == '/#group/%(group_id)s/' % {'group_id': self.group.id}
|
||||
|
||||
def test_format_file_uploaded_msg(self):
|
||||
upload_to = '/'
|
||||
detail = file_uploaded_msg_to_json('upload_msg', self.repo.id, upload_to)
|
||||
notice = UserNotification.objects.add_file_uploaded_msg('file@upload.com', detail)
|
||||
resp = Command().format_file_uploaded_msg(notice)
|
||||
|
||||
assert resp.folder_link == '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': upload_to.strip('/')}
|
||||
|
||||
def test_format_group_join_request(self):
|
||||
detail = group_join_request_to_json('group_join', self.group.id, 'join_request_msg')
|
||||
notice = UserNotification.objects.add_group_join_request_notice('group_join',
|
||||
detail=detail)
|
||||
resp = Command().format_group_join_request(notice)
|
||||
|
||||
assert resp.grpjoin_group_url == '/#group/%(group_id)s/members/' % {'group_id': self.group.id}
|
||||
|
||||
def test_format_add_user_to_group(self):
|
||||
detail = add_user_to_group_to_json(self.user.username, self.group.id)
|
||||
notice = UserNotification.objects.set_add_user_to_group_notice(self.user.username,
|
||||
detail=detail)
|
||||
resp = Command().format_add_user_to_group(notice)
|
||||
|
||||
assert resp.group_url == '/#group/%(group_id)s/' % {'group_id': self.group.id}
|
||||
|
@ -1,5 +1,8 @@
|
||||
from seahub.notifications.models import (
|
||||
UserNotification, repo_share_msg_to_json, file_comment_msg_to_json)
|
||||
UserNotification, repo_share_msg_to_json, file_comment_msg_to_json,
|
||||
repo_share_to_group_msg_to_json, file_uploaded_msg_to_json,
|
||||
group_join_request_to_json, add_user_to_group_to_json, group_msg_to_json)
|
||||
|
||||
from seahub.test_utils import BaseTestCase
|
||||
|
||||
|
||||
@ -12,3 +15,48 @@ class UserNotificationTest(BaseTestCase):
|
||||
msg = notice.format_file_comment_msg()
|
||||
assert msg is not None
|
||||
assert 'new comment from user' in msg
|
||||
|
||||
def test_format_file_uploaded_msg(self):
|
||||
upload_to = '/'
|
||||
detail = file_uploaded_msg_to_json('upload_msg', self.repo.id, upload_to)
|
||||
notice = UserNotification.objects.add_file_uploaded_msg('file@upload.com', detail)
|
||||
|
||||
msg = notice.format_file_uploaded_msg()
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': upload_to.strip('/')} in msg
|
||||
|
||||
def test_format_repo_share_msg(self):
|
||||
detail = repo_share_msg_to_json('share@share.com', self.repo.id, '/', -1)
|
||||
notice = UserNotification.objects.add_repo_share_msg('to@to.com', detail)
|
||||
|
||||
msg = notice.format_repo_share_msg()
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': ''} in msg
|
||||
|
||||
def test_format_repo_share_to_group_msg(self):
|
||||
detail = repo_share_to_group_msg_to_json('repo@share.com', self.repo.id, self.group.id, '/', -1)
|
||||
notice = UserNotification.objects.add_repo_share_to_group_msg('group@share.com', detail)
|
||||
|
||||
msg = notice.format_repo_share_to_group_msg()
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id, 'path': ''} in msg
|
||||
assert '/#group/%(group_id)s/' % {'group_id': self.group.id} in msg
|
||||
|
||||
def test_format_group_message_title(self):
|
||||
detail = group_msg_to_json(self.group.id, 'from@email.com', 'message')
|
||||
notice = UserNotification(to_user= 'to@user.com', msg_type='group_msg', detail=detail)
|
||||
msg = notice.format_group_message_title()
|
||||
assert '/#group/%(group_id)s/discussions/' % {'group_id': self.group.id} in msg
|
||||
|
||||
def test_format_group_join_request(self):
|
||||
detail = group_join_request_to_json('group_join', self.group.id, 'join_request_msg')
|
||||
notice = UserNotification.objects.add_group_join_request_notice('group_join',
|
||||
detail=detail)
|
||||
msg = notice.format_group_join_request()
|
||||
assert '/#group/%(group_id)s/members/' % {'group_id': self.group.id} in msg
|
||||
|
||||
def test_format_add_user_to_group(self):
|
||||
detail = add_user_to_group_to_json(self.user.username, self.group.id)
|
||||
notice = UserNotification.objects.set_add_user_to_group_notice(self.user.username,
|
||||
detail=detail)
|
||||
msg = notice.format_add_user_to_group()
|
||||
assert '/#group/%(group_id)s/' % {'group_id': self.group.id} in msg
|
||||
|
10
tests/seahub/views/init/test_fpath_to_link.py
Normal file
10
tests/seahub/views/init/test_fpath_to_link.py
Normal file
@ -0,0 +1,10 @@
|
||||
from seahub.test_utils import BaseTestCase
|
||||
from seahub.views import fpath_to_link
|
||||
|
||||
|
||||
class FpathToLinkTest(BaseTestCase):
|
||||
def test_fpath_to_link(self):
|
||||
path = '/'
|
||||
resp = fpath_to_link(self.repo.id, path, is_dir=True)
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': path.encode('utf-8').strip('/')} in resp
|
@ -12,3 +12,10 @@ class RepoHistoryTest(BaseTestCase):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertTemplateUsed(resp, 'repo_history.html')
|
||||
assert len(resp.context['commits']) == 1
|
||||
|
||||
def test_passwd_true(self):
|
||||
resp = self.client.get(reverse('repo_history', args=[self.enc_repo.id]))
|
||||
|
||||
self.assertEqual(302, resp.status_code)
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {
|
||||
'repo_id': self.enc_repo.id, 'path': ''} in resp.url
|
||||
|
@ -12,3 +12,10 @@ class RepoRevertHistoryTest(BaseTestCase):
|
||||
})
|
||||
self.assertEqual(200, resp.status_code)
|
||||
assert 'Invalid arguments' in resp.content
|
||||
|
||||
def test_passwd_true(self):
|
||||
resp = self.client.post(reverse('repo_revert_history', args=[self.enc_repo.id]) + '?commit_id=xxx', {})
|
||||
|
||||
self.assertEqual(302, resp.status_code)
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {
|
||||
'repo_id': self.enc_repo.id, 'path': ''} in resp.url
|
||||
|
Loading…
Reference in New Issue
Block a user