1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-14 13:13:22 +00:00

fix notifications url (#2755)

This commit is contained in:
C_Q 2019-01-08 10:56:00 +08:00 committed by zheng xie
parent 855f026596
commit db2d0e01e7
15 changed files with 72 additions and 72 deletions

View File

@ -19,11 +19,7 @@ DAILY_ADMIN = 'daily_admin'
AUDIT_ADMIN = 'audit_admin' AUDIT_ADMIN = 'audit_admin'
HASH_URLS = { HASH_URLS = {
'VIEW_COMMON_LIB_DIR': settings.SITE_ROOT + '#common/lib/%(repo_id)s/%(path)s',
'GROUP_INFO': settings.SITE_ROOT + '#group/%(group_id)s/',
'GROUP_MEMBERS': settings.SITE_ROOT + '#group/%(group_id)s/members/', 'GROUP_MEMBERS': settings.SITE_ROOT + '#group/%(group_id)s/members/',
'GROUP_DISCUSS': settings.SITE_ROOT + '#group/%(group_id)s/discussions/', 'GROUP_DISCUSS': settings.SITE_ROOT + '#group/%(group_id)s/discussions/',
'GROUP_LIST': settings.SITE_ROOT + '#groups/',
'SYS_REPO_ADMIN': settings.SITE_ROOT + 'sysadmin/#all-libs/', 'SYS_REPO_ADMIN': settings.SITE_ROOT + 'sysadmin/#all-libs/',
} }

View File

@ -40,7 +40,6 @@ from seahub.views import is_registered_user, check_folder_permission
from seahub.views.modules import get_enabled_mods_by_group, \ from seahub.views.modules import get_enabled_mods_by_group, \
get_available_mods_by_group get_available_mods_by_group
from seahub.share.models import ExtraGroupsSharePermission from seahub.share.models import ExtraGroupsSharePermission
from seahub.constants import HASH_URLS
from seahub.forms import SharedRepoCreateForm from seahub.forms import SharedRepoCreateForm
@ -96,7 +95,8 @@ def group_check(func):
group_id_int = int(group_id) # Checked by URL Conf group_id_int = int(group_id) # Checked by URL Conf
group = get_group(group_id_int) group = get_group(group_id_int)
if not group: if not group:
return HttpResponseRedirect(HASH_URLS['GROUP_LIST']) group_list_url = reverse('groups')
return HttpResponseRedirect(group_list_url)
group.is_staff = False group.is_staff = False
if PublicGroup.objects.filter(group_id=group.id): if PublicGroup.objects.filter(group_id=group.id):
group.is_pub = True group.is_pub = True

View File

@ -35,18 +35,18 @@ def td(con):
def a_tag(con, href='#', style=''): def a_tag(con, href='#', style=''):
return '<a href="%s" style="%s">%s</a>' % (href, style, e(con)) return '<a href="%s" style="%s">%s</a>' % (href, style, e(con))
def repo_url(repo_id): def repo_url(repo_id, repo_name):
p = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} p = reverse('lib_view', args=[repo_id, repo_name, ''])
return get_site_scheme_and_netloc() + p return get_site_scheme_and_netloc() + p
def file_url(repo_id, file_path): def file_url(repo_id, file_path):
p = reverse('view_lib_file', args=[repo_id, file_path]) p = reverse('view_lib_file', args=[repo_id, file_path])
return get_site_scheme_and_netloc() + p return get_site_scheme_and_netloc() + p
def dir_url(repo_id, dir_path): def dir_url(repo_id, repo_name, dir_path):
p = HASH_URLS["VIEW_COMMON_LIB_DIR"] % { p = reverse('lib_view', args=[repo_id, repo_name, dir_path.strip('/')])
'repo_id': repo_id, 'path': dir_path.strip('/')
}
return get_site_scheme_and_netloc() + p return get_site_scheme_and_netloc() + p
def user_info_url(username): def user_info_url(username):
@ -100,8 +100,8 @@ class Command(BaseCommand):
return Profile.objects.get_user_language(username) return Profile.objects.get_user_language(username)
def format_file_operation(self, ev): def format_file_operation(self, ev):
lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id)) lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id, ev.repo_name))
small_lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id), 'color:#868e96;font-size:87.5%;') small_lib_link = a_tag(ev.repo_name, repo_url(ev.repo_id, ev.repo_name), 'color:#868e96;font-size:87.5%;')
if ev.obj_type == 'repo': if ev.obj_type == 'repo':
if ev.op_type == 'create': if ev.op_type == 'create':
op = _('Created library') op = _('Created library')
@ -153,7 +153,7 @@ class Command(BaseCommand):
else: # dir else: # dir
dir_name = os.path.basename(ev.path) dir_name = os.path.basename(ev.path)
dir_link = a_tag(dir_name, dir_url(ev.repo_id, ev.path)) dir_link = a_tag(dir_name, dir_url(ev.repo_id, ev.repo_name, ev.path))
if ev.op_type == 'create': if ev.op_type == 'create':
op = _('Created folder') op = _('Created folder')
details = td('%s<br />%s' % (dir_link, small_lib_link)) details = td('%s<br />%s' % (dir_link, small_lib_link))

