mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 03:10:45 +00:00
[wiki] Redirect old url to new url end with .md (#2578)
This commit is contained in:
parent
d585c29a7f
commit
2c61839da8
@ -42,6 +42,11 @@ def wiki_list(request):
|
||||
def slug(request, slug, file_path="home.md"):
|
||||
"""Show wiki page.
|
||||
"""
|
||||
# compatible with old wiki url
|
||||
if len(file_path.split('.')) == 1:
|
||||
new_path = file_path + '.md'
|
||||
return HttpResponseRedirect(reverse('wiki:slug', args=[slug, new_path]))
|
||||
|
||||
# get wiki object or 404
|
||||
wiki = get_object_or_404(Wiki, slug=slug)
|
||||
file_path = "/" + file_path
|
||||
|
20
tests/seahub/wiki/test_views.py
Normal file
20
tests/seahub/wiki/test_views.py
Normal file
@ -0,0 +1,20 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from seahub.wiki.models import Wiki
|
||||
from seahub.test_utils import BaseTestCase
|
||||
|
||||
|
||||
class SlugTest(BaseTestCase):
|
||||
def setUp(self, ):
|
||||
self.wiki = Wiki.objects.add('new wiki', self.user.username)
|
||||
self.login_as(self.user)
|
||||
|
||||
# def test_home_page(self, ):
|
||||
# resp = self.client.get(reverse('wiki:slug', args=['new-wiki']))
|
||||
# self.assertEqual(200, resp.status_code)
|
||||
# self.assertTemplateUsed(resp, 'wiki/wiki.html')
|
||||
|
||||
def test_old_home_page(self, ):
|
||||
resp = self.client.get(reverse('wiki:slug', args=['new-wiki', 'home']))
|
||||
self.assertEqual(302, resp.status_code)
|
||||
self.assertRegexpMatches(resp['Location'], '/wikis/new-wiki/home.md')
|
Loading…
Reference in New Issue
Block a user