View File

@ -98,7 +98,8 @@ class Command(BaseCommand):
owner = seafile_api.get_repo_owner(repo_id) owner = seafile_api.get_repo_owner(repo_id)
repo = seafile_api.get_virtual_repo(repo_id, path, owner) repo = seafile_api.get_virtual_repo(repo_id, path, owner)
notice.repo_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} repo_url = reverse('lib_view', args=[repo_id, repo.name, ''])
notice.repo_url = repo_url
notice.notice_from = escape(email2nickname(d['share_from'])) notice.notice_from = escape(email2nickname(d['share_from']))
notice.repo_name = repo.name notice.repo_name = repo.name
notice.avatar_src = self.get_avatar_src(d['share_from']) notice.avatar_src = self.get_avatar_src(d['share_from'])
@ -128,11 +129,12 @@ class Command(BaseCommand):
owner = seafile_api.get_repo_owner(repo_id) owner = seafile_api.get_repo_owner(repo_id)
repo = seafile_api.get_virtual_repo(repo_id, path, owner) repo = seafile_api.get_virtual_repo(repo_id, path, owner)
notice.repo_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} repo_url = reverse('lib_view', args=[repo_id, repo.name, ''])
notice.repo_url = repo_url
notice.notice_from = escape(email2nickname(d['share_from'])) notice.notice_from = escape(email2nickname(d['share_from']))
notice.repo_name = repo.name notice.repo_name = repo.name
notice.avatar_src = self.get_avatar_src(d['share_from']) notice.avatar_src = self.get_avatar_src(d['share_from'])
notice.group_url = HASH_URLS['GROUP_INFO'] % {'group_id': group.id} notice.group_url = reverse('group', args=[group.id])
notice.group_name = group.group_name notice.group_name = group.group_name
notice.shared_type = shared_type notice.shared_type = shared_type
@ -143,10 +145,12 @@ class Command(BaseCommand):
file_name = d['file_name'] file_name = d['file_name']
repo_id = d['repo_id'] repo_id = d['repo_id']
repo = seafile_api.get_repo(repo_id)
uploaded_to = d['uploaded_to'].rstrip('/') uploaded_to = d['uploaded_to'].rstrip('/')
file_path = uploaded_to + '/' + file_name file_path = uploaded_to + '/' + file_name
file_link = reverse('view_lib_file', args=[repo_id, file_path]) file_link = reverse('view_lib_file', args=[repo_id, file_path])
folder_link = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': uploaded_to.strip('/')}
folder_link = reverse('lib_view', args=[repo_id, repo.name, uploaded_to.strip('/')])
folder_name = os.path.basename(uploaded_to) folder_name = os.path.basename(uploaded_to)
notice.file_link = file_link notice.file_link = file_link
@ -184,7 +188,7 @@ class Command(BaseCommand):
notice.avatar_src = self.get_avatar_src(group_staff) notice.avatar_src = self.get_avatar_src(group_staff)
notice.group_staff_profile_url = reverse('user_profile', notice.group_staff_profile_url = reverse('user_profile',
args=[group_staff]) args=[group_staff])
notice.group_url = HASH_URLS['GROUP_INFO'] % {'group_id': group_id} notice.group_url = reverse('group', args=[group.id])
notice.group_name = group.group_name notice.group_name = group.group_name
return notice return notice

View File

@ -5,6 +5,7 @@ import os
import json import json
import logging import logging
from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
from django.forms import ModelForm, Textarea from django.forms import ModelForm, Textarea
@ -505,15 +506,13 @@ class UserNotification(models.Model):
if d['uploaded_to'] == '/': if d['uploaded_to'] == '/':
# current upload path is '/' # current upload path is '/'
file_path = '/' + filename file_path = '/' + filename
link = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} link = reverse('lib_view', args=[repo_id, repo.name, ''])
name = repo.name name = repo.name
else: else:
uploaded_to = d['uploaded_to'].rstrip('/') uploaded_to = d['uploaded_to'].rstrip('/')
file_path = uploaded_to + '/' + filename file_path = uploaded_to + '/' + filename
link = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, link = reverse('lib_view', args=[repo_id, repo.name, uploaded_to.lstrip('/')])
'path': uploaded_to.lstrip('/')}
name = os.path.basename(uploaded_to) name = os.path.basename(uploaded_to)
file_link = reverse('view_lib_file', args=[repo_id, file_path]) file_link = reverse('view_lib_file', args=[repo_id, file_path])
msg = _(u"A file named <a href='%(file_link)s'>%(file_name)s</a> is uploaded to <a href='%(link)s'>%(name)s</a>") % { msg = _(u"A file named <a href='%(file_link)s'>%(file_name)s</a> is uploaded to <a href='%(link)s'>%(name)s</a>") % {
@ -571,12 +570,10 @@ class UserNotification(models.Model):
else: else:
tmpl = 'notifications/notice_msg/folder_share_msg.html' tmpl = 'notifications/notice_msg/folder_share_msg.html'
lib_url = reverse('lib_view', args=[repo.id, repo.name, ''])
msg = render_to_string(tmpl, { msg = render_to_string(tmpl, {
'user': share_from, 'user': share_from,
'lib_url': HASH_URLS["VIEW_COMMON_LIB_DIR"] % { 'lib_url': lib_url,
'repo_id': repo.id,
'path': ''
},
'lib_name': repo.name, 'lib_name': repo.name,
}) })
@ -626,14 +623,13 @@ class UserNotification(models.Model):
else: else:
tmpl = 'notifications/notice_msg/folder_share_to_group_msg.html' tmpl = 'notifications/notice_msg/folder_share_to_group_msg.html'
lib_url = reverse('lib_view', args=[repo.id, repo.name, ''])
group_url = reverse('group', args=[group.id])
msg = render_to_string(tmpl, { msg = render_to_string(tmpl, {
'user': share_from, 'user': share_from,
'lib_url': HASH_URLS["VIEW_COMMON_LIB_DIR"] % { 'lib_url': lib_url,
'repo_id': repo.id,
'path': ''
},
'lib_name': repo.name, 'lib_name': repo.name,
'group_url': HASH_URLS['GROUP_INFO'] % {'group_id': group.id}, 'group_url': group_url,
'group_name': group.group_name, 'group_name': group.group_name,
}) })
@ -742,7 +738,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>") % { 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]), 'user_profile': reverse('user_profile', args=[group_staff]),
'group_staff': escape(email2nickname(group_staff)), 'group_staff': escape(email2nickname(group_staff)),
'href': HASH_URLS['GROUP_INFO'] % {'group_id': group_id}, 'href': reverse('group', args=[group_id]),
'group_name': escape(group.group_name)} 'group_name': escape(group.group_name)}
return msg return msg
@ -858,7 +854,6 @@ class UserNotification(models.Model):
########## handle signals ########## handle signals
from django.core.urlresolvers import reverse
from django.dispatch import receiver from django.dispatch import receiver
from seahub.signals import upload_file_successful, comment_file_successful from seahub.signals import upload_file_successful, comment_file_successful

View File

@ -204,8 +204,8 @@ urlpatterns = [
url(r'^shared-libs/$', react_fake_view, name="shared_libs"), url(r'^shared-libs/$', react_fake_view, name="shared_libs"),
url(r'^my-libs/$', react_fake_view, name="my_libs"), url(r'^my-libs/$', react_fake_view, name="my_libs"),
url(r'^groups/$', react_fake_view, name="groups"), url(r'^groups/$', react_fake_view, name="groups"),
url(r'^group/.*$', react_fake_view, name="group"), url(r'^group/(?P<group_id>\d+)/$', react_fake_view, name="group"),
url(r'^library/.*$', react_fake_view, name="lib_view"), url(r'^library/(?P<repo_id>[-0-9a-f]{36})/(?P<repo_name>[^/]+)/(?P<path>.*)$', react_fake_view, name="lib_view"),
url(r'^my-libs/deleted/$', react_fake_view, name="my_libs_deleted"), url(r'^my-libs/deleted/$', react_fake_view, name="my_libs_deleted"),
url(r'^org/$', react_fake_view, name="org"), url(r'^org/$', react_fake_view, name="org"),

View File

@ -180,8 +180,7 @@ def get_repo_dirents(request, repo, commit, path, offset=-1, limit=-1):
fileshares = FileShare.objects.filter(repo_id=repo.id).filter(username=username) fileshares = FileShare.objects.filter(repo_id=repo.id).filter(username=username)
uploadlinks = UploadLinkShare.objects.filter(repo_id=repo.id).filter(username=username) uploadlinks = UploadLinkShare.objects.filter(repo_id=repo.id).filter(username=username)
view_dir_base = reverse('lib_view', args=[repo.id, repo.name, ''])
view_dir_base = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo.id, 'path': ''}
dl_dir_base = reverse('repo_download_dir', args=[repo.id]) dl_dir_base = reverse('repo_download_dir', args=[repo.id])
file_history_base = reverse('file_revisions', args=[repo.id]) file_history_base = reverse('file_revisions', args=[repo.id])
for dirent in dirs: for dirent in dirs:
@ -466,7 +465,7 @@ def repo_history(request, repo_id):
return render_error(request, e.msg) return render_error(request, e.msg)
if not password_set: if not password_set:
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} reverse_url = reverse('lib_view', args=[repo_id, repo.name, ''])
return HttpResponseRedirect(reverse_url) return HttpResponseRedirect(reverse_url)
try: try:
@ -551,7 +550,7 @@ def repo_revert_history(request, repo_id):
return render_error(request, e.msg) return render_error(request, e.msg)
if not password_set: if not password_set:
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} reverse_url = reverse('lib_view', args=[repo_id, repo.name, ''])
return HttpResponseRedirect(reverse_url) return HttpResponseRedirect(reverse_url)
commit_id = request.GET.get('commit_id', '') commit_id = request.GET.get('commit_id', '')
@ -576,8 +575,8 @@ def repo_revert_history(request, repo_id):
def fpath_to_link(repo_id, path, is_dir=False): def fpath_to_link(repo_id, path, is_dir=False):
"""Translate file path of a repo to its view link""" """Translate file path of a repo to its view link"""
if is_dir: if is_dir:
href = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': path.strip('/')} repo = seafile_api.get_repo(repo_id)
href = urlquote(href, safe='/#') href = reverse('lib_view', args=[repo_id, repo.name, path.strip('/')])
else: else:
if not path.startswith('/'): if not path.startswith('/'):
p = '/' + path p = '/' + path
@ -754,7 +753,8 @@ def libraries(request):
def repo_set_access_property(request, repo_id): def repo_set_access_property(request, repo_id):
ap = request.GET.get('ap', '') ap = request.GET.get('ap', '')
seafserv_threaded_rpc.repo_set_access_property(repo_id, ap) seafserv_threaded_rpc.repo_set_access_property(repo_id, ap)
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} repo = seafile_api.get_repo(repo_id)
reverse_url = reverse('lib_view', args=[repo_id, repo.name, ''])
return HttpResponseRedirect(reverse_url) return HttpResponseRedirect(reverse_url)
@ -1051,13 +1051,13 @@ def convert_cmmt_desc_link(request):
elif d.status == 'mov': # Move or Rename non-empty file/folder elif d.status == 'mov': # Move or Rename non-empty file/folder
if '/' in d.new_name: if '/' in d.new_name:
new_dir_name = d.new_name.split('/')[0] new_dir_name = d.new_name.split('/')[0]
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': new_dir_name} reverse_url = reverse('lib_view', args=[repo_id, repo.name, new_dir_name])
return HttpResponseRedirect(reverse_url) return HttpResponseRedirect(reverse_url)
else: else:
return HttpResponseRedirect( return HttpResponseRedirect(
reverse('view_lib_file', args=[repo_id, '/' + d.new_name])) reverse('view_lib_file', args=[repo_id, '/' + d.new_name]))
elif d.status == 'newdir': elif d.status == 'newdir':
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': d.name.strip('/')}, reverse_url = reverse('lib_view', args=[repo_id, repo.name, d.name.strip('/')])
return HttpResponseRedirect(reverse_url) return HttpResponseRedirect(reverse_url)
else: else:
continue continue
@ -1214,7 +1214,7 @@ def choose_register(request):
}) })
@login_required @login_required
def react_fake_view(request): def react_fake_view(request, **kwargs):
return render(request, "react_app.html", { return render(request, "react_app.html", {
'seafile_collab_server': SEAFILE_COLLAB_SERVER, 'seafile_collab_server': SEAFILE_COLLAB_SERVER,

View File

@ -817,8 +817,8 @@ def mv_dirents(request, src_repo_id, src_path, dst_repo_id, dst_path,
success.append(obj_name) success.append(obj_name)
if len(success) > 0: if len(success) > 0:
url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': dst_repo_id, 'path': dst_path.strip('/')}, dst_repo = seafile_api.get_repo(dst_repo_id)
url = reverse('lib_view', args=[dst_repo_id, dst_repo.name, dst_path.strip('/')])
result = {'success': success, 'failed': failed, 'url': url} result = {'success': success, 'failed': failed, 'url': url}
return HttpResponse(json.dumps(result), content_type=content_type) return HttpResponse(json.dumps(result), content_type=content_type)
@ -890,8 +890,8 @@ def cp_dirents(request, src_repo_id, src_path, dst_repo_id, dst_path, obj_file_n
success.append(obj_name) success.append(obj_name)
if len(success) > 0: if len(success) > 0:
url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': dst_repo_id, 'path': dst_path.strip('/')}, dst_repo = seafile_api.get_repo(dst_repo_id)
url = reverse('lib_view', args=[dst_repo_id, dst_repo.name, dst_path.strip('/')])
result = {'success': success, 'failed': failed, 'url': url} result = {'success': success, 'failed': failed, 'url': url}
return HttpResponse(json.dumps(result), content_type=content_type) return HttpResponse(json.dumps(result), content_type=content_type)

View File

@ -1676,7 +1676,7 @@ def download_file(request, repo_id, obj_id):
raise Http404 raise Http404
if repo.encrypted and not seafile_api.is_password_set(repo_id, username): if repo.encrypted and not seafile_api.is_password_set(repo_id, username):
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} reverse_url = reverse('lib_view', args=[repo_id, repo.name, ''])
return HttpResponseRedirect(reverse_url) return HttpResponseRedirect(reverse_url)
# only check the permissions at the repo level # only check the permissions at the repo level

View File

@ -4,6 +4,7 @@ import os
import posixpath import posixpath
import logging import logging
from django.core.urlresolvers import reverse
from django.db.models import F from django.db.models import F
from django.http import Http404, HttpResponseRedirect from django.http import Http404, HttpResponseRedirect
from django.shortcuts import render from django.shortcuts import render
@ -115,7 +116,7 @@ def repo_history_view(request, repo_id):
# Assume server_crypto is ``False`` if this option is not set. # Assume server_crypto is ``False`` if this option is not set.
server_crypto = False server_crypto = False
reverse_url = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': ''} reverse_url = reverse('lib_view', args=[repo_id, repo.name, ''])
if repo.encrypted and \ if repo.encrypted and \
(repo.enc_version == 1 or (repo.enc_version == 2 and server_crypto)) \ (repo.enc_version == 1 or (repo.enc_version == 2 and server_crypto)) \
and not is_password_set(repo.id, username): and not is_password_set(repo.id, username):

View File

@ -127,8 +127,8 @@ class CommandTest(BaseTestCase):
notice = UserNotification.objects.add_repo_share_msg('to@to.com', detail) notice = UserNotification.objects.add_repo_share_msg('to@to.com', detail)
resp = Command().format_repo_share_msg(notice) resp = Command().format_repo_share_msg(notice)
assert resp.repo_url == '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id, assert resp.repo_url == '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {
'path': ''} 'repo_id': self.repo.id, 'repo_name': self.repo.name, 'path': ''}
def test_format_group_message(self): def test_format_group_message(self):
detail = group_msg_to_json(self.group.id, 'from@email.com', 'message') detail = group_msg_to_json(self.group.id, 'from@email.com', 'message')
@ -144,9 +144,9 @@ class CommandTest(BaseTestCase):
notice = UserNotification.objects.add_repo_share_to_group_msg('group@share.com', detail) notice = UserNotification.objects.add_repo_share_to_group_msg('group@share.com', detail)
resp = Command().format_repo_share_to_group_msg(notice) 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, assert resp.repo_url == '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {
'path': ''} 'repo_id': self.repo.id, 'repo_name': self.repo.name, 'path': ''}
assert resp.group_url == '/#group/%(group_id)s/' % {'group_id': self.group.id} assert resp.group_url == '/group/%(group_id)s/' % {'group_id': self.group.id}
def test_format_file_uploaded_msg(self): def test_format_file_uploaded_msg(self):
upload_to = '/' upload_to = '/'
@ -154,8 +154,8 @@ class CommandTest(BaseTestCase):
notice = UserNotification.objects.add_file_uploaded_msg('file@upload.com', detail) notice = UserNotification.objects.add_file_uploaded_msg('file@upload.com', detail)
resp = Command().format_file_uploaded_msg(notice) resp = Command().format_file_uploaded_msg(notice)
assert resp.folder_link == '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id, assert resp.folder_link == '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {
'path': upload_to.strip('/')} 'repo_id': self.repo.id, 'repo_name': self.repo.name, 'path': upload_to.strip('/')}
def test_format_group_join_request(self): def test_format_group_join_request(self):
detail = group_join_request_to_json('group_join', self.group.id, 'join_request_msg') detail = group_join_request_to_json('group_join', self.group.id, 'join_request_msg')
@ -171,4 +171,4 @@ class CommandTest(BaseTestCase):
detail=detail) detail=detail)
resp = Command().format_add_user_to_group(notice) resp = Command().format_add_user_to_group(notice)
assert resp.group_url == '/#group/%(group_id)s/' % {'group_id': self.group.id} assert resp.group_url == '/group/%(group_id)s/' % {'group_id': self.group.id}

View File

@ -25,7 +25,8 @@ class UserNotificationTest(BaseTestCase):
notice = UserNotification.objects.add_file_uploaded_msg('file@upload.com', detail) notice = UserNotification.objects.add_file_uploaded_msg('file@upload.com', detail)
msg = notice.format_file_uploaded_msg() msg = notice.format_file_uploaded_msg()
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id, assert '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {'repo_id': self.repo.id,
'repo_name': self.repo.name,
'path': upload_to.strip('/')} in msg 'path': upload_to.strip('/')} in msg
def test_format_group_message_title(self): def test_format_group_message_title(self):
@ -46,7 +47,7 @@ class UserNotificationTest(BaseTestCase):
notice = UserNotification.objects.set_add_user_to_group_notice(self.user.username, notice = UserNotification.objects.set_add_user_to_group_notice(self.user.username,
detail=detail) detail=detail)
msg = notice.format_add_user_to_group() msg = notice.format_add_user_to_group()
assert '/#group/%(group_id)s/' % {'group_id': self.group.id} in msg assert '/group/%(group_id)s/' % {'group_id': self.group.id} in msg
def test_format_repo_share_msg(self): def test_format_repo_share_msg(self):
notice = UserNotification.objects.add_repo_share_msg( notice = UserNotification.objects.add_repo_share_msg(
@ -56,7 +57,9 @@ class UserNotificationTest(BaseTestCase):
msg = notice.format_repo_share_msg() msg = notice.format_repo_share_msg()
assert msg is not None assert msg is not None
assert 'bar has shared a library named' in msg assert 'bar has shared a library named' in msg
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id, assert '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {
'repo_id': self.repo.id,
'repo_name': self.repo.name,
'path': ''} in msg 'path': ''} in msg
def test_format_repo_share_msg_with_folder(self): def test_format_repo_share_msg_with_folder(self):
@ -79,7 +82,7 @@ class UserNotificationTest(BaseTestCase):
msg = notice.format_repo_share_to_group_msg() msg = notice.format_repo_share_to_group_msg()
assert msg is not None assert msg is not None
assert 'bar has shared a library named' in msg assert 'bar has shared a library named' in msg
assert '/#group/%(group_id)s/' % {'group_id': self.group.id} in msg assert '/group/%(group_id)s/' % {'group_id': self.group.id} in msg
def test_format_repo_share_to_group_msg_with_folder(self): def test_format_repo_share_to_group_msg_with_folder(self):
folder_path = self.folder folder_path = self.folder

View File

@ -8,7 +8,8 @@ class FpathToLinkTest(BaseTestCase):
def test_fpath_to_link(self): def test_fpath_to_link(self):
path = '/海文/'.decode('utf-8') path = '/海文/'.decode('utf-8')
resp = fpath_to_link(self.repo.id, path, is_dir=True) resp = fpath_to_link(self.repo.id, path, is_dir=True)
url = '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id, url = '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {'repo_id': self.repo.id,
'repo_name': self.repo.name,
'path': path.strip('/')} 'path': path.strip('/')}
assert urlquote(url, safe='/#') in resp assert urlquote(url) in resp

View File

@ -17,5 +17,5 @@ class RepoHistoryTest(BaseTestCase):
resp = self.client.get(reverse('repo_history', args=[self.enc_repo.id])) resp = self.client.get(reverse('repo_history', args=[self.enc_repo.id]))
self.assertEqual(302, resp.status_code) self.assertEqual(302, resp.status_code)
assert '/#common/lib/%(repo_id)s/%(path)s' % { assert '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {
'repo_id': self.enc_repo.id, 'path': ''} in resp.url 'repo_id': self.enc_repo.id, 'repo_name': self.enc_repo.name, 'path': ''} in resp.url

View File

@ -17,5 +17,5 @@ class RepoRevertHistoryTest(BaseTestCase):
resp = self.client.post(reverse('repo_revert_history', args=[self.enc_repo.id]) + '?commit_id=xxx', {}) resp = self.client.post(reverse('repo_revert_history', args=[self.enc_repo.id]) + '?commit_id=xxx', {})
self.assertEqual(302, resp.status_code) self.assertEqual(302, resp.status_code)
assert '/#common/lib/%(repo_id)s/%(path)s' % { assert '/library/%(repo_id)s/%(repo_name)s/%(path)s' % {
'repo_id': self.enc_repo.id, 'path': ''} in resp.url 'repo_id': self.enc_repo.id, 'repo_name': self.enc_repo.name, 'path': ''} in resp.url