refactor urls + namespaces

This commit is contained in:
nitely 2015-07-12 19:24:37 -03:00
parent ba439509c4
commit ef6983ce68
88 changed files with 570 additions and 570 deletions

View File

@ -60,9 +60,9 @@ class AdminViewTest(TestCase):
self.assertRaises(PermissionDenied, user_views.edit, req)
self.assertRaises(PermissionDenied, user_views.index, req)
self.assertRaises(PermissionDenied, user_views.admins, req)
self.assertRaises(PermissionDenied, user_views.mods, req)
self.assertRaises(PermissionDenied, user_views.unactive, req)
self.assertRaises(PermissionDenied, user_views.index_admins, req)
self.assertRaises(PermissionDenied, user_views.index_mods, req)
self.assertRaises(PermissionDenied, user_views.index_unactive, req)
def test_user_edit(self):
"""
@ -71,12 +71,12 @@ class AdminViewTest(TestCase):
utils.login(self)
form_data = {"username": "fooedit", "email": "foo@bar.com", "location": "Bs As",
"timezone": "UTC", "is_administrator": True, "is_moderator": True, "is_active": True}
response = self.client.post(reverse('spirit:admin-user-edit', kwargs={'user_id': self.user.pk, }),
response = self.client.post(reverse('spirit:admin:user:edit', kwargs={'user_id': self.user.pk, }),
form_data)
expected_url = reverse('spirit:admin-user-edit', kwargs={'user_id': self.user.pk, })
expected_url = reverse('spirit:admin:user:edit', kwargs={'user_id': self.user.pk, })
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:admin-user-edit', kwargs={'user_id': self.user.pk, }))
response = self.client.get(reverse('spirit:admin:user:edit', kwargs={'user_id': self.user.pk, }))
self.assertEqual(response.status_code, 200)
def test_user_list(self):
@ -84,7 +84,7 @@ class AdminViewTest(TestCase):
List of all users
"""
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-list'))
response = self.client.get(reverse('spirit:admin:user:index'))
self.assertQuerysetEqual(response.context['users'], map(repr, [self.user, ]))
@override_djconfig(topics_per_page=1)
@ -95,7 +95,7 @@ class AdminViewTest(TestCase):
user2 = utils.create_user()
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-list'))
response = self.client.get(reverse('spirit:admin:user:index'))
self.assertQuerysetEqual(response.context['users'], map(repr, [user2, ]))
def test_user_admins(self):
@ -103,7 +103,7 @@ class AdminViewTest(TestCase):
List of admins
"""
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-admins'))
response = self.client.get(reverse('spirit:admin:user:index-admins'))
self.assertQuerysetEqual(response.context['users'], map(repr, [self.user, ]))
@override_djconfig(topics_per_page=1)
@ -116,7 +116,7 @@ class AdminViewTest(TestCase):
user2.st.save()
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-admins'))
response = self.client.get(reverse('spirit:admin:user:index-admins'))
self.assertQuerysetEqual(response.context['users'], map(repr, [user2, ]))
def test_user_mods(self):
@ -128,7 +128,7 @@ class AdminViewTest(TestCase):
mod.st.save()
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-mods'))
response = self.client.get(reverse('spirit:admin:user:index-mods'))
self.assertQuerysetEqual(response.context['users'], map(repr, [mod, ]))
@override_djconfig(topics_per_page=1)
@ -145,7 +145,7 @@ class AdminViewTest(TestCase):
mod2.st.save()
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-mods'))
response = self.client.get(reverse('spirit:admin:user:index-mods'))
self.assertQuerysetEqual(response.context['users'], map(repr, [mod2, ]))
def test_user_unactive(self):
@ -155,7 +155,7 @@ class AdminViewTest(TestCase):
unactive = utils.create_user()
User.objects.filter(pk=unactive.pk).update(is_active=False)
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-unactive'))
response = self.client.get(reverse('spirit:admin:user:index-unactive'))
self.assertQuerysetEqual(response.context['users'], map(repr, [unactive, ]))
@override_djconfig(topics_per_page=1)
@ -169,12 +169,12 @@ class AdminViewTest(TestCase):
User.objects.filter(pk=unactive2.pk).update(is_active=False)
utils.login(self)
response = self.client.get(reverse('spirit:admin-user-unactive'))
response = self.client.get(reverse('spirit:admin:user:index-unactive'))
self.assertQuerysetEqual(response.context['users'], map(repr, [unactive2, ]))
def test_index_dashboard(self):
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic'))
response = self.client.get(reverse('spirit:admin:topic:index'))
self.assertEqual(response.status_code, 200)
def test_topic_deleted(self):
@ -183,7 +183,7 @@ class AdminViewTest(TestCase):
"""
topic_ = utils.create_topic(self.category, is_removed=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-deleted'))
response = self.client.get(reverse('spirit:admin:topic:deleted'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
@override_djconfig(topics_per_page=1)
@ -195,7 +195,7 @@ class AdminViewTest(TestCase):
topic_ = utils.create_topic(self.category, is_removed=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-deleted'))
response = self.client.get(reverse('spirit:admin:topic:deleted'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
def test_topic_closed(self):
@ -204,7 +204,7 @@ class AdminViewTest(TestCase):
"""
topic_ = utils.create_topic(self.category, is_closed=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-closed'))
response = self.client.get(reverse('spirit:admin:topic:closed'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
@override_djconfig(topics_per_page=1)
@ -215,7 +215,7 @@ class AdminViewTest(TestCase):
utils.create_topic(self.category, is_closed=True)
topic_ = utils.create_topic(self.category, is_closed=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-closed'))
response = self.client.get(reverse('spirit:admin:topic:closed'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
def test_topic_pinned(self):
@ -224,7 +224,7 @@ class AdminViewTest(TestCase):
"""
topic_ = utils.create_topic(self.category, is_pinned=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-pinned'))
response = self.client.get(reverse('spirit:admin:topic:pinned'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
@override_djconfig(topics_per_page=1)
@ -235,7 +235,7 @@ class AdminViewTest(TestCase):
utils.create_topic(self.category, is_pinned=True)
topic_ = utils.create_topic(self.category, is_pinned=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-pinned'))
response = self.client.get(reverse('spirit:admin:topic:pinned'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
def test_category_list(self):
@ -245,7 +245,7 @@ class AdminViewTest(TestCase):
utils.create_category(parent=self.category)
categories = Category.objects.filter(is_private=False, parent=None)
utils.login(self)
response = self.client.get(reverse('spirit:admin-category-list'))
response = self.client.get(reverse('spirit:admin:category:index'))
self.assertQuerysetEqual(response.context['categories'], map(repr, categories))
def test_category_create(self):
@ -254,12 +254,12 @@ class AdminViewTest(TestCase):
"""
utils.login(self)
form_data = {"parent": "", "title": "foo", "description": "", "is_closed": False, "is_removed": False}
response = self.client.post(reverse('spirit:admin-category-create'),
response = self.client.post(reverse('spirit:admin:category:create'),
form_data)
expected_url = reverse("spirit:admin-category-list")
expected_url = reverse("spirit:admin:category:index")
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:admin-category-create'))
response = self.client.get(reverse('spirit:admin:category:create'))
self.assertEqual(response.status_code, 200)
def test_category_update(self):
@ -268,12 +268,12 @@ class AdminViewTest(TestCase):
"""
utils.login(self)
form_data = {"parent": "", "title": "foo", "description": "", "is_closed": False, "is_removed": False}
response = self.client.post(reverse('spirit:admin-category-update', kwargs={"category_id": self.category.pk, }),
response = self.client.post(reverse('spirit:admin:category:update', kwargs={"category_id": self.category.pk, }),
form_data)
expected_url = reverse("spirit:admin-category-list")
expected_url = reverse("spirit:admin:category:index")
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:admin-category-update', kwargs={"category_id": self.category.pk, }))
response = self.client.get(reverse('spirit:admin:category:update', kwargs={"category_id": self.category.pk, }))
self.assertEqual(response.status_code, 200)
def test_config_basic(self):
@ -282,12 +282,12 @@ class AdminViewTest(TestCase):
"""
utils.login(self)
form_data = {"site_name": "foo", "site_description": "bar", "comments_per_page": 10, "topics_per_page": 10}
response = self.client.post(reverse('spirit:admin-config-basic'),
response = self.client.post(reverse('spirit:admin:config-basic'),
form_data)
expected_url = reverse('spirit:admin-config-basic')
expected_url = reverse('spirit:admin:config-basic')
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:admin-config-basic'))
response = self.client.get(reverse('spirit:admin:config-basic'))
self.assertEqual(response.status_code, 200)
def test_flag_open(self):
@ -300,7 +300,7 @@ class AdminViewTest(TestCase):
flag_ = CommentFlag.objects.create(comment=comment)
utils.login(self)
response = self.client.get(reverse('spirit:admin-flag-open'))
response = self.client.get(reverse('spirit:admin:flag:opened'))
self.assertQuerysetEqual(response.context['flags'], map(repr, [flag_, ]))
@override_djconfig(comments_per_page=1)
@ -314,7 +314,7 @@ class AdminViewTest(TestCase):
flag_ = CommentFlag.objects.create(comment=comment)
utils.login(self)
response = self.client.get(reverse('spirit:admin-flag-open'))
response = self.client.get(reverse('spirit:admin:flag:opened'))
self.assertQuerysetEqual(response.context['flags'], map(repr, [flag_, ]))
def test_flag_closed(self):
@ -327,7 +327,7 @@ class AdminViewTest(TestCase):
CommentFlag.objects.create(comment=comment)
utils.login(self)
response = self.client.get(reverse('spirit:admin-flag-closed'))
response = self.client.get(reverse('spirit:admin:flag:closed'))
self.assertQuerysetEqual(response.context['flags'], map(repr, [flag_closed, ]))
@override_djconfig(comments_per_page=1)
@ -341,7 +341,7 @@ class AdminViewTest(TestCase):
flag_closed = CommentFlag.objects.create(comment=comment, is_closed=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-flag-closed'))
response = self.client.get(reverse('spirit:admin:flag:closed'))
self.assertQuerysetEqual(response.context['flags'], map(repr, [flag_closed, ]))
def test_flag_detail(self):
@ -358,12 +358,12 @@ class AdminViewTest(TestCase):
utils.login(self)
form_data = {"is_closed": True, }
response = self.client.post(reverse('spirit:admin-flag-detail', kwargs={'pk': comment_flag.pk, }),
response = self.client.post(reverse('spirit:admin:flag:detail', kwargs={'pk': comment_flag.pk, }),
form_data)
expected_url = reverse('spirit:admin-flag')
expected_url = reverse('spirit:admin:flag:index')
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:admin-flag-detail', kwargs={'pk': comment_flag.pk, }))
response = self.client.get(reverse('spirit:admin:flag:detail', kwargs={'pk': comment_flag.pk, }))
self.assertEqual(response.status_code, 200)
self.assertEqual(repr(response.context['flag']), repr(comment_flag))
self.assertQuerysetEqual(response.context['flags'], map(repr, [flag_, ]))
@ -380,7 +380,7 @@ class AdminViewTest(TestCase):
flag_ = Flag.objects.create(comment=comment, user=self.user, reason=0)
utils.login(self)
response = self.client.get(reverse('spirit:admin-flag-detail', kwargs={'pk': comment_flag.pk, }))
response = self.client.get(reverse('spirit:admin:flag:detail', kwargs={'pk': comment_flag.pk, }))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['flags'], map(repr, [flag_, ]))

View File

@ -12,12 +12,12 @@ import spirit.user.admin.urls
urlpatterns = [
url(r'^$', views.dashboard, name='admin'),
url(r'^dashboard/$', views.dashboard, name='admin-dashboard'),
url(r'^config/$', views.config_basic, name='admin-config-basic'),
url(r'^$', views.dashboard, name='index'),
url(r'^dashboard/$', views.dashboard, name='dashboard'),
url(r'^config/$', views.config_basic, name='config-basic'),
url(r'^category/', include(spirit.category.admin.urls)),
url(r'^comment/flag/', include(spirit.comment.flag.admin.urls)),
url(r'^topic/', include(spirit.topic.admin.urls)),
url(r'^user/', include(spirit.user.admin.urls)),
url(r'^category/', include(spirit.category.admin.urls, namespace='category')),
url(r'^comment/flag/', include(spirit.comment.flag.admin.urls, namespace='flag')),
url(r'^topic/', include(spirit.topic.admin.urls, namespace='topic')),
url(r'^user/', include(spirit.user.admin.urls, namespace='user')),
]

View File

@ -8,8 +8,7 @@ from . import views
urlpatterns = [
url(r'^$', views.index, name='admin-category'),
url(r'^list/$', views.index, name='admin-category-list'),
url(r'^create/$', views.create, name='admin-category-create'),
url(r'^update/(?P<category_id>\d+)/$', views.update, name='admin-category-update'),
url(r'^$', views.index, name='index'),
url(r'^create/$', views.create, name='create'),
url(r'^update/(?P<category_id>\d+)/$', views.update, name='update'),
]

View File

@ -29,7 +29,7 @@ def create(request):
if form.is_valid():
form.save()
return redirect(reverse("spirit:admin-category-list"))
return redirect(reverse("spirit:admin:category:index"))
else:
form = CategoryForm()
@ -48,7 +48,7 @@ def update(request, category_id):
if form.is_valid():
form.save()
messages.info(request, _("The category has been updated!"))
return redirect(reverse("spirit:admin-category-list"))
return redirect(reverse("spirit:admin:category:index"))
else:
form = CategoryForm(instance=category)

View File

@ -42,9 +42,9 @@ class Category(models.Model):
def get_absolute_url(self):
if self.pk == settings.ST_TOPIC_PRIVATE_CATEGORY_PK:
return reverse('spirit:private-list')
return reverse('spirit:topic:private:index')
else:
return reverse('spirit:category-detail', kwargs={'pk': str(self.id), 'slug': self.slug})
return reverse('spirit:category:detail', kwargs={'pk': str(self.id), 'slug': self.slug})
@property
def is_subcategory(self):

View File

@ -30,7 +30,7 @@ class CategoryViewTest(TestCase):
"""
should display all categories
"""
response = self.client.get(reverse('spirit:category-list'))
response = self.client.get(reverse('spirit:category:index'))
self.assertQuerysetEqual(
response.context['categories'],
['<Category: Uncategorized>', repr(self.category_1), repr(self.category_2)]
@ -48,7 +48,7 @@ class CategoryViewTest(TestCase):
Topic.objects.filter(pk=topic.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
Topic.objects.filter(pk=topic3.pk).update(last_active=timezone.now() - datetime.timedelta(days=5))
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.category_1.pk,
'slug': self.category_1.slug}))
self.assertQuerysetEqual(response.context['topics'], [repr(topic2), repr(topic3), repr(topic)])
@ -62,7 +62,7 @@ class CategoryViewTest(TestCase):
# show pinned first
Topic.objects.filter(pk=topic_a.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.category_1.pk,
'slug': self.category_1.slug}))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_a, topic_b, ]))
@ -78,7 +78,7 @@ class CategoryViewTest(TestCase):
# show globally pinned first
Topic.objects.filter(pk=topic_d.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': category.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': category.pk,
'slug': category.slug}))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_d, topic_b, topic_c, topic_a]))
@ -91,7 +91,7 @@ class CategoryViewTest(TestCase):
utils.create_topic(category=self.category_1, is_removed=True)
utils.create_topic(category=self.category_2)
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.category_1.pk,
'slug': self.category_1.slug}))
self.assertQuerysetEqual(response.context['topics'], [])
@ -99,14 +99,14 @@ class CategoryViewTest(TestCase):
"""
invalid category
"""
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': str(99), }))
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': str(99), }))
self.assertEqual(response.status_code, 404)
def test_category_detail_view_invalid_slug(self):
"""
invalid slug
"""
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.category_1.pk,
'slug': 'bar'}))
self.assertRedirects(response, self.category_1.get_absolute_url(), status_code=301)
@ -114,7 +114,7 @@ class CategoryViewTest(TestCase):
"""
no slug
"""
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.category_1.pk,
'slug': ''}))
self.assertRedirects(response, self.category_1.get_absolute_url(), status_code=301)
@ -124,7 +124,7 @@ class CategoryViewTest(TestCase):
"""
utils.create_topic(category=self.category_1)
topic2 = utils.create_topic(category=self.subcategory_1, title="topic_subcat1")
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.subcategory_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.subcategory_1.pk,
'slug': self.subcategory_1.slug}))
self.assertQuerysetEqual(response.context['topics'], [repr(topic2), ])
self.assertQuerysetEqual(response.context['categories'], [])
@ -137,7 +137,7 @@ class CategoryViewTest(TestCase):
topic = utils.create_topic(category=self.category_1)
bookmark = CommentBookmark.objects.create(topic=topic, user=self.user)
response = self.client.get(reverse('spirit:category-detail',
response = self.client.get(reverse('spirit:category:detail',
kwargs={'pk': self.category_1.pk,
'slug': self.category_1.slug}))
self.assertQuerysetEqual(response.context['topics'], [repr(topic), ])
@ -151,6 +151,6 @@ class CategoryViewTest(TestCase):
utils.create_topic(category=self.category_1)
topic = utils.create_topic(category=self.category_1)
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk,
response = self.client.get(reverse('spirit:category:detail', kwargs={'pk': self.category_1.pk,
'slug': self.category_1.slug}))
self.assertQuerysetEqual(response.context['topics'], [repr(topic), ])

View File

@ -8,8 +8,8 @@ from . import views
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='category-list'),
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P<pk>\d+)/$', views.detail, kwargs={'slug': "", }, name='category-detail'),
url(r'^(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.detail, name='category-detail'),
url(r'^(?P<pk>\d+)/$', views.detail, kwargs={'slug': "", }, name='detail'),
url(r'^(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.detail, name='detail'),
]

View File

@ -30,7 +30,7 @@ class CommentBookmarkViewTest(TestCase):
"""
utils.login(self)
form_data = {'comment_number': 999, }
response = self.client.post(reverse('spirit:bookmark-create', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:bookmark:create', kwargs={'topic_id': self.topic.pk, }),
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
data=form_data)
self.assertEqual(response.status_code, 200)

View File

@ -8,6 +8,6 @@ from . import views
urlpatterns = [
url(r'^(?P<topic_id>\d+)/create/$', views.create, name='bookmark-create'),
url(r'^(?P<topic_id>\d+)/find/$', views.find, name='bookmark-find'),
url(r'^(?P<topic_id>\d+)/create/$', views.create, name='create'),
url(r'^(?P<topic_id>\d+)/find/$', views.find, name='find'),
]

View File

@ -8,8 +8,8 @@ from . import views
urlpatterns = [
url(r'^$', views.opened, name='admin-flag'),
url(r'^open/$', views.opened, name='admin-flag-open'),
url(r'^closed/$', views.closed, name='admin-flag-closed'),
url(r'^(?P<pk>\d+)/$', views.detail, name='admin-flag-detail'),
url(r'^$', views.opened, name='index'),
url(r'^opened/$', views.opened, name='opened'),
url(r'^closed/$', views.closed, name='closed'),
url(r'^(?P<pk>\d+)/$', views.detail, name='detail'),
]

View File

@ -25,7 +25,7 @@ def detail(request, pk):
if form.is_valid():
form.save()
messages.info(request, _("The flag has been moderated!"))
return redirect(reverse("spirit:admin-flag"))
return redirect(reverse("spirit:admin:flag:index"))
else:
form = CommentFlagForm(instance=flag)

View File

@ -26,7 +26,7 @@ class FlagViewTest(TestCase):
"""
utils.login(self)
form_data = {'reason': "0", }
response = self.client.post(reverse('spirit:flag-create', kwargs={'comment_id': self.comment.pk, }),
response = self.client.post(reverse('spirit:comment:flag:create', kwargs={'comment_id': self.comment.pk, }),
form_data)
self.assertRedirects(response, self.comment.get_absolute_url(), status_code=302, target_status_code=302)
self.assertEqual(len(Flag.objects.all()), 1)

View File

@ -8,5 +8,5 @@ from . import views
urlpatterns = [
url(r'^(?P<comment_id>\d+)/create/$', views.create, name='flag-create'),
url(r'^(?P<comment_id>\d+)/create/$', views.create, name='create'),
]

View File

@ -26,4 +26,4 @@ class CommentHistory(models.Model):
return "%s: %s..." % (self.comment_fk.user.username, self.comment_html[:50])
def get_absolute_url(self):
return reverse('spirit:comment-history', kwargs={'pk': str(self.id), })
return reverse('spirit:comment:history:detail', kwargs={'pk': str(self.id), })

View File

@ -31,7 +31,7 @@ class CommentHistoryViewTest(TestCase):
CommentHistory.objects.create(comment_fk=comment2, comment_html=comment2.comment_html)
utils.login(self)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertQuerysetEqual(response.context['comments'], map(repr, [comment_history, ]))
@override_djconfig(comments_per_page=1)
@ -44,7 +44,7 @@ class CommentHistoryViewTest(TestCase):
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
utils.login(self)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertQuerysetEqual(response.context['comments'], map(repr, [comment_history, ]))
def test_comment_history_detail_private_topic(self):
@ -56,7 +56,7 @@ class CommentHistoryViewTest(TestCase):
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
utils.login(self)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertEqual(response.status_code, 200)
def test_comment_history_detail_removed(self):
@ -68,14 +68,14 @@ class CommentHistoryViewTest(TestCase):
# comment removed
comment = utils.create_comment(user=self.user, topic=self.topic, is_removed=True)
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertEqual(response.status_code, 404)
# topic removed
topic = utils.create_topic(category=self.category, user=self.user, is_removed=True)
comment = utils.create_comment(user=self.user, topic=topic)
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertEqual(response.status_code, 404)
# category removed
@ -83,7 +83,7 @@ class CommentHistoryViewTest(TestCase):
topic = utils.create_topic(category=category, user=self.user)
comment = utils.create_comment(user=self.user, topic=topic)
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertEqual(response.status_code, 404)
def test_comment_history_detail_no_access(self):
@ -97,7 +97,7 @@ class CommentHistoryViewTest(TestCase):
CommentHistory.objects.create(comment_fk=comment, comment_html=comment.comment_html)
utils.login(self)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertEqual(response.status_code, 404)
def test_comment_history_detail_denied_to_non_logged_users(self):
@ -105,7 +105,7 @@ class CommentHistoryViewTest(TestCase):
history should not be seen by guests
"""
comment = utils.create_comment(user=self.user, topic=self.topic)
response = self.client.get(reverse('spirit:comment-history', kwargs={'comment_id': comment.pk, }))
response = self.client.get(reverse('spirit:comment:history:detail', kwargs={'comment_id': comment.pk, }))
self.assertEqual(response.status_code, 302)

View File

@ -8,5 +8,5 @@ from . import views
urlpatterns = [
url(r'^(?P<comment_id>\d+)/$', views.detail, name='comment-history'),
url(r'^(?P<comment_id>\d+)/$', views.detail, name='detail'),
]

View File

@ -28,4 +28,4 @@ class CommentLike(models.Model):
return "%s likes %s" % (self.user, self.comment)
def get_delete_url(self):
return reverse('spirit:like-delete', kwargs={'pk': str(self.pk), })
return reverse('spirit:comment:like:delete', kwargs={'pk': str(self.pk), })

View File

@ -28,7 +28,7 @@ class LikeViewTest(TestCase):
"""
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:like-create', kwargs={'comment_id': self.comment.pk, }),
response = self.client.post(reverse('spirit:comment:like:create', kwargs={'comment_id': self.comment.pk, }),
form_data)
self.assertRedirects(response, self.comment.get_absolute_url(), status_code=302, target_status_code=302)
self.assertEqual(len(CommentLike.objects.all()), 1)
@ -39,7 +39,7 @@ class LikeViewTest(TestCase):
"""
utils.login(self)
form_data = {'next': '/fakepath/', }
response = self.client.post(reverse('spirit:like-create', kwargs={'comment_id': self.comment.pk, }),
response = self.client.post(reverse('spirit:comment:like:create', kwargs={'comment_id': self.comment.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
@ -50,7 +50,7 @@ class LikeViewTest(TestCase):
CommentLike.objects.create(user=self.user, comment=self.comment)
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:like-create', kwargs={'comment_id': self.comment.pk, }),
response = self.client.post(reverse('spirit:comment:like:create', kwargs={'comment_id': self.comment.pk, }),
form_data)
self.assertEqual(response.status_code, 200)
@ -61,7 +61,7 @@ class LikeViewTest(TestCase):
utils.login(self)
like = CommentLike.objects.create(user=self.user, comment=self.comment)
form_data = {}
response = self.client.post(reverse('spirit:like-delete', kwargs={'pk': like.pk, }),
response = self.client.post(reverse('spirit:comment:like:delete', kwargs={'pk': like.pk, }),
form_data)
self.assertRedirects(response, self.comment.get_absolute_url(), status_code=302, target_status_code=302)
self.assertEqual(len(CommentLike.objects.all()), 0)
@ -73,7 +73,7 @@ class LikeViewTest(TestCase):
utils.login(self)
like = CommentLike.objects.create(user=self.user, comment=self.comment)
form_data = {'next': '/fakepath/', }
response = self.client.post(reverse('spirit:like-delete', kwargs={'pk': like.pk, }),
response = self.client.post(reverse('spirit:comment:like:delete', kwargs={'pk': like.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)

View File

@ -8,6 +8,6 @@ from . import views
urlpatterns = [
url(r'^(?P<comment_id>\d+)/create/$', views.create, name='like-create'),
url(r'^(?P<pk>\d+)/delete/$', views.delete, name='like-delete'),
url(r'^(?P<comment_id>\d+)/create/$', views.create, name='create'),
url(r'^(?P<pk>\d+)/delete/$', views.delete, name='delete'),
]

View File

@ -48,7 +48,7 @@ def delete(request, pk):
comment_like_post_delete.send(sender=like.__class__, comment=like.comment)
if request.is_ajax():
url = reverse('spirit:like-create', kwargs={'comment_id': like.comment.pk, })
url = reverse('spirit:comment:like:create', kwargs={'comment_id': like.comment.pk, })
return json_response({'url_create': url, })
return redirect(request.POST.get('next', like.comment.get_absolute_url()))

View File

@ -54,7 +54,7 @@ class Comment(models.Model):
return "%s: %s..." % (self.user.username, self.comment[:50])
def get_absolute_url(self):
return reverse('spirit:comment-find', kwargs={'pk': str(self.id), })
return reverse('spirit:comment:find', kwargs={'pk': str(self.id), })
@property
def like(self):

View File

@ -46,19 +46,19 @@ class CommentViewTest(TestCase):
"""
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
expected_url = reverse('spirit:comment-find', kwargs={'pk': 1, })
expected_url = reverse('spirit:comment:find', kwargs={'pk': 1, })
self.assertRedirects(response, expected_url, status_code=302, target_status_code=302)
self.assertEqual(len(Comment.objects.all()), 1)
# ratelimit
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(len(Comment.objects.all()), 1)
# get
response = self.client.get(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }))
response = self.client.get(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['topic'], self.topic)
@ -70,9 +70,9 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': private.topic.pk, }),
form_data)
expected_url = reverse('spirit:comment-find', kwargs={'pk': 1, })
expected_url = reverse('spirit:comment:find', kwargs={'pk': 1, })
self.assertRedirects(response, expected_url, status_code=302, target_status_code=302)
self.assertEqual(len(Comment.objects.all()), 1)
@ -84,7 +84,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -96,7 +96,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(len(Comment.objects.all()), 1)
@ -110,7 +110,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -121,7 +121,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': topic2.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': topic2.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -131,7 +131,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -144,7 +144,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -158,7 +158,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foobar', }
self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }), form_data)
self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }), form_data)
self.assertEqual(self._comment.comment, 'foobar')
def test_comment_publish_quote(self):
@ -167,7 +167,7 @@ class CommentViewTest(TestCase):
"""
utils.login(self)
comment = utils.create_comment(topic=self.topic)
response = self.client.get(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk,
response = self.client.get(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk,
'pk': comment.pk}))
self.assertEqual(response.context['form'].initial['comment'],
markdown.quotify(comment.comment, comment.user.username))
@ -178,7 +178,7 @@ class CommentViewTest(TestCase):
"""
utils.login(self)
form_data = {'comment': 'foobar', 'next': '/fakepath/'}
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
@ -190,15 +190,15 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'barfoo', }
response = self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:update', kwargs={'pk': comment.pk, }),
form_data)
expected_url = reverse('spirit:comment-find', kwargs={'pk': 1, })
expected_url = reverse('spirit:comment:find', kwargs={'pk': 1, })
self.assertRedirects(response, expected_url, status_code=302, target_status_code=302)
self.assertEqual(Comment.objects.get(pk=comment.pk).comment, 'barfoo')
# next
form_data.update({'next': '/fakepath/', })
response = self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:update', kwargs={'pk': comment.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
@ -211,7 +211,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'barfoo', }
response = self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:update', kwargs={'pk': comment.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -225,9 +225,9 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'barfoo', }
response = self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:update', kwargs={'pk': comment.pk, }),
form_data)
expected_url = reverse('spirit:comment-find', kwargs={'pk': 1, })
expected_url = reverse('spirit:comment:find', kwargs={'pk': 1, })
self.assertRedirects(response, expected_url, status_code=302, target_status_code=302)
self.assertEqual(Comment.objects.get(pk=comment.pk).comment, 'barfoo')
@ -242,7 +242,7 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'barfoo', }
response = self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:update', kwargs={'pk': comment.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -261,7 +261,7 @@ class CommentViewTest(TestCase):
utils.login(self)
comment_posted = utils.create_comment(user=self.user, topic=self.topic)
form_data = {'comment': 'barfoo', }
self.client.post(reverse('spirit:comment-update', kwargs={'pk': comment_posted.pk, }),
self.client.post(reverse('spirit:comment:update', kwargs={'pk': comment_posted.pk, }),
form_data)
self.assertEqual(repr(self._comment_new), repr(Comment.objects.get(pk=comment_posted.pk)))
self.assertEqual(repr(self._comment_old), repr(comment_posted))
@ -283,12 +283,12 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:comment-delete', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:delete', kwargs={'pk': comment.pk, }),
form_data)
expected_url = comment.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302, target_status_code=302)
response = self.client.get(reverse('spirit:comment-delete', kwargs={'pk': comment.pk, }))
response = self.client.get(reverse('spirit:comment:delete', kwargs={'pk': comment.pk, }))
self.assertEqual(response.status_code, 200)
def test_comment_undelete(self):
@ -302,12 +302,12 @@ class CommentViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:comment-undelete', kwargs={'pk': comment.pk, }),
response = self.client.post(reverse('spirit:comment:undelete', kwargs={'pk': comment.pk, }),
form_data)
expected_url = comment.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302, target_status_code=302)
response = self.client.get(reverse('spirit:comment-undelete', kwargs={'pk': comment.pk, }))
response = self.client.get(reverse('spirit:comment:undelete', kwargs={'pk': comment.pk, }))
self.assertEqual(response.status_code, 200)
def test_comment_move(self):
@ -322,7 +322,7 @@ class CommentViewTest(TestCase):
to_topic = utils.create_topic(category=self.category)
form_data = {'topic': to_topic.pk,
'comments': [comment.pk, comment2.pk], }
response = self.client.post(reverse('spirit:comment-move', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:move', kwargs={'topic_id': self.topic.pk, }),
form_data)
expected_url = self.topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -354,7 +354,7 @@ class CommentViewTest(TestCase):
form_data = {'topic': to_topic.pk,
'comments': [comment.pk, comment2.pk], }
response = self.client.post(reverse('spirit:comment-move', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:comment:move', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertListEqual(self._comments, [comment2, comment])
@ -366,7 +366,7 @@ class CommentViewTest(TestCase):
comment absolute and lazy url
"""
comment = utils.create_comment(user=self.user, topic=self.topic)
response = self.client.post(reverse('spirit:comment-find', kwargs={'pk': comment.pk, }))
response = self.client.post(reverse('spirit:comment:find', kwargs={'pk': comment.pk, }))
expected_url = comment.topic.get_absolute_url() + "#c%d" % comment.pk
self.assertRedirects(response, expected_url, status_code=302)
@ -378,7 +378,7 @@ class CommentViewTest(TestCase):
img = BytesIO(b'GIF87a\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00ccc,\x00'
b'\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;')
files = {'image': SimpleUploadedFile('image.gif', img.read(), content_type='image/gif'), }
response = self.client.post(reverse('spirit:comment-image-upload-ajax'),
response = self.client.post(reverse('spirit:comment:image-upload-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
data=files)
res = json.loads(response.content.decode('utf-8'))
@ -396,7 +396,7 @@ class CommentViewTest(TestCase):
image.name = 'image.gif'
image.content_type = 'image/gif'
files = {'image': SimpleUploadedFile(image.name, image.read()), }
response = self.client.post(reverse('spirit:comment-image-upload-ajax'),
response = self.client.post(reverse('spirit:comment:image-upload-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
data=files)
res = json.loads(response.content.decode('utf-8'))

View File

@ -2,21 +2,30 @@
from __future__ import unicode_literals
from django.conf.urls import url
from django.conf.urls import url, include
import spirit.comment.bookmark.urls
import spirit.comment.flag.urls
import spirit.comment.history.urls
import spirit.comment.like.urls
from . import views
urlpatterns = [
url(r'^(?P<topic_id>\d+)/publish/$', views.publish, name='comment-publish'),
url(r'^(?P<topic_id>\d+)/publish/(?P<pk>\d+)/quote/$', views.publish, name='comment-publish'),
url(r'^(?P<topic_id>\d+)/publish/$', views.publish, name='publish'),
url(r'^(?P<topic_id>\d+)/publish/(?P<pk>\d+)/quote/$', views.publish, name='publish'),
url(r'^(?P<pk>\d+)/update/$', views.update, name='comment-update'),
url(r'^(?P<pk>\d+)/find/$', views.find, name='comment-find'),
url(r'^(?P<topic_id>\d+)/move/$', views.move, name='comment-move'),
url(r'^(?P<pk>\d+)/update/$', views.update, name='update'),
url(r'^(?P<pk>\d+)/find/$', views.find, name='find'),
url(r'^(?P<topic_id>\d+)/move/$', views.move, name='move'),
url(r'^(?P<pk>\d+)/delete/$', views.delete, name='comment-delete'),
url(r'^(?P<pk>\d+)/undelete/$', views.delete, kwargs={'remove': False, }, name='comment-undelete'),
url(r'^(?P<pk>\d+)/delete/$', views.delete, name='delete'),
url(r'^(?P<pk>\d+)/undelete/$', views.delete, kwargs={'remove': False, }, name='undelete'),
url(r'^upload/$', views.image_upload_ajax, name='comment-image-upload-ajax'),
url(r'^upload/$', views.image_upload_ajax, name='image-upload-ajax'),
url(r'^bookmark/', include(spirit.comment.bookmark.urls, namespace='bookmark')),
url(r'^flag/', include(spirit.comment.flag.urls, namespace='flag')),
url(r'^history/', include(spirit.comment.history.urls, namespace='history')),
url(r'^like/', include(spirit.comment.like.urls, namespace='like')),
]

View File

@ -28,20 +28,12 @@ class PrivateForumMiddleware(object):
if resolver_match.app_name != 'spirit':
return
url_whitelist = {
'user-login',
'user-logout',
'user-register',
'resend-activation',
'registration-activation',
'password-reset',
'password-reset-done',
'password-reset-confirm',
'password-reset-complete'
}
full_namespace = ':'.join(resolver_match.namespaces)
if resolver_match.url_name in url_whitelist:
if full_namespace != 'spirit:user:auth':
return
return redirect_to_login(next=request.get_full_path(),
login_url=settings.LOGIN_URL)
return redirect_to_login(
next=request.get_full_path(),
login_url=settings.LOGIN_URL
)

View File

@ -77,7 +77,7 @@ class SearchViewTest(TestCase):
advanced search by topic
"""
utils.login(self)
response = self.client.get(reverse('spirit:search'))
response = self.client.get(reverse('spirit:search:search'))
self.assertEqual(response.status_code, 200)
def test_advanced_search_topics(self):
@ -86,7 +86,7 @@ class SearchViewTest(TestCase):
"""
utils.login(self)
data = {'q': 'spirit search', }
response = self.client.get(reverse('spirit:search'),
response = self.client.get(reverse('spirit:search:search'),
data)
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual([s.object for s in response.context['page']], map(repr, [self.topic, ]))
@ -98,7 +98,7 @@ class SearchViewTest(TestCase):
"""
utils.login(self)
data = {'q': 'foo', }
response = self.client.get(reverse('spirit:search'),
response = self.client.get(reverse('spirit:search:search'),
data)
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual([s.object for s in response.context['page']], map(repr, [self.topic2, ]))
@ -110,12 +110,12 @@ class SearchViewTest(TestCase):
utils.login(self)
category = utils.create_category()
data = {'q': 'spirit search', 'category': category.pk}
response = self.client.get(reverse('spirit:search'),
response = self.client.get(reverse('spirit:search:search'),
data)
self.assertQuerysetEqual(response.context['page'], [])
data['category'] = self.category.pk
response = self.client.get(reverse('spirit:search'),
response = self.client.get(reverse('spirit:search:search'),
data)
self.assertEqual(len(response.context['page']), 1)

View File

@ -10,6 +10,8 @@ from . import views
urlpatterns = [
url(r'^$', login_required(views.SearchView(template='spirit/search/search.html', form_class=AdvancedSearchForm)),
name='search'),
url(r'^$', login_required(views.SearchView(
template='spirit/search/search.html',
form_class=AdvancedSearchForm)
), name='search'),
]

View File

@ -37,6 +37,8 @@ ST_UNIQUE_EMAILS = True
# Django & Spirit settings defined below...
#
# TODO: change all tuples to list so we can do .extend(arg1, arag2, ...)
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
@ -63,8 +65,8 @@ AUTHENTICATION_BACKENDS = (
'spirit.user.auth.backends.EmailAuthBackend',
)
LOGIN_URL = 'spirit:user-login'
LOGIN_REDIRECT_URL = 'spirit:profile-update'
LOGIN_URL = 'spirit:user:auth:login'
LOGIN_REDIRECT_URL = 'spirit:user:update'
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',

View File

@ -277,7 +277,7 @@ class Category(models.Model):
verbose_name_plural = _(&quot;categories&quot;)
def get_absolute_url(self):
return reverse('spirit:category-detail', kwargs={'pk': str(self.id), 'slug': self.slug})
return reverse('spirit:category:detail', kwargs={'pk': str(self.id), 'slug': self.slug})
@property
def is_subcategory(self):

View File

@ -52,8 +52,8 @@
{% if user.is_authenticated %}
$.notification( {
notificationUrl: "{% url "spirit:topic-notification-ajax" %}",
notificationListUrl: "{% url "spirit:topic-notification-list-unread" %}",
notificationUrl: "{% url "spirit:topic:notification:index-ajax" %}",
notificationListUrl: "{% url "spirit:topic:notification:index-unread" %}",
mentionTxt: "{% trans "{user} has mention you on {topic}" %}",
commentTxt: "{% trans "{user} has commented on {topic}" %}",
showAll: "{% trans "Show all" %}",

View File

@ -7,9 +7,9 @@
{% has_topic_notifications user as has_notifications %}
<ul class="header-tabs">
<li><a class="header-tab-link js-tab" href="{% url "spirit:search" %}" data-related=".js-search-content"><i class="fa fa-search"></i></a></li><!--
--><li><a class="header-tab-link js-tab-notification{% if has_notifications %} is-highlighted{% endif %}" href="{% url "spirit:topic-notification-list" %}" data-related=".js-notifications-content"><i class="fa fa-bell"></i></a></li><!--
--><li><a class="header-tab-link js-tab" href="{% url "spirit:user-menu" %}" data-related=".js-user-content">{{ user.username }} <i class="fa fa-chevron-down"></i></a></li>
<li><a class="header-tab-link js-tab" href="{% url "spirit:search:search" %}" data-related=".js-search-content"><i class="fa fa-search"></i></a></li><!--
--><li><a class="header-tab-link js-tab-notification{% if has_notifications %} is-highlighted{% endif %}" href="{% url "spirit:topic:notification:index" %}" data-related=".js-notifications-content"><i class="fa fa-bell"></i></a></li><!--
--><li><a class="header-tab-link js-tab" href="{% url "spirit:user:menu" %}" data-related=".js-user-content">{{ user.username }} <i class="fa fa-chevron-down"></i></a></li>
</ul>
<div class="header-tabs-content">
@ -17,16 +17,16 @@
<div class="header-tab-content js-tab-content js-user-content">
<nav class="header-nav">
<ul class="menu">
<li><a class="menu-link" href="{% url "spirit:profile-detail" pk=user.pk slug=user.st.slug %}">{% trans "Profile" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic-active" %}">{% trans "Topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic-unread-list" %}">{% trans "Unread topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:private-list" %}">{% trans "Private topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:user:detail" pk=user.pk slug=user.st.slug %}">{% trans "Profile" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:index-active" %}">{% trans "Topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:unread:index" %}">{% trans "Unread topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:private:index" %}">{% trans "Private topics" %}</a></li>
{% if user.st.is_administrator %}
<li><a class="menu-link" href="{% url "spirit:admin" %}">{% trans "Admin" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:admin:index" %}">{% trans "Admin" %}</a></li>
{% endif %}
<li><a class="menu-link js-post" href="{% url "spirit:user-logout" %}?next={% firstof request.get_full_path|urlencode '/' %}">{% trans "Log out" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:user:auth:logout" %}?next={% firstof request.get_full_path|urlencode '/' %}">{% trans "Log out" %}</a></li>
</ul>
</nav>
</div>
@ -39,6 +39,6 @@
</div>
{% else %}
<a class="header-link" href="{% url "spirit:user-login" %}?next={% firstof request.get_full_path|urlencode '/' %}">{% trans "Log in" %}</a>
<a class="header-link" href="{% url "spirit:user:auth:login" %}?next={% firstof request.get_full_path|urlencode '/' %}">{% trans "Log in" %}</a>
{% endif %}
</header>

View File

@ -6,11 +6,11 @@
<a class="side-menu-close" href="#"><i class="fa fa-times-circle-o"></i></a>
<ul>
<li><a class="side-menu-link{% ifequal active "dashboard" %} is-selected{% endifequal %}" href="{% url "spirit:admin" %}">{% trans "Dashboard" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "basic_settings" %} is-selected{% endifequal %}" href="{% url "spirit:admin-config-basic" %}">{% trans "Basic settings" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "categories" %} is-selected{% endifequal %}" href="{% url "spirit:admin-category" %}">{% trans "Categories" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "topics" %} is-selected{% endifequal %}" href="{% url "spirit:admin-topic" %}">{% trans "Topics" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "users" %} is-selected{% endifequal %}" href="{% url "spirit:admin-user" %}">{% trans "Users" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "flags" %} is-selected{% endifequal %}" href="{% url "spirit:admin-flag" %}">{% trans "Flags" %}</a></li>
<li><a class="side-menu-link{% ifequal active "dashboard" %} is-selected{% endifequal %}" href="{% url "spirit:admin:index" %}">{% trans "Dashboard" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "basic_settings" %} is-selected{% endifequal %}" href="{% url "spirit:admin:config-basic" %}">{% trans "Basic settings" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "categories" %} is-selected{% endifequal %}" href="{% url "spirit:admin:category:index" %}">{% trans "Categories" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "topics" %} is-selected{% endifequal %}" href="{% url "spirit:admin:topic:index" %}">{% trans "Topics" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "users" %} is-selected{% endifequal %}" href="{% url "spirit:admin:user:index" %}">{% trans "Users" %}</a></li><!--
--><li><a class="side-menu-link{% ifequal active "flags" %} is-selected{% endifequal %}" href="{% url "spirit:admin:flag:index" %}">{% trans "Flags" %}</a></li>
</ul>
</div>

View File

@ -10,7 +10,7 @@
<h1 class="headline">{% trans "Category list" %}</h1>
<a class="button" href="{% url "spirit:admin-category-create" %}">{% trans "Create Category" %}</a>
<a class="button" href="{% url "spirit:admin:category:create" %}">{% trans "Create Category" %}</a>
<div class="rows">
@ -26,7 +26,7 @@
<i class="fa fa-lock"></i>
{% endif %}
<a class="row-edit" href="{% url "spirit:admin-category-update" category_id=c.pk %}"><i class="fa fa-cog"></i> {% trans "edit" %}</a>
<a class="row-edit" href="{% url "spirit:admin:category:update" category_id=c.pk %}"><i class="fa fa-cog"></i> {% trans "edit" %}</a>
</div>
{% for subc in c.category_set.all %}
@ -41,7 +41,7 @@
<i class="fa fa-lock"></i>
{% endif %}
<a class="row-edit" href="{% url "spirit:admin-category-update" category_id=subc.pk %}"><i class="fa fa-cog"></i> {% trans "edit" %}</a>
<a class="row-edit" href="{% url "spirit:admin:category:update" category_id=subc.pk %}"><i class="fa fa-cog"></i> {% trans "edit" %}</a>
</div>
{% endfor %}
{% endfor %}

View File

@ -29,7 +29,7 @@
$( '.js-reply' ).find( 'textarea' ).editor_image_upload( {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:comment-image-upload-ajax" %}",
target: "{% url "spirit:comment:image-upload-ajax" %}",
placeholderText: "{% trans "uploading {image_name}" %}"
} )
.editor( {

View File

@ -1,6 +1,6 @@
{% load i18n %}
<form action="{% url "spirit:comment-publish" topic_id %}" method="post" class="js-reply">
<form action="{% url "spirit:comment:publish" topic_id %}" method="post" class="js-reply">
{% csrf_token %}
{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}

View File

@ -22,7 +22,7 @@
<ul class="comment-date">
{% if c.modified_count > 0 %}
<li><a href="{% url "spirit:comment-history" comment_id=c.pk %}"><i class="fa fa-pencil"></i> {{ c.modified_count }}</a></li>
<li><a href="{% url "spirit:comment:history:detail" comment_id=c.pk %}"><i class="fa fa-pencil"></i> {{ c.modified_count }}</a></li>
{% endif %}
<li title="{{ c.date }}">{{ c.date|shortnaturaltime }}</li>
@ -44,31 +44,31 @@
<ul class="comment-actions">
{% if user.is_authenticated %}
{% if user.st.is_moderator %}
<li><a href="{% url "spirit:comment-delete" c.pk %}"><i class="fa fa-times"></i> {% trans "delete" %}</a></li>
<li><a href="{% url "spirit:comment:delete" c.pk %}"><i class="fa fa-times"></i> {% trans "delete" %}</a></li>
{% endif %}
<li><a href="{% url "spirit:flag-create" c.pk %}"><i class="fa fa-flag"></i> {% trans "report" %}</a></li>
<li><a href="{% url "spirit:comment:flag:create" c.pk %}"><i class="fa fa-flag"></i> {% trans "report" %}</a></li>
{% endif %}
<li><a class="js-share" href="#" data-dialog=".js-share-{{ c.pk }}"><i class="fa fa-share"></i> {% trans "share" %}</a></li>
{% if user.is_authenticated %}
{% if c.like %}
<li class="comment-like"><a class="js-like" href="{% url "spirit:like-delete" c.like.pk %}" data-count="{{ c.likes_count }}" ><i class="fa fa-heart"></i> {% trans "remove like" %} ({{ c.likes_count }})</a></li>
<li class="comment-like"><a class="js-like" href="{% url "spirit:comment:like:delete" c.like.pk %}" data-count="{{ c.likes_count }}" ><i class="fa fa-heart"></i> {% trans "remove like" %} ({{ c.likes_count }})</a></li>
{% else %}
{% ifnotequal c.user user %}
<li class="comment-like"><a class="js-like" class="like" href="{% url "spirit:like-create" c.pk %}" data-count="{{ c.likes_count }}" ><i class="fa fa-heart"></i> {% trans "like" %} ({{ c.likes_count }})</a></li>
<li class="comment-like"><a class="js-like" class="like" href="{% url "spirit:comment:like:create" c.pk %}" data-count="{{ c.likes_count }}" ><i class="fa fa-heart"></i> {% trans "like" %} ({{ c.likes_count }})</a></li>
{% else %}
<li class="comment-like"><i class="fa fa-heart"></i> ({{ c.likes_count }})</li>
{% endifnotequal %}
{% endif %}
{% if user.st.is_moderator or c.user.pk == user.pk %}
<li><a href="{% url "spirit:comment-update" pk=c.pk %}" >{% trans "edit" %}</a></li>
<li><a href="{% url "spirit:comment:update" pk=c.pk %}" >{% trans "edit" %}</a></li>
{% endif %}
{% ifnotequal c.user.pk user.pk %}
<li><a href="{% url "spirit:comment-publish" topic_id=topic.pk pk=c.pk %}" >{% trans "quote" %}</a></li>
<li><a href="{% url "spirit:comment:publish" topic_id=topic.pk pk=c.pk %}" >{% trans "quote" %}</a></li>
<li><a href="#reply" >{% trans "reply" %}</a></li>
{% endifnotequal %}
{% endif %}
@ -115,7 +115,7 @@
{% if user.st.is_moderator %}
<ul class="comment-actions">
<li><a href="{% url "spirit:comment-undelete" c.pk %}"><i class="fa fa-times"></i> {% trans "undelete" %}</a></li>
<li><a href="{% url "spirit:comment:undelete" c.pk %}"><i class="fa fa-times"></i> {% trans "undelete" %}</a></li>
</ul>
{% endif %}

View File

@ -6,7 +6,7 @@
{% for f in flags %}
<div class="row">
<a href="{{ f.comment.get_absolute_url }}">{{ f.comment.topic.title }}</a> <a class="row-edit" href="{% url "spirit:admin-flag-detail" pk=f.pk %}"><i class="fa fa-cog"></i> {% trans "moderate" %}</a>
<a href="{{ f.comment.get_absolute_url }}">{{ f.comment.topic.title }}</a> <a class="row-edit" href="{% url "spirit:admin:flag:detail" pk=f.pk %}"><i class="fa fa-cog"></i> {% trans "moderate" %}</a>
</div>
{% endfor %}

View File

@ -1,6 +1,6 @@
{% load i18n %}
<ul class="tabs">
<li><a class="tab-link{% ifequal active_tab "open" %} is-selected{% endifequal %}" href="{% url "spirit:admin-flag-open" %}" >{% trans "Open" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "closed" %} is-selected{% endifequal %}" href="{% url "spirit:admin-flag-closed" %}" >{% trans "Closed" %}</a></li>
<li><a class="tab-link{% ifequal active_tab "open" %} is-selected{% endifequal %}" href="{% url "spirit:admin:flag:opened" %}" >{% trans "Open" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "closed" %} is-selected{% endifequal %}" href="{% url "spirit:admin:flag:closed" %}" >{% trans "Closed" %}</a></li>
</ul>

View File

@ -7,8 +7,8 @@
{% block content %}
<ul class="nav">
<li><a href="{% url "spirit:admin" %}" >{% trans "Admin" %}</a><i class="fa fa-chevron-right"></i></li><!--
--><li><a href="{% url "spirit:admin-flag" %}" >{% trans "Flags" %}</a></li>
<li><a href="{% url "spirit:admin:index" %}" >{% trans "Admin" %}</a><i class="fa fa-chevron-right"></i></li><!--
--><li><a href="{% url "spirit:admin:flag:index" %}" >{% trans "Flags" %}</a></li>
</ul>
<h1 class="headline">{% trans "Flag" %}</h1>

View File

@ -1,7 +1,7 @@
{% if like %}
<form action="{% url "spirit:like-delete" like.pk %}" method="post">
<form action="{% url "spirit:comment:like:delete" like.pk %}" method="post">
{% else %}
<form action="{% url "spirit:like-create" comment_id %}" method="post">
<form action="{% url "spirit:comment:like:create" comment_id %}" method="post">
{% endif %}
{% csrf_token %}
{% include "spirit/_form.html" %}

View File

@ -1,6 +1,6 @@
{% load i18n %}
<form method="get" action="{% url "spirit:search" %}">
<form method="get" action="{% url "spirit:search:search" %}">
{% include "spirit/_form.html" %}
<input class="button" type="submit" value="{% trans "Search" %}" />

View File

@ -9,7 +9,7 @@
{% if not query %}
<h1 class="headline">{% trans "Search" %}</h1>
<form method="get" action="{% url "spirit:search" %}">
<form method="get" action="{% url "spirit:search:search" %}">
{% include "spirit/_form.html" %}
<input class="button" type="submit" value="{% trans "Search" %}" />

View File

@ -16,7 +16,7 @@
{% if category.parent %}
<li><a class="menu-link" href="{{ category.parent.get_absolute_url }}" >{% trans "All Subcategories" %}</a></li>
{% else %}
<li><a class="menu-link" href="{% url "spirit:topic-active" %}" >{% trans "All Categories" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:index-active" %}" >{% trans "All Categories" %}</a></li>
{% endif %}
</ul>
</div>
@ -24,9 +24,9 @@
<div class="new-topic">
{% if category %}
<a class="button" href="{% url "spirit:topic-publish" category.pk %}">{% trans "Create Topic" %}</a>
<a class="button" href="{% url "spirit:topic:publish" category.pk %}">{% trans "Create Topic" %}</a>
{% else %}
<a class="button" href="{% url "spirit:topic-publish" %}">{% trans "Create Topic" %}</a>
<a class="button" href="{% url "spirit:topic:publish" %}">{% trans "Create Topic" %}</a>
{% endif %}
</div>
</div>

View File

@ -1,7 +1,7 @@
{% load i18n %}
<ul class="tabs">
<li><a class="tab-link{% ifequal active_tab "deleted" %} is-selected{% endifequal %}" href="{% url "spirit:admin-topic-deleted" %}" >{% trans "Deleted" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "closed" %} is-selected{% endifequal %}" href="{% url "spirit:admin-topic-closed" %}" >{% trans "Closed" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "pinned" %} is-selected{% endifequal %}" href="{% url "spirit:admin-topic-pinned" %}" >{% trans "Pinned" %}</a></li>
<li><a class="tab-link{% ifequal active_tab "deleted" %} is-selected{% endifequal %}" href="{% url "spirit:admin:topic:deleted" %}" >{% trans "Deleted" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "closed" %} is-selected{% endifequal %}" href="{% url "spirit:admin:topic:closed" %}" >{% trans "Closed" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "pinned" %} is-selected{% endifequal %}" href="{% url "spirit:admin:topic:pinned" %}" >{% trans "Pinned" %}</a></li>
</ul>

View File

@ -27,9 +27,9 @@
{{ topic.title }}
{% if user.st.is_moderator %}
<a class="head-edit-link" href="{% url "spirit:topic-update" topic.pk %}"><i class="fa fa-pencil"></i> {% trans "edit" %}</a>
<a class="head-edit-link" href="{% url "spirit:topic:update" topic.pk %}"><i class="fa fa-pencil"></i> {% trans "edit" %}</a>
{% elif user.pk == topic.user.pk and not topic.is_closed %}
<a class="head-edit-link" href="{% url "spirit:topic-update" topic.pk %}"><i class="fa fa-pencil"></i> {% trans "edit" %}</a>
<a class="head-edit-link" href="{% url "spirit:topic:update" topic.pk %}"><i class="fa fa-pencil"></i> {% trans "edit" %}</a>
{% endif %}
</h1>
@ -42,27 +42,27 @@
<li><a class="menu-link js-show-move-comments" href="#" ><i class="fa fa-comments"></i> {% trans "Select comments to move" %}</a></li>
{% if topic.is_removed %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-undelete" topic.pk %}" ><i class="fa fa-trash-o"></i> {% trans "Undelete topic" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:undelete" topic.pk %}" ><i class="fa fa-trash-o"></i> {% trans "Undelete topic" %}</a></li>
{% else %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-delete" topic.pk %}" ><i class="fa fa-trash-o"></i> {% trans "Delete topic" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:delete" topic.pk %}" ><i class="fa fa-trash-o"></i> {% trans "Delete topic" %}</a></li>
{% endif %}
{% if topic.is_closed %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-unlock" topic.pk %}" ><i class="fa fa-unlock"></i> {% trans "Open topic" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:unlock" topic.pk %}" ><i class="fa fa-unlock"></i> {% trans "Open topic" %}</a></li>
{% else %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-lock" topic.pk %}" ><i class="fa fa-lock"></i> {% trans "Close topic" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:lock" topic.pk %}" ><i class="fa fa-lock"></i> {% trans "Close topic" %}</a></li>
{% endif %}
{% if topic.is_pinned %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-unpin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Unpin topic" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:unpin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Unpin topic" %}</a></li>
{% else %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-pin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Pin topic" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:pin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Pin topic" %}</a></li>
{% endif %}
{% if topic.is_globally_pinned %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-global-unpin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Unpin topic globally" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:global-unpin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Unpin topic globally" %}</a></li>
{% else %}
<li><a class="menu-link js-post" href="{% url "spirit:topic-global-pin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Pin topic globally" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:topic:moderate:global-pin" topic.pk %}" ><i class="fa fa-thumb-tack"></i> {% trans "Pin topic globally" %}</a></li>
{% endif %}
</ul>
</div>
@ -89,7 +89,7 @@
{% if user.is_authenticated %}
{% render_notification_form user=user topic=topic %}
{% elif not topic.is_closed %}
<a class="button" href="{% url "spirit:comment-publish" topic_id=topic.pk %}">{% trans "Reply" %}</a>
<a class="button" href="{% url "spirit:comment:publish" topic_id=topic.pk %}">{% trans "Reply" %}</a>
{% endif %}
</div>
</div>
@ -116,14 +116,14 @@
$( ".comment" ).bookmark( {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:bookmark-create" topic.pk %}",
target: "{% url "spirit:comment:bookmark:create" topic.pk %}",
} );
{% if user.st.is_moderator %}
$('.js-show-move-comments').move_comments( {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:comment-move" topic.pk %}",
target: "{% url "spirit:comment:move" topic.pk %}",
} );
{% endif %}

View File

@ -1,9 +1,9 @@
{% load i18n %}
{% if notification %}
<form method="post" action="{% url "spirit:topic-notification-update" notification.pk %}">
<form method="post" action="{% url "spirit:topic:notification:update" notification.pk %}">
{% else %}
<form method="post" action="{% url "spirit:topic-notification-create" topic_id %}">
<form method="post" action="{% url "spirit:topic:notification:create" topic_id %}">
{% endif %}
{% csrf_token %}
{% include "spirit/_form.html" %}

View File

@ -2,8 +2,8 @@
{% for n in notifications %}
<div class="row">
{% url "spirit:profile-detail" pk=n.comment.user.pk slug=n.comment.user.st.slug as url_profile %}
{% url "spirit:comment-find" pk=n.comment.pk as url_topic %}
{% url "spirit:user:detail" pk=n.comment.user.pk slug=n.comment.user.st.slug as url_profile %}
{% url "spirit:comment:find" pk=n.comment.pk as url_topic %}
{% if n.is_comment %}
{% blocktrans with username=n.comment.user.username topic_title=n.topic.title %}<a href="{{ url_profile }}">{{ username }}</a> has commented on <a href="{{ url_topic }}">{{ topic_title }}</a>{% endblocktrans %}

View File

@ -1,15 +1,15 @@
{% load i18n %}
{% if poll %}
<form action="{% url "spirit:poll-vote" pk=poll.pk %}" method="post">
<form action="{% url "spirit:topic:poll:vote" pk=poll.pk %}" method="post">
{% csrf_token %}
{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
{% include "spirit/_form.html" %}
<input class="button" type="submit" name="post" value="{% trans "Vote" %}" />
<a class="head-edit-link" href="{% url "spirit:poll-update" pk=poll.pk %}"><i class="fa fa-pencil"></i> {% trans "edit" %}</a>
<a class="head-edit-link js-post" href="{% url "spirit:poll-close" pk=poll.pk %}">
<a class="head-edit-link" href="{% url "spirit:topic:poll:update" pk=poll.pk %}"><i class="fa fa-pencil"></i> {% trans "edit" %}</a>
<a class="head-edit-link js-post" href="{% url "spirit:topic:poll:close" pk=poll.pk %}">
{% if poll.is_closed %}
<i class="fa fa-unlock"></i> {% trans "open" %}
{% else %}

View File

@ -1,6 +1,6 @@
{% load i18n %}
<form action="{% url "spirit:private-access-create" topic.pk %}" method="post">
<form action="{% url "spirit:topic:private:access-create" topic.pk %}" method="post">
{% csrf_token %}
{% include "spirit/_form.html" %}

View File

@ -10,13 +10,13 @@
<div class="tab-content js-tab-content js-categories-content">
<ul class="menu">
<li><a class="menu-link" href="{% url "spirit:private-created-list" %}" >{% trans "Left" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:private-list" %}" >{% trans "Participating in" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:private:index-author" %}" >{% trans "Left" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:private:index" %}" >{% trans "Participating in" %}</a></li>
</ul>
</div>
</div>
<div class="new-topic">
<a class="button" href="{% url "spirit:private-publish" %}">{% trans "Create private topic" %}</a>
<a class="button" href="{% url "spirit:topic:private:publish" %}">{% trans "Create private topic" %}</a>
</div>
</div>

View File

@ -7,7 +7,7 @@
{% block content %}
<ul class="nav">
<li><a href="{% url "spirit:private-list" %}" >{% trans "Private topics" %}</a></li>
<li><a href="{% url "spirit:topic:private:index" %}" >{% trans "Private topics" %}</a></li>
</ul>
<h1 class="headline">{{ topic.title }}</h1>
@ -19,7 +19,7 @@
<div class="tab-content js-tab-content js-participants-content">
<ul class="participants-menu">
{% for tp in topic.topics_private.all %}
<li class="menu-item"><span class="menu-username">{{ tp.user.username }}</span>{% ifequal user.pk topic.user.pk %}<a class="menu-icon" href="{% url "spirit:private-access-remove" tp.pk %}" ><i class="fa fa-times"></i></a>{% endifequal %}</li>
<li class="menu-item"><span class="menu-username">{{ tp.user.username }}</span>{% ifequal user.pk topic.user.pk %}<a class="menu-icon" href="{% url "spirit:topic:private:access-remove" tp.pk %}" ><i class="fa fa-times"></i></a>{% endifequal %}</li>
{% endfor %}
</ul>
@ -30,7 +30,7 @@
</div>
<div class="private-leave">
<a class="button" href="{% url "spirit:private-access-remove" topic_private.pk %}" ><i class="fa fa-times"></i>{% trans "Leave topic" %}</a>
<a class="button" href="{% url "spirit:topic:private:access-remove" topic_private.pk %}" ><i class="fa fa-times"></i>{% trans "Leave topic" %}</a>
</div>
</div>
@ -64,7 +64,7 @@
$( ".comment" ).bookmark( {
csrfToken: "{{ csrf_token }}",
target: "{% url "spirit:bookmark-create" topic.pk %}",
target: "{% url "spirit:comment:bookmark:create" topic.pk %}",
} );
});

View File

@ -12,7 +12,7 @@
{% for t in topics %}
<div class="row">
<a href="{% url "spirit:private-join" topic_id=t.pk %}">{{ t.title }}</a> <a class="row-edit js-post" href="{% url "spirit:private-join" topic_id=t.pk %}"><i class="fa fa-users"></i> {% trans "join" %}</a>
<a href="{% url "spirit:topic:private:join" topic_id=t.pk %}">{{ t.title }}</a> <a class="row-edit js-post" href="{% url "spirit:topic:private:join" topic_id=t.pk %}"><i class="fa fa-users"></i> {% trans "join" %}</a>
</div>
{% empty %}
<p>{% trans "There are no topics here, yet" %}</p>

View File

@ -28,22 +28,22 @@
{% ifequal user.username p_user.username %}
<div class="profile-preferences">
<a class="button" href="{% url "spirit:profile-update" %}"><i class="fa fa-cog"></i> {% trans "Preferences" %}</a>
<a class="button" href="{% url "spirit:user:update" %}"><i class="fa fa-cog"></i> {% trans "Preferences" %}</a>
</div>
{% else %}
<div class="private-message">
<a class="button" href="{% url "spirit:private-publish" user_id=p_user.pk %}"><i class="fa fa-envelope"></i> {% trans "Private Message" %}</a>
<a class="button" href="{% url "spirit:topic:private:publish" user_id=p_user.pk %}"><i class="fa fa-envelope"></i> {% trans "Private Message" %}</a>
</div>
{% endifequal %}
{% if user.st.is_administrator %}
<div class="profile-preferences">
<a class="button" href="{% url "spirit:admin-user-edit" user_id=p_user.pk %}"><i class="fa fa-cog"></i> {% trans "Edit user" %}</a>
<a class="button" href="{% url "spirit:admin:user:edit" user_id=p_user.pk %}"><i class="fa fa-cog"></i> {% trans "Edit user" %}</a>
</div>
{% endif %}
<ul class="tabs">
<li><a class="tab-link{% ifequal active_tab 0 %} is-selected{% endifequal %}" href="{% url "spirit:profile-detail" pk=p_user.pk slug=p_user.st.slug %}" >{% trans "Comments" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab 1 %} is-selected{% endifequal %}" href="{% url "spirit:profile-topics" pk=p_user.pk slug=p_user.st.slug %}" >{% trans "Topics" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab 2 %} is-selected{% endifequal %}" href="{% url "spirit:profile-likes" pk=p_user.pk slug=p_user.st.slug %}" >{% trans "Likes" %}</a></li>
<li><a class="tab-link{% ifequal active_tab 0 %} is-selected{% endifequal %}" href="{% url "spirit:user:detail" pk=p_user.pk slug=p_user.st.slug %}" >{% trans "Comments" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab 1 %} is-selected{% endifequal %}" href="{% url "spirit:user:topics" pk=p_user.pk slug=p_user.st.slug %}" >{% trans "Topics" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab 2 %} is-selected{% endifequal %}" href="{% url "spirit:user:likes" pk=p_user.pk slug=p_user.st.slug %}" >{% trans "Likes" %}</a></li>
</ul>

View File

@ -3,7 +3,7 @@
{% trans "Please go to the following link to activate your account:" %}
{{ protocol }}://{{ domain }}{% url 'spirit:registration-activation' pk=user_id token=token %}
{{ protocol }}://{{ domain }}{% url 'spirit:user:auth:registration-activation' pk=user_id token=token %}
{% trans "Thanks for using our site!" %}

View File

@ -6,7 +6,7 @@
{% for u in users %}
<div class="row">
<a href="{{ u.get_absolute_url }}">{{ u.username }}</a> <a class="row-edit" href="{% url "spirit:admin-user-edit" user_id=u.pk %}"><i class="fa fa-cog"></i> {% trans "edit" %}</a>
<a href="{{ u.get_absolute_url }}">{{ u.username }}</a> <a class="row-edit" href="{% url "spirit:admin:user:edit" user_id=u.pk %}"><i class="fa fa-cog"></i> {% trans "edit" %}</a>
</div>
{% endfor %}

View File

@ -1,8 +1,8 @@
{% load i18n %}
<ul class="tabs">
<li><a class="tab-link{% ifequal active_tab "list" %} is-selected{% endifequal %}" href="{% url "spirit:admin-user-list" %}" >{% trans "List" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "admins" %} is-selected{% endifequal %}" href="{% url "spirit:admin-user-admins" %}" >{% trans "Admins" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "mods" %} is-selected{% endifequal %}" href="{% url "spirit:admin-user-mods" %}" >{% trans "Mods" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "unactive" %} is-selected{% endifequal %}" href="{% url "spirit:admin-user-unactive" %}" >{% trans "Unactive" %}</a></li>
<li><a class="tab-link{% ifequal active_tab "list" %} is-selected{% endifequal %}" href="{% url "spirit:admin:user:index" %}" >{% trans "List" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "admins" %} is-selected{% endifequal %}" href="{% url "spirit:admin:user:index-admins" %}" >{% trans "Admins" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "mods" %} is-selected{% endifequal %}" href="{% url "spirit:admin:user:index-mods" %}" >{% trans "Mods" %}</a></li><!--
--><li><a class="tab-link{% ifequal active_tab "unactive" %} is-selected{% endifequal %}" href="{% url "spirit:admin:user:index-unactive" %}" >{% trans "Unactive" %}</a></li>
</ul>

View File

@ -18,9 +18,9 @@
</div>
<div class="login-links">
<a class="login-link" href="{% url "spirit:user-register" %}">{% trans "Create an account" %}</a>
<a class="login-link" href="{% url "spirit:password-reset" %}">{% trans "I don't know my password" %}</a>
<a class="login-link" href="{% url "spirit:resend-activation" %}">{% trans "Resend activation email" %}</a>
<a class="login-link" href="{% url "spirit:user:auth:register" %}">{% trans "Create an account" %}</a>
<a class="login-link" href="{% url "spirit:user:auth:password-reset" %}">{% trans "I don't know my password" %}</a>
<a class="login-link" href="{% url "spirit:user:auth:resend-activation" %}">{% trans "Resend activation email" %}</a>
</div>
{% endblock %}

View File

@ -10,6 +10,6 @@
<h1 class="headline">{% trans 'Password change successful' %}</h1>
<p><a href="{% url "spirit:user-login" %}">{% trans 'Continue to login' %}</a></p>
<p><a href="{% url "spirit:user:auth:login" %}">{% trans 'Continue to login' %}</a></p>
{% endblock %}

View File

@ -3,7 +3,7 @@
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'spirit:password-reset-confirm' uidb64=uid token=token %}
{{ protocol }}://{{ domain }}{% url 'spirit:user:auth:password-reset-confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Thanks for using our site!" %}

View File

@ -3,7 +3,7 @@
{% trans "Please go to the following link to confirm your email change:" %}
{{ protocol }}://{{ domain }}{% url 'spirit:email-change-confirm' token=token %}
{{ protocol }}://{{ domain }}{% url 'spirit:user:email-change-confirm' token=token %}
{% trans "Thanks for using our site!" %}

View File

@ -11,16 +11,16 @@
<h1 class="headline">{% trans "Menu" %}</h1>
<ul class="menu">
<li><a class="menu-link" href="{% url "spirit:profile-detail" pk=user.pk slug=user.st.slug %}">{% trans "Profile" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic-active" %}">{% trans "Topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic-unread-list" %}">{% trans "Unread topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:private-list" %}">{% trans "Private topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:user:detail" pk=user.pk slug=user.st.slug %}">{% trans "Profile" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:index-active" %}">{% trans "Topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:unread:index" %}">{% trans "Unread topics" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:topic:private:index" %}">{% trans "Private topics" %}</a></li>
{% if user.st.is_administrator %}
<li><a class="menu-link" href="{% url "spirit:admin" %}">{% trans "Admin" %}</a></li>
<li><a class="menu-link" href="{% url "spirit:admin:index" %}">{% trans "Admin" %}</a></li>
{% endif %}
<li><a class="menu-link js-post" href="{% url "spirit:user-logout" %}">{% trans "Log out" %}</a></li>
<li><a class="menu-link js-post" href="{% url "spirit:user:auth:logout" %}">{% trans "Log out" %}</a></li>
</ul>
{% endblock %}

View File

@ -3,7 +3,7 @@
{% trans "Please go to the following link to read the comment:" %}
{{ protocol }}://{{ domain }}{% url "spirit:bookmark-find" topic_id=comment.topic_id %}
{{ protocol }}://{{ domain }}{% url "spirit:comment:bookmark:find" topic_id=comment.topic_id %}
{% trans "If you don't want to keep receiving notifications, you can deactivate them on your profile preferences." %}

View File

@ -10,10 +10,10 @@
<dl class="preference">
<dt class="preference-label">{% trans "Email" %}:</dt>
<dd class="preference-desc"><a href="{% url "spirit:profile-email-change" %}"><i class="fa fa-pencil"></i> {{ user.email }}</a></dd>
<dd class="preference-desc"><a href="{% url "spirit:user:email-change" %}"><i class="fa fa-pencil"></i> {{ user.email }}</a></dd>
<dt class="preference-label">{% trans "Password" %}:</dt>
<dd class="preference-desc"><a href="{% url "spirit:profile-password-change" %}"><i class="fa fa-pencil"></i> {% trans "Change password" %}</a></dd>
<dd class="preference-desc"><a href="{% url "spirit:user:password-change" %}"><i class="fa fa-pencil"></i> {% trans "Change password" %}</a></dd>
<dt class="preference-label">{% trans "Avatar" %}:</dt>
<dd class="preference-desc"><a href="https://gravatar.com"><i class="fa fa-pencil"></i> {% trans "Change avatar" %}</a>

View File

@ -8,8 +8,8 @@ from . import views
urlpatterns = [
url(r'^$', views.deleted, name='admin-topic'),
url(r'^deleted/$', views.deleted, name='admin-topic-deleted'),
url(r'^closed/$', views.closed, name='admin-topic-closed'),
url(r'^pinned/$', views.pinned, name='admin-topic-pinned'),
url(r'^$', views.deleted, name='index'),
url(r'^deleted/$', views.deleted, name='deleted'),
url(r'^closed/$', views.closed, name='closed'),
url(r'^pinned/$', views.pinned, name='pinned'),
]

View File

@ -26,7 +26,7 @@ class FavoriteViewTest(TestCase):
"""
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:favorite-create', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:topic:favorite:create', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertRedirects(response, self.topic.get_absolute_url(), status_code=302)
self.assertEqual(len(TopicFavorite.objects.all()), 1)
@ -37,7 +37,7 @@ class FavoriteViewTest(TestCase):
"""
utils.login(self)
form_data = {'next': '/fakepath/', }
response = self.client.post(reverse('spirit:favorite-create', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:topic:favorite:create', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
@ -48,7 +48,7 @@ class FavoriteViewTest(TestCase):
TopicFavorite.objects.create(user=self.user, topic=self.topic)
utils.login(self)
form_data = {'next': '/fakepath/', }
response = self.client.post(reverse('spirit:favorite-create', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:topic:favorite:create', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
self.assertEqual(len(TopicFavorite.objects.all()), 1)
@ -60,7 +60,7 @@ class FavoriteViewTest(TestCase):
utils.login(self)
favorite = TopicFavorite.objects.create(user=self.user, topic=self.topic)
form_data = {}
response = self.client.post(reverse('spirit:favorite-delete', kwargs={'pk': favorite.pk, }),
response = self.client.post(reverse('spirit:topic:favorite:delete', kwargs={'pk': favorite.pk, }),
form_data)
self.assertRedirects(response, self.topic.get_absolute_url(), status_code=302)
self.assertEqual(len(TopicFavorite.objects.all()), 0)
@ -72,7 +72,7 @@ class FavoriteViewTest(TestCase):
utils.login(self)
favorite = TopicFavorite.objects.create(user=self.user, topic=self.topic)
form_data = {'next': '/fakepath/', }
response = self.client.post(reverse('spirit:favorite-delete', kwargs={'pk': favorite.pk, }),
response = self.client.post(reverse('spirit:topic:favorite:delete', kwargs={'pk': favorite.pk, }),
form_data)
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
self.assertEqual(len(TopicFavorite.objects.all()), 0)

View File

@ -8,6 +8,6 @@ from . import views
urlpatterns = [
url(r'^(?P<topic_id>\d+)/create/$', views.create, name='favorite-create'),
url(r'^(?P<pk>\d+)/delete/$', views.delete, name='favorite-delete'),
url(r'^(?P<topic_id>\d+)/create/$', views.create, name='create'),
url(r'^(?P<pk>\d+)/delete/$', views.delete, name='delete'),
]

View File

@ -44,9 +44,9 @@ class Topic(models.Model):
def get_absolute_url(self):
if self.category_id == settings.ST_TOPIC_PRIVATE_CATEGORY_PK:
return reverse('spirit:private-detail', kwargs={'topic_id': str(self.id), 'slug': self.slug})
return reverse('spirit:topic:private:detail', kwargs={'topic_id': str(self.id), 'slug': self.slug})
else:
return reverse('spirit:topic-detail', kwargs={'pk': str(self.id), 'slug': self.slug})
return reverse('spirit:topic:detail', kwargs={'pk': str(self.id), 'slug': self.slug})
@property
def main_category(self):

View File

@ -29,7 +29,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category)
form_data = {}
response = self.client.post(reverse('spirit:topic-delete', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:delete', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -46,7 +46,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category, is_removed=True)
form_data = {}
response = self.client.post(reverse('spirit:topic-undelete', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:undelete', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -67,7 +67,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category)
form_data = {}
response = self.client.post(reverse('spirit:topic-lock', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:lock', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -89,7 +89,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category, is_closed=True)
form_data = {}
response = self.client.post(reverse('spirit:topic-unlock', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:unlock', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -111,7 +111,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category)
form_data = {}
response = self.client.post(reverse('spirit:topic-pin', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:pin', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -133,7 +133,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category, is_pinned=True)
form_data = {}
response = self.client.post(reverse('spirit:topic-unpin', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:unpin', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -155,7 +155,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category)
form_data = {}
response = self.client.post(reverse('spirit:topic-global-pin', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:global-pin', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -177,7 +177,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category, is_globally_pinned=True)
form_data = {}
response = self.client.post(reverse('spirit:topic-global-unpin', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:moderate:global-unpin', kwargs={'pk': topic.pk, }),
form_data)
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)

View File

@ -8,15 +8,15 @@ from . import views
urlpatterns = [
url(r'^delete/(?P<pk>\d+)/$', views.DeleteView.as_view(), name='topic-delete'),
url(r'^undelete/(?P<pk>\d+)/$', views.UnDeleteView.as_view(), name='topic-undelete'),
url(r'^delete/(?P<pk>\d+)/$', views.DeleteView.as_view(), name='delete'),
url(r'^undelete/(?P<pk>\d+)/$', views.UnDeleteView.as_view(), name='undelete'),
url(r'^lock/(?P<pk>\d+)/$', views.LockView.as_view(), name='topic-lock'),
url(r'^unlock/(?P<pk>\d+)/$', views.UnLockView.as_view(), name='topic-unlock'),
url(r'^lock/(?P<pk>\d+)/$', views.LockView.as_view(), name='lock'),
url(r'^unlock/(?P<pk>\d+)/$', views.UnLockView.as_view(), name='unlock'),
url(r'^pin/(?P<pk>\d+)/$', views.PinView.as_view(), name='topic-pin'),
url(r'^unpin/(?P<pk>\d+)/$', views.UnPinView.as_view(), name='topic-unpin'),
url(r'^pin/(?P<pk>\d+)/$', views.PinView.as_view(), name='pin'),
url(r'^unpin/(?P<pk>\d+)/$', views.UnPinView.as_view(), name='unpin'),
url(r'^globallypin/(?P<pk>\d+)/$', views.GlobalPinView.as_view(), name='topic-global-pin'),
url(r'^ungloballypin/(?P<pk>\d+)/$', views.GlobalUnPinView.as_view(), name='topic-global-unpin'),
url(r'^global-pin/(?P<pk>\d+)/$', views.GlobalPinView.as_view(), name='global-pin'),
url(r'^global-unpin/(?P<pk>\d+)/$', views.GlobalUnPinView.as_view(), name='global-unpin'),
]

View File

@ -51,7 +51,7 @@ class TopicNotificationViewTest(TestCase):
topic notification list
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-list'))
response = self.client.get(reverse('spirit:topic:notification:index'))
self.assertQuerysetEqual(response.context['notifications'], map(repr, [self.topic_notification, ]))
@override_djconfig(topics_per_page=1)
@ -66,7 +66,7 @@ class TopicNotificationViewTest(TestCase):
action=COMMENT)
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-list'))
response = self.client.get(reverse('spirit:topic:notification:index'))
self.assertQuerysetEqual(response.context['notifications'], map(repr, [topic_notification2, ]))
def test_topic_notification_list_show_private_topic(self):
@ -80,15 +80,15 @@ class TopicNotificationViewTest(TestCase):
comment=self.comment, is_active=True, action=COMMENT)
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-list'))
response = self.client.get(reverse('spirit:topic:notification:index'))
self.assertQuerysetEqual(response.context['notifications'], map(repr, [topic_notif, ]))
# list unread should behave the same
response = self.client.get(reverse('spirit:topic-notification-list-unread'))
response = self.client.get(reverse('spirit:topic:notification:index-unread'))
self.assertQuerysetEqual(response.context['page'], map(repr, [topic_notif, ]))
# ajax list should behave the same
response = self.client.get(reverse('spirit:topic-notification-ajax'),
response = self.client.get(reverse('spirit:topic:notification:index-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
res = json.loads(response.content.decode('utf-8'))
self.assertEqual(len(res['n']), 1)
@ -121,15 +121,15 @@ class TopicNotificationViewTest(TestCase):
self.assertEqual(len(TopicNotification.objects.filter(user=self.user, is_active=True, is_read=False)), 5)
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-list'))
response = self.client.get(reverse('spirit:topic:notification:index'))
self.assertQuerysetEqual(response.context['notifications'], [])
# list unread should behave the same
response = self.client.get(reverse('spirit:topic-notification-list-unread'))
response = self.client.get(reverse('spirit:topic:notification:index-unread'))
self.assertQuerysetEqual(response.context['page'], [])
# ajax list should behave the same
response = self.client.get(reverse('spirit:topic-notification-ajax'),
response = self.client.get(reverse('spirit:topic:notification:index-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
res = json.loads(response.content.decode('utf-8'))
self.assertEqual(len(res['n']), 0)
@ -146,11 +146,11 @@ class TopicNotificationViewTest(TestCase):
action=COMMENT)
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-list-unread'))
response = self.client.get(reverse('spirit:topic:notification:index-unread'))
self.assertQuerysetEqual(response.context['page'], map(repr, [topic_notification, self.topic_notification]))
# fake next page
response = self.client.get(reverse('spirit:topic-notification-list-unread') + "?notif=" + str(topic_notification.pk))
response = self.client.get(reverse('spirit:topic:notification:index-unread') + "?notif=" + str(topic_notification.pk))
self.assertQuerysetEqual(response.context['page'], map(repr, [self.topic_notification, ]))
def test_topic_notification_ajax(self):
@ -158,7 +158,7 @@ class TopicNotificationViewTest(TestCase):
get notifications
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-ajax'),
response = self.client.get(reverse('spirit:topic:notification:index-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
res = json.loads(response.content.decode('utf-8'))
self.assertEqual(len(res['n']), 1)
@ -183,7 +183,7 @@ class TopicNotificationViewTest(TestCase):
is_active=True, action=COMMENT)
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-ajax'),
response = self.client.get(reverse('spirit:topic:notification:index-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
res = json.loads(response.content.decode('utf-8'))
self.assertGreater(TopicNotification.objects.filter(user=self.user).count(), 1)
@ -207,7 +207,7 @@ class TopicNotificationViewTest(TestCase):
TopicNotification.objects.filter(pk=self.topic_notification.pk).update(is_read=False, date=old_date)
utils.login(self)
response = self.client.get(reverse('spirit:topic-notification-ajax'),
response = self.client.get(reverse('spirit:topic:notification:index-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
res = json.loads(response.content.decode('utf-8'))
self.assertFalse(res['n'][0]['is_read'])
@ -229,7 +229,7 @@ class TopicNotificationViewTest(TestCase):
utils.login(self)
response = self.client.get(
reverse('spirit:topic-notification-ajax'),
reverse('spirit:topic:notification:index-ajax'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest'
)
res = json.loads(response.content.decode('utf-8'))
@ -250,7 +250,7 @@ class TopicNotificationViewTest(TestCase):
utils.login(self)
form_data = {'is_active': True, }
response = self.client.post(reverse('spirit:topic-notification-create', kwargs={'topic_id': self.topic.pk, }),
response = self.client.post(reverse('spirit:topic:notification:create', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertRedirects(response, self.topic.get_absolute_url(), status_code=302)
self.assertEqual(len(TopicNotification.objects.all()), 1)
@ -264,7 +264,7 @@ class TopicNotificationViewTest(TestCase):
utils.login(self)
form_data = {'is_active': True, }
response = self.client.post(reverse('spirit:topic-notification-create', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:notification:create', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertRedirects(response, private.topic.get_absolute_url(), status_code=302)
self.assertEqual(len(TopicNotification.objects.all()), 1)
@ -277,7 +277,7 @@ class TopicNotificationViewTest(TestCase):
utils.login(self)
form_data = {'is_active': True, }
response = self.client.post(reverse('spirit:topic-notification-create', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:notification:create', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -287,7 +287,7 @@ class TopicNotificationViewTest(TestCase):
"""
utils.login(self)
form_data = {'is_active': True, }
response = self.client.post(reverse('spirit:topic-notification-update',
response = self.client.post(reverse('spirit:topic:notification:update',
kwargs={'pk': self.topic_notification.pk, }),
form_data)
self.assertRedirects(response, self.topic.get_absolute_url(), status_code=302)
@ -303,7 +303,7 @@ class TopicNotificationViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:topic-notification-update', kwargs={'pk': notification.pk, }),
response = self.client.post(reverse('spirit:topic:notification:update', kwargs={'pk': notification.pk, }),
form_data)
self.assertEqual(response.status_code, 404)

View File

@ -8,9 +8,9 @@ from . import views
urlpatterns = [
url(r'^$', views.index_unread, name='topic-notification-list-unread'),
url(r'^list/$', views.index, name='topic-notification-list'),
url(r'^(?P<topic_id>\d+)/create/$', views.create, name='topic-notification-create'),
url(r'^(?P<pk>\d+)/update/$', views.update, name='topic-notification-update'),
url(r'^ajax/$', views.index_ajax, name='topic-notification-ajax'),
url(r'^$', views.index, name='index'),
url(r'^unread/$', views.index_unread, name='index-unread'),
url(r'^ajax/$', views.index_ajax, name='index-ajax'),
url(r'^(?P<topic_id>\d+)/create/$', views.create, name='create'),
url(r'^(?P<pk>\d+)/update/$', views.update, name='update'),
]

View File

@ -31,7 +31,7 @@ class TopicPollViewTest(TestCase):
"""
User must be logged in
"""
response = self.client.get(reverse('spirit:poll-update', kwargs={'pk': 1, }))
response = self.client.get(reverse('spirit:topic:poll:update', kwargs={'pk': 1, }))
self.assertEqual(response.status_code, 302)
def test_poll_update_wrong_user(self):
@ -40,7 +40,7 @@ class TopicPollViewTest(TestCase):
"""
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic2)
response = self.client.get(reverse('spirit:poll-update', kwargs={'pk': poll.pk, }))
response = self.client.get(reverse('spirit:topic:poll:update', kwargs={'pk': poll.pk, }))
self.assertEqual(response.status_code, 404)
def test_poll_update_get(self):
@ -49,7 +49,7 @@ class TopicPollViewTest(TestCase):
"""
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic)
response = self.client.get(reverse('spirit:poll-update', kwargs={'pk': poll.pk, }))
response = self.client.get(reverse('spirit:topic:poll:update', kwargs={'pk': poll.pk, }))
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.context['form'], TopicPollForm)
self.assertIsInstance(response.context['formset'], TopicPollChoiceFormSet)
@ -64,7 +64,7 @@ class TopicPollViewTest(TestCase):
'choices-0-description': 'op1', 'choices-0-poll': poll.pk,
'choices-1-description': 'op2', 'choices-1-poll': poll.pk,
'choice_limit': 2}
response = self.client.post(reverse('spirit:poll-update', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:update', kwargs={'pk': poll.pk, }),
form_data)
expected_url = poll.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -78,7 +78,7 @@ class TopicPollViewTest(TestCase):
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic)
form_data = {'choices-TOTAL_FORMS': 2, 'choices-INITIAL_FORMS': 0}
response = self.client.post(reverse('spirit:poll-update', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:update', kwargs={'pk': poll.pk, }),
form_data)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.context['form'], TopicPollForm)
@ -89,7 +89,7 @@ class TopicPollViewTest(TestCase):
User must be logged in
"""
poll = TopicPoll.objects.create(topic=self.topic)
response = self.client.get(reverse('spirit:poll-close', kwargs={'pk': poll.pk, }))
response = self.client.get(reverse('spirit:topic:poll:close', kwargs={'pk': poll.pk, }))
self.assertEqual(response.status_code, 302)
def test_poll_close_wrong_user(self):
@ -98,7 +98,7 @@ class TopicPollViewTest(TestCase):
"""
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic2)
response = self.client.get(reverse('spirit:poll-close', kwargs={'pk': poll.pk, }))
response = self.client.get(reverse('spirit:topic:poll:close', kwargs={'pk': poll.pk, }))
self.assertEqual(response.status_code, 404)
def test_poll_close_get(self):
@ -107,7 +107,7 @@ class TopicPollViewTest(TestCase):
"""
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic)
response = self.client.get(reverse('spirit:poll-close', kwargs={'pk': poll.pk, }))
response = self.client.get(reverse('spirit:topic:poll:close', kwargs={'pk': poll.pk, }))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['poll'].pk, poll.pk)
@ -118,14 +118,14 @@ class TopicPollViewTest(TestCase):
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic)
form_data = {}
response = self.client.post(reverse('spirit:poll-close', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:close', kwargs={'pk': poll.pk, }),
form_data)
expected_url = poll.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
self.assertTrue(TopicPoll.objects.get(pk=poll.pk).is_closed)
# Open
response = self.client.post(reverse('spirit:poll-close', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:close', kwargs={'pk': poll.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertFalse(TopicPoll.objects.get(pk=poll.pk).is_closed)
@ -136,9 +136,9 @@ class TopicPollViewTest(TestCase):
"""
poll = TopicPoll.objects.create(topic=self.topic)
form_data = {}
response = self.client.post(reverse('spirit:poll-vote', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:vote', kwargs={'pk': poll.pk, }),
form_data)
expected_url = reverse('spirit:user-login') + "?next=" + poll.get_absolute_url()
expected_url = reverse('spirit:user:auth:login') + "?next=" + poll.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
def test_poll_vote_get(self):
@ -148,7 +148,7 @@ class TopicPollViewTest(TestCase):
"""
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic)
response = self.client.get(reverse('spirit:poll-vote', kwargs={'pk': poll.pk, }))
response = self.client.get(reverse('spirit:topic:poll:vote', kwargs={'pk': poll.pk, }))
self.assertEqual(response.status_code, 405)
def test_poll_vote_post(self):
@ -159,7 +159,7 @@ class TopicPollViewTest(TestCase):
poll = TopicPoll.objects.create(topic=self.topic)
choice = TopicPollChoice.objects.create(poll=poll, description="op1")
form_data = {'choices': choice.pk, }
response = self.client.post(reverse('spirit:poll-vote', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:vote', kwargs={'pk': poll.pk, }),
form_data)
expected_url = poll.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -172,7 +172,7 @@ class TopicPollViewTest(TestCase):
utils.login(self)
poll = TopicPoll.objects.create(topic=self.topic)
form_data = {}
response = self.client.post(reverse('spirit:poll-vote', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:vote', kwargs={'pk': poll.pk, }),
form_data, follow=True)
expected_url = poll.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -196,7 +196,7 @@ class TopicPollViewTest(TestCase):
poll = TopicPoll.objects.create(topic=self.topic)
choice = TopicPollChoice.objects.create(poll=poll, description="op1")
form_data = {'choices': choice.pk, }
response = self.client.post(reverse('spirit:poll-vote', kwargs={'pk': poll.pk, }),
response = self.client.post(reverse('spirit:topic:poll:vote', kwargs={'pk': poll.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(repr(self._poll), repr(poll))

View File

@ -8,7 +8,7 @@ from . import views
urlpatterns = [
url(r'^update/(?P<pk>\d+)/$', views.update, name='poll-update'),
url(r'^close/(?P<pk>\d+)/$', views.close, name='poll-close'),
url(r'^vote/(?P<pk>\d+)/$', views.vote, name='poll-vote'),
url(r'^update/(?P<pk>\d+)/$', views.update, name='update'),
url(r'^close/(?P<pk>\d+)/$', views.close, name='close'),
url(r'^vote/(?P<pk>\d+)/$', views.vote, name='vote'),
]

View File

@ -39,13 +39,13 @@ class TopicPrivateViewTest(TestCase):
"""
utils.login(self)
form_data = {'comment': 'foo', 'title': 'foobar', 'users': self.user2.username}
response = self.client.post(reverse('spirit:private-publish'),
response = self.client.post(reverse('spirit:topic:private:publish'),
form_data)
private = TopicPrivate.objects.last()
expected_url = private.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:private-publish'))
response = self.client.get(reverse('spirit:topic:private:publish'))
self.assertEqual(response.status_code, 200)
def test_private_publish_comment_posted_signals(self):
@ -58,7 +58,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foo', 'title': 'foobar', 'users': self.user2.username}
response = self.client.post(reverse('spirit:private-publish'),
response = self.client.post(reverse('spirit:topic:private:publish'),
form_data)
self.assertEqual(response.status_code, 302)
comment = Comment.objects.last()
@ -78,7 +78,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
form_data = {'comment': 'foo', 'title': 'foobar', 'users': self.user.username}
response = self.client.post(reverse('spirit:private-publish'),
response = self.client.post(reverse('spirit:topic:private:publish'),
form_data)
self.assertEqual(response.status_code, 302)
topic_private = TopicPrivate.objects.last()
@ -92,7 +92,7 @@ class TopicPrivateViewTest(TestCase):
create private topic with user as initial value
"""
utils.login(self)
response = self.client.get(reverse('spirit:private-publish', kwargs={'user_id': self.user2.pk, }))
response = self.client.get(reverse('spirit:topic:private:publish', kwargs={'user_id': self.user2.pk, }))
self.assertEqual(response.context['tpform'].initial['users'], [self.user2.username, ])
def test_private_detail(self):
@ -109,7 +109,7 @@ class TopicPrivateViewTest(TestCase):
topic2 = utils.create_topic(category=category)
utils.create_comment(topic=topic2)
response = self.client.get(reverse('spirit:private-detail', kwargs={'topic_id': private.topic.pk,
response = self.client.get(reverse('spirit:topic:private:detail', kwargs={'topic_id': private.topic.pk,
'slug': private.topic.slug}))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['topic'], private.topic)
@ -127,7 +127,7 @@ class TopicPrivateViewTest(TestCase):
comment2 = utils.create_comment(topic=private.topic)
utils.create_comment(topic=private.topic) # comment3
response = self.client.get(reverse('spirit:private-detail', kwargs={'topic_id': private.topic.pk,
response = self.client.get(reverse('spirit:topic:private:detail', kwargs={'topic_id': private.topic.pk,
'slug': private.topic.slug}))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['topic'], private.topic)
@ -140,7 +140,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
private = utils.create_private_topic(user=self.user)
form_data = {'user': self.user2.username, }
response = self.client.post(reverse('spirit:private-access-create', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:access-create', kwargs={'topic_id': private.topic.pk, }),
form_data)
expected_url = private.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -155,7 +155,7 @@ class TopicPrivateViewTest(TestCase):
TopicPrivate.objects.create(user=self.user, topic=private.topic)
user = utils.create_user()
form_data = {'user': user.username, }
response = self.client.post(reverse('spirit:private-access-create', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:access-create', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -171,7 +171,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
private = utils.create_private_topic(user=self.user)
form_data = {'user': self.user2.username, }
response = self.client.post(reverse('spirit:private-access-create', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:access-create', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(self._topic, repr(private.topic))
@ -185,7 +185,7 @@ class TopicPrivateViewTest(TestCase):
private = utils.create_private_topic(user=self.user)
private2 = TopicPrivate.objects.create(user=self.user2, topic=private.topic)
form_data = {}
response = self.client.post(reverse('spirit:private-access-remove', kwargs={'pk': private2.pk, }),
response = self.client.post(reverse('spirit:topic:private:access-remove', kwargs={'pk': private2.pk, }),
form_data)
expected_url = private.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
@ -198,7 +198,7 @@ class TopicPrivateViewTest(TestCase):
private = utils.create_private_topic(user=self.user2)
TopicPrivate.objects.create(user=self.user, topic=private.topic)
form_data = {}
response = self.client.post(reverse('spirit:private-access-remove', kwargs={'pk': private.pk, }),
response = self.client.post(reverse('spirit:topic:private:access-remove', kwargs={'pk': private.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -210,9 +210,9 @@ class TopicPrivateViewTest(TestCase):
private = utils.create_private_topic(user=self.user2)
private2_leave = TopicPrivate.objects.create(user=self.user, topic=private.topic)
form_data = {}
response = self.client.post(reverse('spirit:private-access-remove', kwargs={'pk': private2_leave.pk, }),
response = self.client.post(reverse('spirit:topic:private:access-remove', kwargs={'pk': private2_leave.pk, }),
form_data)
expected_url = reverse("spirit:private-list")
expected_url = reverse("spirit:topic:private:index")
self.assertRedirects(response, expected_url, status_code=302)
def test_private_list(self):
@ -227,7 +227,7 @@ class TopicPrivateViewTest(TestCase):
utils.create_topic(category, user=self.user)
utils.login(self)
response = self.client.get(reverse('spirit:private-list'))
response = self.client.get(reverse('spirit:topic:private:index'))
self.assertQuerysetEqual(response.context['topics'], [repr(private.topic), ])
def test_private_list_order_topics(self):
@ -242,7 +242,7 @@ class TopicPrivateViewTest(TestCase):
Topic.objects.filter(pk=private_c.topic.pk).update(last_active=timezone.now() - datetime.timedelta(days=5))
utils.login(self)
response = self.client.get(reverse('spirit:private-list'))
response = self.client.get(reverse('spirit:topic:private:index'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [private_b.topic, private_c.topic,
private_a.topic]))
@ -254,7 +254,7 @@ class TopicPrivateViewTest(TestCase):
bookmark = CommentBookmark.objects.create(topic=private.topic, user=self.user)
utils.login(self)
response = self.client.get(reverse('spirit:private-list'))
response = self.client.get(reverse('spirit:topic:private:index'))
self.assertQuerysetEqual(response.context['topics'], [repr(private.topic), ])
self.assertEqual(response.context['topics'][0].bookmark, bookmark)
@ -267,7 +267,7 @@ class TopicPrivateViewTest(TestCase):
private = utils.create_private_topic(user=self.user)
utils.login(self)
response = self.client.get(reverse('spirit:private-list'))
response = self.client.get(reverse('spirit:topic:private:index'))
self.assertQuerysetEqual(response.context['topics'], [repr(private.topic), ])
def test_private_join(self):
@ -279,12 +279,12 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:private-join', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:join', kwargs={'topic_id': private.topic.pk, }),
form_data)
expected_url = private.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.get(reverse('spirit:private-join', kwargs={'topic_id': private.topic.pk, }))
response = self.client.get(reverse('spirit:topic:private:join', kwargs={'topic_id': private.topic.pk, }))
self.assertEqual(response.status_code, 200)
def test_private_join_invalid_regular_topic(self):
@ -296,7 +296,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:private-join', kwargs={'topic_id': topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:join', kwargs={'topic_id': topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -308,7 +308,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:private-join', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:join', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -326,7 +326,7 @@ class TopicPrivateViewTest(TestCase):
utils.login(self)
form_data = {}
response = self.client.post(reverse('spirit:private-join', kwargs={'topic_id': private.topic.pk, }),
response = self.client.post(reverse('spirit:topic:private:join', kwargs={'topic_id': private.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(self._topic, repr(private.topic))
@ -350,7 +350,7 @@ class TopicPrivateViewTest(TestCase):
TopicPrivate.objects.create(user=self.user, topic=private4.topic)
utils.login(self)
response = self.client.get(reverse('spirit:private-created-list'))
response = self.client.get(reverse('spirit:topic:private:index-author'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [private.topic, ]))
def test_private_created_list_order_topics(self):
@ -368,7 +368,7 @@ class TopicPrivateViewTest(TestCase):
Topic.objects.filter(pk=private_c.topic.pk).update(last_active=timezone.now() - datetime.timedelta(days=5))
utils.login(self)
response = self.client.get(reverse('spirit:private-created-list'))
response = self.client.get(reverse('spirit:topic:private:index-author'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [private_b.topic, private_c.topic,
private_a.topic]))
@ -383,7 +383,7 @@ class TopicPrivateViewTest(TestCase):
private2.delete()
utils.login(self)
response = self.client.get(reverse('spirit:private-created-list'))
response = self.client.get(reverse('spirit:topic:private:index-author'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [private2.topic, ]))

View File

@ -8,16 +8,16 @@ from . import views
urlpatterns = [
url(r'^$', views.index, name='private-list'),
url(r'^created/$', views.index_author, name='private-created-list'),
url(r'^$', views.index, name='index'),
url(r'^author/$', views.index_author, name='index-author'),
url(r'^publish/$', views.publish, name='private-publish'),
url(r'^publish/(?P<user_id>\d+)/$', views.publish, name='private-publish'),
url(r'^publish/$', views.publish, name='publish'),
url(r'^publish/(?P<user_id>\d+)/$', views.publish, name='publish'),
url(r'^(?P<topic_id>\d+)/$', views.detail, kwargs={'slug': "", }, name='private-detail'),
url(r'^(?P<topic_id>\d+)/(?P<slug>[\w-]+)/$', views.detail, name='private-detail'),
url(r'^(?P<topic_id>\d+)/$', views.detail, kwargs={'slug': "", }, name='detail'),
url(r'^(?P<topic_id>\d+)/(?P<slug>[\w-]+)/$', views.detail, name='detail'),
url(r'^invite/(?P<topic_id>\d+)/$', views.create_access, name='private-access-create'),
url(r'^remove/(?P<pk>\d+)/$', views.delete_access, name='private-access-remove'),
url(r'^join/(?P<topic_id>\d+)/$', views.join_in, name='private-join'),
url(r'^invite/(?P<topic_id>\d+)/$', views.create_access, name='access-create'),
url(r'^remove/(?P<pk>\d+)/$', views.delete_access, name='access-remove'),
url(r'^join/(?P<topic_id>\d+)/$', views.join_in, name='join'),
]

View File

@ -124,7 +124,7 @@ def delete_access(request, pk):
topic_private.delete()
if request.user.pk == topic_private.user_id:
return redirect(reverse("spirit:private-list"))
return redirect(reverse("spirit:topic:private:index"))
return redirect(request.POST.get('next', topic_private.get_absolute_url()))

View File

@ -37,7 +37,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
form_data = {'comment': 'foo', 'title': 'foobar', 'category': category.pk,
'choices-TOTAL_FORMS': 2, 'choices-INITIAL_FORMS': 0, 'choice_limit': 1}
response = self.client.post(reverse('spirit:topic-publish'),
response = self.client.post(reverse('spirit:topic:publish'),
form_data)
topic = Topic.objects.last()
expected_url = topic.get_absolute_url()
@ -47,12 +47,12 @@ class TopicViewTest(TestCase):
self.assertRaises(ObjectDoesNotExist, lambda: topic.poll)
# ratelimit
response = self.client.post(reverse('spirit:topic-publish'),
response = self.client.post(reverse('spirit:topic:publish'),
form_data)
self.assertEqual(response.status_code, 200)
# get
response = self.client.get(reverse('spirit:topic-publish'))
response = self.client.get(reverse('spirit:topic:publish'))
self.assertEqual(response.status_code, 200)
def test_topic_publish_long_title(self):
@ -64,7 +64,7 @@ class TopicViewTest(TestCase):
title = "a" * 255
form_data = {'comment': 'foo', 'title': title, 'category': category.pk,
'choices-TOTAL_FORMS': 2, 'choices-INITIAL_FORMS': 0, 'choice_limit': 1}
response = self.client.post(reverse('spirit:topic-publish'),
response = self.client.post(reverse('spirit:topic:publish'),
form_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(len(Topic.objects.all()), 1)
@ -78,14 +78,14 @@ class TopicViewTest(TestCase):
category = utils.create_category()
form_data = {'comment': 'foo', 'title': 'foobar', 'category': category.pk,
'choices-TOTAL_FORMS': 2, 'choices-INITIAL_FORMS': 0, 'choice_limit': 1}
response = self.client.post(reverse('spirit:topic-publish', kwargs={'category_id': category.pk, }),
response = self.client.post(reverse('spirit:topic:publish', kwargs={'category_id': category.pk, }),
form_data)
topic = Topic.objects.last()
expected_url = topic.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
# ratelimit
response = self.client.post(reverse('spirit:topic-publish', kwargs={'category_id': category.pk, }),
response = self.client.post(reverse('spirit:topic:publish', kwargs={'category_id': category.pk, }),
form_data)
self.assertEqual(response.status_code, 200)
@ -98,7 +98,7 @@ class TopicViewTest(TestCase):
subcategory = utils.create_subcategory(category)
form_data = {'comment': 'foo', 'title': 'foobar', 'category': subcategory.pk,
'choices-TOTAL_FORMS': 2, 'choices-INITIAL_FORMS': 0, 'choice_limit': 1}
response = self.client.post(reverse('spirit:topic-publish', kwargs={'category_id': subcategory.pk, }),
response = self.client.post(reverse('spirit:topic:publish', kwargs={'category_id': subcategory.pk, }),
form_data)
topic = Topic.objects.last()
expected_url = topic.get_absolute_url()
@ -109,7 +109,7 @@ class TopicViewTest(TestCase):
invalid topic category
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-publish', kwargs={'category_id': str(99), }))
response = self.client.get(reverse('spirit:topic:publish', kwargs={'category_id': str(99), }))
self.assertEqual(response.status_code, 404)
def test_topic_publish_comment_posted_signals(self):
@ -125,7 +125,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
form_data = {'title': 'foobar', 'category': category.pk, 'comment': 'foo',
'choices-TOTAL_FORMS': 2, 'choices-INITIAL_FORMS': 0, 'choice_limit': 1}
response = self.client.post(reverse('spirit:topic-publish'),
response = self.client.post(reverse('spirit:topic:publish'),
form_data)
self.assertEqual(response.status_code, 302)
comment = Comment.objects.last()
@ -142,7 +142,7 @@ class TopicViewTest(TestCase):
'choices-0-description': 'op1', 'choices-0-poll': "",
'choices-1-description': 'op2', 'choices-1-poll': "",
'choice_limit': 2}
response = self.client.post(reverse('spirit:topic-publish'),
response = self.client.post(reverse('spirit:topic:publish'),
form_data)
self.assertEqual(response.status_code, 302)
topic = Topic.objects.last()
@ -150,7 +150,7 @@ class TopicViewTest(TestCase):
self.assertEqual(len(topic.poll.choices.all()), 2)
# get
response = self.client.get(reverse('spirit:topic-publish'))
response = self.client.get(reverse('spirit:topic:publish'))
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.context['pform'], TopicPollForm)
self.assertIsInstance(response.context['pformset'], TopicPollChoiceFormSet)
@ -163,7 +163,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category=category, user=self.user)
form_data = {'title': 'foobar', }
response = self.client.post(reverse('spirit:topic-update', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:update', kwargs={'pk': topic.pk, }),
form_data)
self.assertRedirects(response, topic.get_absolute_url(), status_code=302)
@ -183,7 +183,7 @@ class TopicViewTest(TestCase):
topic = utils.create_topic(category=category, user=self.user)
category2 = utils.create_category()
form_data = {'title': 'foobar', 'category': category2.pk}
self.client.post(reverse('spirit:topic-update', kwargs={'pk': topic.pk, }),
self.client.post(reverse('spirit:topic:update', kwargs={'pk': topic.pk, }),
form_data)
self.assertSequenceEqual(self._moderate, [repr(self.user), repr(Topic.objects.get(pk=topic.pk)), MOVED])
@ -195,7 +195,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category=category)
form_data = {'title': 'foobar', }
response = self.client.post(reverse('spirit:topic-update', kwargs={'pk': topic.pk, }),
response = self.client.post(reverse('spirit:topic:update', kwargs={'pk': topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
@ -213,7 +213,7 @@ class TopicViewTest(TestCase):
comment2 = utils.create_comment(topic=topic)
utils.create_comment(topic=topic2)
response = self.client.get(reverse('spirit:topic-detail', kwargs={'pk': topic.pk, 'slug': topic.slug}))
response = self.client.get(reverse('spirit:topic:detail', kwargs={'pk': topic.pk, 'slug': topic.slug}))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['topic'], topic)
self.assertQuerysetEqual(response.context['comments'], map(repr, [comment1, comment2]))
@ -232,7 +232,7 @@ class TopicViewTest(TestCase):
comment2 = utils.create_comment(topic=topic)
utils.create_comment(topic=topic) # comment3
response = self.client.get(reverse('spirit:topic-detail', kwargs={'pk': topic.pk, 'slug': topic.slug}))
response = self.client.get(reverse('spirit:topic:detail', kwargs={'pk': topic.pk, 'slug': topic.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['comments'], map(repr, [comment1, comment2]))
@ -248,7 +248,7 @@ class TopicViewTest(TestCase):
category = utils.create_category()
topic = utils.create_topic(category=category, user=self.user)
response = self.client.get(reverse('spirit:topic-detail', kwargs={'pk': topic.pk, 'slug': topic.slug}))
response = self.client.get(reverse('spirit:topic:detail', kwargs={'pk': topic.pk, 'slug': topic.slug}))
self.assertEqual(response.status_code, 200)
self.assertSequenceEqual(self._viewed, [response.context['request'], repr(topic)])
@ -259,7 +259,7 @@ class TopicViewTest(TestCase):
utils.login(self)
category = utils.create_category()
topic = utils.create_topic(category=category)
response = self.client.get(reverse('spirit:topic-detail', kwargs={'pk': topic.pk,
response = self.client.get(reverse('spirit:topic:detail', kwargs={'pk': topic.pk,
'slug': 'bar'}))
self.assertRedirects(response, topic.get_absolute_url(), status_code=301)
@ -270,7 +270,7 @@ class TopicViewTest(TestCase):
utils.login(self)
category = utils.create_category()
topic = utils.create_topic(category=category)
response = self.client.get(reverse('spirit:topic-detail', kwargs={'pk': topic.pk,
response = self.client.get(reverse('spirit:topic:detail', kwargs={'pk': topic.pk,
'slug': ''}))
self.assertRedirects(response, topic.get_absolute_url(), status_code=301)
@ -286,7 +286,7 @@ class TopicViewTest(TestCase):
Topic.objects.filter(pk=topic_a.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
Topic.objects.filter(pk=topic_c.pk).update(last_active=timezone.now() - datetime.timedelta(days=5))
response = self.client.get(reverse('spirit:topic-active'))
response = self.client.get(reverse('spirit:topic:index-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_b, topic_c, topic_a]))
def test_topic_active_view_pinned(self):
@ -301,7 +301,7 @@ class TopicViewTest(TestCase):
# show globally pinned first
Topic.objects.filter(pk=topic_d.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
response = self.client.get(reverse('spirit:topic-active'))
response = self.client.get(reverse('spirit:topic:index-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_d, topic_c, topic_b, topic_a]))
def test_topic_active_view_dont_show_private_or_removed(self):
@ -318,7 +318,7 @@ class TopicViewTest(TestCase):
utils.create_topic(category=subcategory)
utils.create_topic(category=subcategory_removed)
response = self.client.get(reverse('spirit:topic-active'))
response = self.client.get(reverse('spirit:topic:index-active'))
self.assertQuerysetEqual(response.context['topics'], [])
def test_topic_active_view_bookmark(self):
@ -338,7 +338,7 @@ class TopicViewTest(TestCase):
ten_days_ago = timezone.now() - datetime.timedelta(days=10)
Topic.objects.filter(pk=topic2.pk).update(last_active=ten_days_ago)
response = self.client.get(reverse('spirit:topic-active'))
response = self.client.get(reverse('spirit:topic:index-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic, topic2]))
self.assertEqual(response.context['topics'][0].bookmark, bookmark)
@ -351,7 +351,7 @@ class TopicViewTest(TestCase):
topic_a = utils.create_topic(category=category)
topic_b = utils.create_topic(category=category, user=self.user, view_count=10)
response = self.client.get(reverse('spirit:topic-active'))
response = self.client.get(reverse('spirit:topic:index-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_b, ]))

View File

@ -38,11 +38,11 @@ class TopicUnreadViewTest(TestCase):
.update(is_read=False)
utils.login(self)
response = self.client.get(reverse('spirit:topic-unread-list'))
response = self.client.get(reverse('spirit:topic:unread:index'))
self.assertQuerysetEqual(response.context['page'], map(repr, [self.topic2, self.topic]))
# fake next page
response = self.client.get(reverse('spirit:topic-unread-list') + "?topic_id=" + str(self.topic2.pk))
response = self.client.get(reverse('spirit:topic:unread:index') + "?topic_id=" + str(self.topic2.pk))
self.assertQuerysetEqual(response.context['page'], map(repr, [self.topic, ]))
def test_topic_unread_list_show_private_topic(self):
@ -55,7 +55,7 @@ class TopicUnreadViewTest(TestCase):
TopicUnread.objects.create(user=self.user, topic=topic_a.topic, is_read=False)
utils.login(self)
response = self.client.get(reverse('spirit:topic-unread-list'))
response = self.client.get(reverse('spirit:topic:unread:index'))
self.assertQuerysetEqual(response.context['page'], map(repr, [topic_a.topic, ]))
def test_topic_unread_list_dont_show_removed_or_no_access(self):
@ -80,7 +80,7 @@ class TopicUnreadViewTest(TestCase):
TopicUnread.objects.create(user=self.user, topic=topic_e, is_read=False)
utils.login(self)
response = self.client.get(reverse('spirit:topic-unread-list'))
response = self.client.get(reverse('spirit:topic:unread:index'))
self.assertQuerysetEqual(response.context['page'], [])
def test_topic_unread_list_invalid_topic_id(self):
@ -89,7 +89,7 @@ class TopicUnreadViewTest(TestCase):
"""
utils.login(self)
last_pk = TopicUnread.objects.order_by("pk").last().pk
response = self.client.get(reverse('spirit:topic-unread-list') + "?topic_id=" + str(last_pk + 1))
response = self.client.get(reverse('spirit:topic:unread:index') + "?topic_id=" + str(last_pk + 1))
self.assertEqual(response.status_code, 404)
def test_topic_unread_list_empty_first_page(self):
@ -97,7 +97,7 @@ class TopicUnreadViewTest(TestCase):
empty first page
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-unread-list'))
response = self.client.get(reverse('spirit:topic:unread:index'))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['page'], [])
@ -106,7 +106,7 @@ class TopicUnreadViewTest(TestCase):
empty page, other than the first one
"""
utils.login(self)
response = self.client.get(reverse('spirit:topic-unread-list') + "?topic_id=" + str(self.topic.pk))
response = self.client.get(reverse('spirit:topic:unread:index') + "?topic_id=" + str(self.topic.pk))
self.assertEqual(response.status_code, 404)
def test_topic_unread_list_bookmarks(self):
@ -119,7 +119,7 @@ class TopicUnreadViewTest(TestCase):
bookmark = CommentBookmark.objects.create(topic=self.topic2, user=self.user)
utils.login(self)
response = self.client.get(reverse('spirit:topic-unread-list'))
response = self.client.get(reverse('spirit:topic:unread:index'))
self.assertQuerysetEqual(response.context['page'], map(repr, [self.topic2, self.topic]))
self.assertEqual(response.context['page'][0].bookmark, bookmark)

View File

@ -8,5 +8,5 @@ from . import views
urlpatterns = [
url(r'^$', views.index, name='topic-unread-list'),
url(r'^$', views.index, name='index'),
]

View File

@ -2,19 +2,32 @@
from __future__ import unicode_literals
from django.conf.urls import url
from django.conf.urls import url, include
import spirit.topic.moderate.urls
import spirit.topic.unread.urls
import spirit.topic.notification.urls
import spirit.topic.favorite.urls
import spirit.topic.private.urls
import spirit.topic.poll.urls
from . import views
urlpatterns = [
url(r'^publish/$', views.publish, name='topic-publish'),
url(r'^publish/(?P<category_id>\d+)/$', views.publish, name='topic-publish'),
url(r'^publish/$', views.publish, name='publish'),
url(r'^publish/(?P<category_id>\d+)/$', views.publish, name='publish'),
url(r'^update/(?P<pk>\d+)/$', views.update, name='topic-update'),
url(r'^update/(?P<pk>\d+)/$', views.update, name='update'),
url(r'^(?P<pk>\d+)/$', views.detail, kwargs={'slug': "", }, name='topic-detail'),
url(r'^(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.detail, name='topic-detail'),
url(r'^(?P<pk>\d+)/$', views.detail, kwargs={'slug': "", }, name='detail'),
url(r'^(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.detail, name='detail'),
url(r'^active/$', views.index_active, name='topic-active'),
url(r'^active/$', views.index_active, name='index-active'),
url(r'^moderate/', include(spirit.topic.moderate.urls, namespace='moderate')),
url(r'^unread/', include(spirit.topic.unread.urls, namespace='unread')),
url(r'^notification/', include(spirit.topic.notification.urls, namespace='notification')),
url(r'^favorite/', include(spirit.topic.favorite.urls, namespace='favorite')),
url(r'^private/', include(spirit.topic.private.urls, namespace='private')),
url(r'^poll/', include(spirit.topic.poll.urls, namespace='poll')),
]

View File

@ -23,29 +23,17 @@ import spirit.comment.history.urls
import spirit.comment.like.urls
pattern_list = [
patterns = [
url(r'^$', spirit.topic.views.index_active, name='index'),
url(r'^st/admin/', include(spirit.admin.urls)),
url(r'^user/', include(spirit.user.urls)),
url(r'^search/', include(spirit.search.urls)),
url(r'^category/', include(spirit.category.urls)),
url(r'^topic/', include(spirit.topic.urls)),
url(r'^topic/moderate/', include(spirit.topic.moderate.urls)),
url(r'^topic/unread/', include(spirit.topic.unread.urls)),
url(r'^topic/notification/', include(spirit.topic.notification.urls)),
url(r'^topic/favorite/', include(spirit.topic.favorite.urls)),
url(r'^topic/private/', include(spirit.topic.private.urls)),
url(r'^topic/poll/', include(spirit.topic.poll.urls)),
url(r'^comment/', include(spirit.comment.urls)),
url(r'^comment/bookmark/', include(spirit.comment.bookmark.urls)),
url(r'^comment/flag/', include(spirit.comment.flag.urls)),
url(r'^comment/history/', include(spirit.comment.history.urls)),
url(r'^comment/like/', include(spirit.comment.like.urls)),
url(r'^st/admin/', include(spirit.admin.urls, namespace='admin')),
url(r'^user/', include(spirit.user.urls, namespace='user')),
url(r'^search/', include(spirit.search.urls, namespace='search')),
url(r'^category/', include(spirit.category.urls, namespace='category')),
url(r'^topic/', include(spirit.topic.urls, namespace='topic')),
url(r'^comment/', include(spirit.comment.urls, namespace='comment')),
]
urlpatterns = [
url(r'^', include(pattern_list, namespace="spirit", app_name="spirit")),
url(r'^', include(patterns, namespace='spirit', app_name='spirit')),
]

View File

@ -8,10 +8,9 @@ from . import views
urlpatterns = [
url(r'^$', views.index, name='admin-user'),
url(r'^edit/(?P<user_id>\d+)/$', views.edit, name='admin-user-edit'),
url(r'^list/$', views.index, name='admin-user-list'),
url(r'^admins/$', views.admins, name='admin-user-admins'),
url(r'^mods/$', views.mods, name='admin-user-mods'),
url(r'^unactive/$', views.unactive, name='admin-user-unactive'),
url(r'^$', views.index, name='index'),
url(r'^admins/$', views.index_admins, name='index-admins'),
url(r'^mods/$', views.index_mods, name='index-mods'),
url(r'^unactive/$', views.index_unactive, name='index-unactive'),
url(r'^edit/(?P<user_id>\d+)/$', views.edit, name='edit'),
]

View File

@ -60,7 +60,7 @@ def index(request):
)
def admins(request):
def index_admins(request):
return _index(
request,
queryset=User.objects.filter(st__is_administrator=True),
@ -68,7 +68,7 @@ def admins(request):
)
def mods(request):
def index_mods(request):
return _index(
request,
queryset=User.objects.filter(st__is_moderator=True, st__is_administrator=False),
@ -76,7 +76,7 @@ def mods(request):
)
def unactive(request):
def index_unactive(request):
return _index(
request,
queryset=User.objects.filter(is_active=False),

View File

@ -10,31 +10,29 @@ from . import views
urlpatterns = [
url(r'^login/$', views.custom_login, {'template_name': 'spirit/user/auth/login.html'}, name='user-login'),
url(r'^logout/$', views.custom_logout, {'next_page': '/', }, name='user-logout'),
url(r'^login/$', views.custom_login, {'template_name': 'spirit/user/auth/login.html'}, name='login'),
url(r'^logout/$', views.custom_logout, {'next_page': '/', }, name='logout'),
url(r'^register/$', views.register, name='user-register'),
url(r'^register/$', views.register, name='register'),
url(r'^resend-activation/$', views.resend_activation_email, name='resend-activation'),
url(r'^activation/(?P<pk>\d+)/(?P<token>[0-9A-Za-z_\-\.]+)/$', views.registration_activation,
name='registration-activation'),
url(r'^password-reset/$', views.custom_reset_password,
{'template_name': 'spirit/user/auth/password_reset_form.html',
'email_template_name': 'spirit/user/auth/password_reset_email.html',
'subject_template_name': 'spirit/user/auth/password_reset_subject.txt',
'post_reset_redirect': reverse_lazy('spirit:password-reset-done')},
name='password-reset'),
url(r'^password-reset/$', views.custom_password_reset,
{
'template_name': 'spirit/user/auth/password_reset_form.html',
'email_template_name': 'spirit/user/auth/password_reset_email.html',
'subject_template_name': 'spirit/user/auth/password_reset_subject.txt',
'post_reset_redirect': reverse_lazy('spirit:user:auth:password-reset-done')
}, name='password-reset'),
url(r'^password-reset/done/$', django_views.password_reset_done,
{'template_name': 'spirit/user/auth/password_reset_done.html', },
name='password-reset-done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[\w\-]+)/$', django_views.password_reset_confirm,
{'template_name': 'spirit/user/auth/password_reset_confirm.html',
'post_reset_redirect': reverse_lazy('spirit:password-reset-complete')},
name='password-reset-confirm'),
{
'template_name': 'spirit/user/auth/password_reset_confirm.html',
'post_reset_redirect': reverse_lazy('spirit:user:auth:password-reset-complete')
}, name='password-reset-confirm'),
url(r'^reset/done/$', django_views.password_reset_complete,
{'template_name': 'spirit/user/auth/password_reset_complete.html', },
name='password-reset-complete'),

View File

@ -34,7 +34,7 @@ def custom_login(request, **kwargs):
def custom_logout(request, **kwargs):
# Currently, Django 1.6 uses GET to log out
if not request.user.is_authenticated():
return redirect(request.GET.get('next', reverse('spirit:user-login')))
return redirect(request.GET.get('next', reverse('spirit:user:auth:login')))
if request.method == 'POST':
return logout(request, **kwargs)
@ -43,9 +43,9 @@ def custom_logout(request, **kwargs):
@ratelimit(field='email', rate='5/5m')
def custom_reset_password(request, **kwargs):
def custom_password_reset(request, **kwargs):
if request.method == "POST" and request.is_limited:
return redirect(reverse("spirit:password-reset"))
return redirect(reverse("spirit:user:auth:password-reset"))
return password_reset(request, **kwargs)
@ -54,7 +54,7 @@ def custom_reset_password(request, **kwargs):
# TODO: @guest_only
def register(request):
if request.user.is_authenticated():
return redirect(request.GET.get('next', reverse('spirit:profile-update')))
return redirect(request.GET.get('next', reverse('spirit:user:update')))
if request.method == 'POST':
form = RegistrationForm(data=request.POST)
@ -67,9 +67,9 @@ def register(request):
# TODO: email-less activation
# if not settings.REGISTER_EMAIL_ACTIVATION_REQUIRED:
# login(request, user)
# return redirect(request.GET.get('next', reverse('spirit:profile-update')))
# return redirect(request.GET.get('next', reverse('spirit:user:update')))
return redirect(reverse('spirit:user-login'))
return redirect(reverse('spirit:user:auth:login'))
else:
form = RegistrationForm()
@ -88,14 +88,14 @@ def registration_activation(request, pk, token):
user.save()
messages.info(request, _("Your account has been activated!"))
return redirect(reverse('spirit:user-login'))
return redirect(reverse('spirit:user:auth:login'))
@ratelimit(field='email', rate='5/5m')
# TODO: @guest_only
def resend_activation_email(request):
if request.user.is_authenticated():
return redirect(request.GET.get('next', reverse('spirit:profile-update')))
return redirect(request.GET.get('next', reverse('spirit:user:update')))
if request.method == 'POST':
form = ResendActivationForm(data=request.POST)
@ -107,7 +107,7 @@ def resend_activation_email(request):
# TODO: show if is_valid only
messages.info(request, _("If you don't receive an email, please make sure you've entered "
"the address you registered with, and check your spam folder."))
return redirect(reverse('spirit:user-login'))
return redirect(reverse('spirit:user:auth:login'))
else:
form = ResendActivationForm()

View File

@ -49,7 +49,7 @@ class UserProfile(models.Model):
super(UserProfile, self).save(*args, **kwargs)
def get_absolute_url(self):
return reverse('spirit:profile-detail', kwargs={'pk': self.pk,
return reverse('spirit:user:detail', kwargs={'pk': self.pk,
'slug': self.slug})
@ -112,7 +112,7 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin, AbstractForumUser):
abstract = True
def get_absolute_url(self):
return reverse('spirit:profile-detail', kwargs={'pk': self.pk,
return reverse('spirit:user:detail', kwargs={'pk': self.pk,
'slug': self.slug})
def get_full_name(self):

View File

@ -46,20 +46,20 @@ class UserViewTest(TestCase):
pk = self.user.pk
slug = self.user.st.slug
response = self.client.get(reverse('spirit:profile-topics', kwargs={'pk': pk, 'slug': slug}))
response = self.client.get(reverse('spirit:user:topics', kwargs={'pk': pk, 'slug': slug}))
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('spirit:profile-detail', kwargs={'pk': pk, 'slug': slug}))
response = self.client.get(reverse('spirit:user:detail', kwargs={'pk': pk, 'slug': slug}))
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('spirit:profile-likes', kwargs={'pk': pk, 'slug': slug}))
response = self.client.get(reverse('spirit:user:likes', kwargs={'pk': pk, 'slug': slug}))
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('spirit:profile-update'))
response = self.client.get(reverse('spirit:user:update'))
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('spirit:profile-password-change'))
response = self.client.get(reverse('spirit:user:password-change'))
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('spirit:profile-email-change'))
response = self.client.get(reverse('spirit:user:email-change'))
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('spirit:email-change-confirm', kwargs={'token': "foo"}))
response = self.client.get(reverse('spirit:user:email-change-confirm', kwargs={'token': "foo"}))
self.assertEqual(response.status_code, 302)
def test_login_email(self):
@ -67,14 +67,14 @@ class UserViewTest(TestCase):
try to login by email
"""
# get
response = self.client.get(reverse('spirit:user-login'))
response = self.client.get(reverse('spirit:user:auth:login'))
self.assertEqual(response.status_code, 200)
# post
form_data = {'username': self.user.email, 'password': "bar"}
response = self.client.post(reverse('spirit:user-login'),
response = self.client.post(reverse('spirit:user:auth:login'),
form_data)
expected_url = reverse('spirit:profile-update')
expected_url = reverse('spirit:user:update')
self.assertRedirects(response, expected_url, status_code=302)
def test_login_redirect(self):
@ -82,11 +82,11 @@ class UserViewTest(TestCase):
try to login with a logged in user
"""
utils.login(self)
response = self.client.get(reverse('spirit:user-login'))
response = self.client.get(reverse('spirit:user:auth:login'))
expected_url = self.user.st.get_absolute_url()
self.assertRedirects(response, expected_url, status_code=302)
# next
response = self.client.get(reverse('spirit:user-login') + '?next=/fakepath/')
response = self.client.get(reverse('spirit:user:auth:login') + '?next=/fakepath/')
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
def test_register(self):
@ -94,27 +94,27 @@ class UserViewTest(TestCase):
register
"""
# get
response = self.client.get(reverse('spirit:user-register'))
response = self.client.get(reverse('spirit:user:auth:register'))
self.assertEqual(response.status_code, 200)
# post
form_data = {'username': 'uniquefoo', 'email': 'some@some.com', 'password1': 'pass', 'password2': 'pass'}
response = self.client.post(reverse('spirit:user-register'),
response = self.client.post(reverse('spirit:user:auth:register'),
form_data)
expected_url = reverse('spirit:user-login')
expected_url = reverse('spirit:user:auth:login')
self.assertRedirects(response, expected_url, status_code=302)
# redirect logged in user
utils.login(self)
response = self.client.get(reverse('spirit:user-register'))
self.assertRedirects(response, reverse('spirit:profile-update'), status_code=302)
response = self.client.get(reverse('spirit:user:auth:register'))
self.assertRedirects(response, reverse('spirit:user:update'), status_code=302)
def test_register_email_sent(self):
"""
register and send activation email
"""
form_data = {'username': 'uniquefoo', 'email': 'some@some.com', 'password1': 'pass', 'password2': 'pass'}
response = self.client.post(reverse('spirit:user-register'), form_data)
response = self.client.post(reverse('spirit:user:auth:register'), form_data)
self.assertEqual(response.status_code, 302)
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].subject, _("User activation"))
@ -125,7 +125,7 @@ class UserViewTest(TestCase):
"""
# redirect logged in user
utils.login(self)
response = self.client.get(reverse('spirit:user-register') + "?next=/fakepath/")
response = self.client.get(reverse('spirit:user:auth:register') + "?next=/fakepath/")
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
def test_profile_topics(self):
@ -133,7 +133,7 @@ class UserViewTest(TestCase):
profile user's topics
"""
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:topics", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['topics'], [repr(self.topic), ])
@ -154,7 +154,7 @@ class UserViewTest(TestCase):
Topic.objects.filter(pk=topic_c.pk).update(date=timezone.now() - datetime.timedelta(days=5))
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:topics", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_b, topic_c, topic_a]))
@ -165,7 +165,7 @@ class UserViewTest(TestCase):
bookmark = CommentBookmark.objects.create(topic=self.topic, user=self.user)
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics",
response = self.client.get(reverse("spirit:user:topics",
kwargs={'pk': self.user2.pk, 'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['topics'], [repr(self.topic), ])
@ -179,7 +179,7 @@ class UserViewTest(TestCase):
topic = utils.create_topic(self.category, user=self.user2)
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:topics", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['topics'], [repr(topic), ])
@ -201,7 +201,7 @@ class UserViewTest(TestCase):
utils.create_topic(category=subcategory_removed, user=self.user2)
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:topics", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertQuerysetEqual(response.context['topics'], [])
@ -210,9 +210,9 @@ class UserViewTest(TestCase):
profile user's topics
"""
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:topics", kwargs={'pk': self.user2.pk,
'slug': "invalid"}))
expected_url = reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
expected_url = reverse("spirit:user:topics", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug})
self.assertRedirects(response, expected_url, status_code=301)
@ -223,7 +223,7 @@ class UserViewTest(TestCase):
utils.login(self)
comment = utils.create_comment(user=self.user2, topic=self.topic)
utils.create_comment(user=self.user, topic=self.topic)
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:detail", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['comments'], [repr(comment), ])
@ -241,7 +241,7 @@ class UserViewTest(TestCase):
Comment.objects.filter(pk=comment_c.pk).update(date=timezone.now() - datetime.timedelta(days=5))
utils.login(self)
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:detail", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertQuerysetEqual(response.context['comments'], map(repr, [comment_b, comment_c, comment_a]))
@ -254,7 +254,7 @@ class UserViewTest(TestCase):
comment = utils.create_comment(user=self.user2, topic=self.topic)
utils.login(self)
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:detail", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['comments'], [repr(comment), ])
@ -279,7 +279,7 @@ class UserViewTest(TestCase):
utils.create_comment(user=self.user2, topic=topic_e)
utils.login(self)
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:detail", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertQuerysetEqual(response.context['comments'], [])
@ -288,9 +288,9 @@ class UserViewTest(TestCase):
profile user's comments, invalid user slug
"""
utils.login(self)
response = self.client.get(reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:detail", kwargs={'pk': self.user2.pk,
'slug': "invalid"}))
expected_url = reverse("spirit:profile-detail", kwargs={'pk': self.user2.pk,
expected_url = reverse("spirit:user:detail", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug})
self.assertRedirects(response, expected_url, status_code=301)
@ -303,7 +303,7 @@ class UserViewTest(TestCase):
comment2 = utils.create_comment(user=self.user2, topic=self.topic)
like = CommentLike.objects.create(user=self.user2, comment=comment)
CommentLike.objects.create(user=self.user, comment=comment2)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['comments'], [repr(like.comment), ])
@ -324,7 +324,7 @@ class UserViewTest(TestCase):
CommentLike.objects.filter(pk=like_c.pk).update(date=timezone.now() - datetime.timedelta(days=5))
utils.login(self)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertQuerysetEqual(response.context['comments'], map(repr, [comment_b, comment_c, comment_a]))
@ -353,7 +353,7 @@ class UserViewTest(TestCase):
CommentLike.objects.create(user=self.user2, comment=comment_e)
utils.login(self)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertQuerysetEqual(response.context['comments'], [])
@ -362,9 +362,9 @@ class UserViewTest(TestCase):
profile user's likes, invalid user slug
"""
utils.login(self)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:likes", kwargs={'pk': self.user2.pk,
'slug': "invalid"}))
expected_url = reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
expected_url = reverse("spirit:user:likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug})
self.assertRedirects(response, expected_url, status_code=301)
@ -379,7 +379,7 @@ class UserViewTest(TestCase):
like = CommentLike.objects.create(user=self.user2, comment=comment2)
utils.login(self)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
response = self.client.get(reverse("spirit:user:likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.st.slug}))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['comments'], [repr(like.comment), ])
@ -390,15 +390,15 @@ class UserViewTest(TestCase):
"""
utils.login(self)
# get
response = self.client.get(reverse('spirit:profile-update'))
response = self.client.get(reverse('spirit:user:update'))
self.assertEqual(response.status_code, 200)
# post
form_data = {'first_name': 'foo', 'last_name': 'bar',
'location': 'spirit', 'timezone': self.user.st.timezone}
response = self.client.post(reverse('spirit:profile-update'),
response = self.client.post(reverse('spirit:user:update'),
form_data)
expected_url = reverse('spirit:profile-update')
expected_url = reverse('spirit:user:update')
self.assertRedirects(response, expected_url, status_code=302)
def test_login_rate_limit(self):
@ -408,11 +408,11 @@ class UserViewTest(TestCase):
form_data = {'username': self.user.email, 'password': "badpassword"}
for attempt in range(5):
url = reverse('spirit:user-login')
url = reverse('spirit:user:auth:login')
response = self.client.post(url, form_data)
self.assertTemplateUsed(response, 'spirit/user/auth/login.html')
url = reverse('spirit:user-login') + "?next=/path/"
url = reverse('spirit:user:auth:login') + "?next=/path/"
response = self.client.post(url, form_data)
self.assertRedirects(response, url, status_code=302)
@ -423,19 +423,19 @@ class UserViewTest(TestCase):
form_data = {'email': "bademail@bad.com", }
for attempt in range(5):
response = self.client.post(reverse('spirit:password-reset'), form_data)
expected_url = reverse("spirit:password-reset-done")
response = self.client.post(reverse('spirit:user:auth:password-reset'), form_data)
expected_url = reverse("spirit:user:auth:password-reset-done")
self.assertRedirects(response, expected_url, status_code=302)
response = self.client.post(reverse('spirit:password-reset'), form_data)
expected_url = reverse("spirit:password-reset")
response = self.client.post(reverse('spirit:user:auth:password-reset'), form_data)
expected_url = reverse("spirit:user:auth:password-reset")
self.assertRedirects(response, expected_url, status_code=302)
def test_password_reset_confirm(self):
"""
test access
"""
response = self.client.get(reverse('spirit:password-reset-confirm', kwargs={'uidb64': 'f-a-k-e',
response = self.client.get(reverse('spirit:user:auth:password-reset-confirm', kwargs={'uidb64': 'f-a-k-e',
'token': 'f-a-k-e'}))
self.assertEqual(response.status_code, 200)
@ -453,7 +453,7 @@ class UserViewTest(TestCase):
return
response = self.client.get(url)
expected_url = reverse("spirit:user-login") + "?next=" + reverse('admin:login')
expected_url = reverse("spirit:user:auth:login") + "?next=" + reverse('admin:login')
self.assertRedirects(response, expected_url, status_code=302)
def test_profile_password_change(self):
@ -465,14 +465,14 @@ class UserViewTest(TestCase):
form_data = {'old_password': 'foo',
'new_password1': 'bar',
'new_password2': 'bar'}
response = self.client.post(reverse('spirit:profile-password-change'),
response = self.client.post(reverse('spirit:user:password-change'),
form_data)
expected_url = reverse("spirit:profile-update")
expected_url = reverse("spirit:user:update")
self.assertRedirects(response, expected_url, status_code=302)
utils.login(self, user=user, password="bar")
# get
response = self.client.get(reverse('spirit:profile-password-change'))
response = self.client.get(reverse('spirit:user:password-change'))
self.assertEqual(response.status_code, 200)
def test_profile_password_change_re_login(self):
@ -486,8 +486,8 @@ class UserViewTest(TestCase):
form_data = {'old_password': 'foo',
'new_password1': 'bar',
'new_password2': 'bar'}
response = self.client.post(reverse('spirit:profile-password-change'), form_data)
expected_url = reverse("spirit:profile-update")
response = self.client.post(reverse('spirit:user:password-change'), form_data)
expected_url = reverse("spirit:user:update")
self.assertRedirects(response, expected_url, status_code=302)
self.assertNotEqual(old_hash, self.client.session[HASH_SESSION_KEY])
@ -500,9 +500,9 @@ class UserViewTest(TestCase):
self.user.is_active = False
self.user.save()
token = UserActivationTokenGenerator().generate(self.user)
response = self.client.get(reverse('spirit:registration-activation', kwargs={'pk': self.user.pk,
response = self.client.get(reverse('spirit:user:auth:registration-activation', kwargs={'pk': self.user.pk,
'token': token}))
expected_url = reverse("spirit:user-login")
expected_url = reverse("spirit:user:auth:login")
self.assertRedirects(response, expected_url, status_code=302)
self.assertTrue(User.objects.get(pk=self.user.pk).is_active)
@ -517,9 +517,9 @@ class UserViewTest(TestCase):
utils.login(self)
User.objects.filter(pk=self.user.pk).update(is_active=False)
UserProfile.objects.filter(user__pk=self.user.pk).update(is_verified=True)
response = self.client.get(reverse('spirit:registration-activation', kwargs={'pk': self.user.pk,
response = self.client.get(reverse('spirit:user:auth:registration-activation', kwargs={'pk': self.user.pk,
'token': token}))
expected_url = reverse("spirit:user-login")
expected_url = reverse("spirit:user:auth:login")
self.assertRedirects(response, expected_url, status_code=302)
self.assertFalse(User.objects.get(pk=self.user.pk).is_active)
@ -530,8 +530,8 @@ class UserViewTest(TestCase):
utils.login(self)
new_email = "newfoo@bar.com"
token = UserEmailChangeTokenGenerator().generate(self.user, new_email)
response = self.client.get(reverse('spirit:email-change-confirm', kwargs={'token': token}))
expected_url = reverse("spirit:profile-update")
response = self.client.get(reverse('spirit:user:email-change-confirm', kwargs={'token': token}))
expected_url = reverse("spirit:user:update")
self.assertRedirects(response, expected_url, status_code=302)
self.assertEqual(User.objects.get(pk=self.user.pk).email, new_email)
@ -544,8 +544,8 @@ class UserViewTest(TestCase):
token = UserEmailChangeTokenGenerator().generate(self.user, old_email)
new_email = "newfoo@bar.com"
User.objects.filter(pk=self.user.pk).update(email=new_email)
response = self.client.get(reverse('spirit:email-change-confirm', kwargs={'token': token}))
expected_url = reverse("spirit:profile-update")
response = self.client.get(reverse('spirit:user:email-change-confirm', kwargs={'token': token}))
expected_url = reverse("spirit:user:update")
self.assertRedirects(response, expected_url, status_code=302)
self.assertEqual(User.objects.get(pk=self.user.pk).email, new_email)
@ -558,7 +558,7 @@ class UserViewTest(TestCase):
new_email = "duplicated@bar.com"
old_email = self.user.email
token = UserEmailChangeTokenGenerator().generate(self.user, new_email)
self.client.get(reverse('spirit:email-change-confirm', kwargs={'token': token}))
self.client.get(reverse('spirit:user:email-change-confirm', kwargs={'token': token}))
self.assertEqual(User.objects.get(pk=self.user.pk).email, old_email)
@override_settings(ST_UNIQUE_EMAILS=False)
@ -570,7 +570,7 @@ class UserViewTest(TestCase):
utils.create_user(email="duplicated@bar.com")
new_email = "duplicated@bar.com"
token = UserEmailChangeTokenGenerator().generate(self.user, new_email)
self.client.get(reverse('spirit:email-change-confirm', kwargs={'token': token}))
self.client.get(reverse('spirit:user:email-change-confirm', kwargs={'token': token}))
self.assertEqual(User.objects.get(pk=self.user.pk).email, new_email)
def test_profile_email_change(self):
@ -581,15 +581,15 @@ class UserViewTest(TestCase):
utils.login(self, user=user, password="foo")
form_data = {'password': 'foo',
'email': 'newfoo@bar.com'}
response = self.client.post(reverse('spirit:profile-email-change'),
response = self.client.post(reverse('spirit:user:email-change'),
form_data)
expected_url = reverse("spirit:profile-update")
expected_url = reverse("spirit:user:update")
self.assertRedirects(response, expected_url, status_code=302)
self.assertEquals(len(mail.outbox), 1)
self.assertIn(_("Email change"), mail.outbox[0].subject)
# get
response = self.client.get(reverse('spirit:profile-email-change'))
response = self.client.get(reverse('spirit:user:email-change'))
self.assertEqual(response.status_code, 200)
def test_resend_activation_email(self):
@ -600,15 +600,15 @@ class UserViewTest(TestCase):
form_data = {'email': user.email,
'password': "foo"}
response = self.client.post(reverse('spirit:resend-activation'),
response = self.client.post(reverse('spirit:user:auth:resend-activation'),
form_data)
expected_url = reverse("spirit:user-login")
expected_url = reverse("spirit:user:auth:login")
self.assertRedirects(response, expected_url, status_code=302)
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].subject, _("User activation"))
# get
response = self.client.get(reverse('spirit:resend-activation'))
response = self.client.get(reverse('spirit:user:auth:resend-activation'))
self.assertEquals(response.status_code, 200)
def test_resend_activation_email_invalid_previously_logged_in(self):
@ -621,7 +621,7 @@ class UserViewTest(TestCase):
form_data = {'email': user.email,
'password': "foo"}
response = self.client.post(reverse('spirit:resend-activation'),
response = self.client.post(reverse('spirit:user:auth:resend-activation'),
form_data)
self.assertEquals(response.status_code, 302)
self.assertEquals(len(mail.outbox), 0)
@ -633,7 +633,7 @@ class UserViewTest(TestCase):
utils.create_user(password="foo")
form_data = {'email': "bad@foo.com", }
response = self.client.post(reverse('spirit:resend-activation'),
response = self.client.post(reverse('spirit:user:auth:resend-activation'),
form_data)
self.assertEquals(response.status_code, 302)
self.assertEquals(len(mail.outbox), 0)
@ -643,8 +643,8 @@ class UserViewTest(TestCase):
resend_activation_email redirect to profile if user is logged in
"""
utils.login(self)
response = self.client.get(reverse('spirit:resend-activation'))
expected_url = reverse("spirit:profile-update")
response = self.client.get(reverse('spirit:user:auth:resend-activation'))
expected_url = reverse("spirit:user:update")
self.assertRedirects(response, expected_url, status_code=302)
def test_logout(self):
@ -654,12 +654,12 @@ class UserViewTest(TestCase):
utils.login(self)
# get should display confirmation message
response = self.client.get(reverse('spirit:user-logout'))
response = self.client.get(reverse('spirit:user:auth:logout'))
self.assertEqual(response.status_code, 200)
self.assertTrue(self.client.session.items())
# post should log out the user (clear the session)
response = self.client.post(reverse('spirit:user-logout'))
response = self.client.post(reverse('spirit:user:auth:logout'))
expected_url = "/"
self.assertRedirects(response, expected_url, status_code=302)
self.assertFalse(self.client.session.items())
@ -667,7 +667,7 @@ class UserViewTest(TestCase):
# next
utils.login(self)
self.assertTrue(self.client.session.items())
response = self.client.post(reverse('spirit:user-logout') + '?next=/fakepath/')
response = self.client.post(reverse('spirit:user:auth:logout') + '?next=/fakepath/')
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)
self.assertFalse(self.client.session.items())
@ -676,12 +676,12 @@ class UserViewTest(TestCase):
should log out on POST only
"""
# redirect to login if user is anonymous
response = self.client.get(reverse('spirit:user-logout'))
expected_url = reverse("spirit:user-login")
response = self.client.get(reverse('spirit:user:auth:logout'))
expected_url = reverse("spirit:user:auth:login")
self.assertRedirects(response, expected_url, status_code=302)
# next if user is anonymous
response = self.client.get(reverse('spirit:user-logout') + '?next=/fakepath/')
response = self.client.get(reverse('spirit:user:auth:logout') + '?next=/fakepath/')
self.assertRedirects(response, '/fakepath/', status_code=302, target_status_code=404)

View File

@ -9,23 +9,21 @@ from . import views
urlpatterns = [
url(r'^$', views.update, name='profile-update'),
url(r'^password-change/$', views.password_change, name='profile-password-change'),
url(r'^email-change/$', views.email_change, name='profile-email-change'),
url(r'^$', views.update, name='update'),
url(r'^password-change/$', views.password_change, name='password-change'),
url(r'^email-change/$', views.email_change, name='email-change'),
url(r'^email-change/(?P<token>[0-9A-Za-z_\-\.]+)/$', views.email_change_confirm, name='email-change-confirm'),
url(r'^(?P<pk>\d+)/$', views.comments, kwargs={'slug': "", }, name='profile-detail'),
url(r'^(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.comments, name='profile-detail'),
url(r'^(?P<pk>\d+)/$', views.comments, kwargs={'slug': "", }, name='detail'),
url(r'^(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.comments, name='detail'),
url(r'^topics/(?P<pk>\d+)/$', views.topics, kwargs={'slug': "", }, name='profile-topics'),
url(r'^topics/(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.topics, name='profile-topics'),
url(r'^topics/(?P<pk>\d+)/$', views.topics, kwargs={'slug': "", }, name='topics'),
url(r'^topics/(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.topics, name='topics'),
url(r'^likes/(?P<pk>\d+)/$', views.likes, kwargs={'slug': "", }, name='profile-likes'),
url(r'^likes/(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.likes, name='profile-likes'),
url(r'^likes/(?P<pk>\d+)/$', views.likes, kwargs={'slug': "", }, name='likes'),
url(r'^likes/(?P<pk>\d+)/(?P<slug>[\w-]+)/$', views.likes, name='likes'),
url(r'^menu/$', views.menu, name='user-menu'),
]
url(r'^menu/$', views.menu, name='menu'),
urlpatterns += [
url(r'^', include(auth_urls)),
url(r'^', include(auth_urls, namespace='auth')),
]

View File

@ -33,7 +33,7 @@ def update(request):
uform.save()
form.save()
messages.info(request, _("Your profile has been updated!"))
return redirect(reverse('spirit:profile-update'))
return redirect(reverse('spirit:user:update'))
else:
uform = UserForm(instance=request.user)
form = UserProfileForm(instance=request.user.st)
@ -55,7 +55,7 @@ def password_change(request):
form.save()
update_session_auth_hash(request, form.user)
messages.info(request, _("Your password has been changed!"))
return redirect(reverse('spirit:profile-update'))
return redirect(reverse('spirit:user:update'))
else:
form = PasswordChangeForm(user=request.user)
@ -72,7 +72,7 @@ def email_change(request):
if form.is_valid():
send_email_change_email(request, request.user, form.get_email())
messages.info(request, _("We have sent you an email so you can confirm the change!"))
return redirect(reverse('spirit:profile-update'))
return redirect(reverse('spirit:user:update'))
else:
form = EmailChangeForm()
@ -94,10 +94,10 @@ def email_change_confirm(request, token):
user.email = form.get_email()
user.save()
messages.info(request, _("Your email has been changed!"))
return redirect(reverse('spirit:profile-update'))
return redirect(reverse('spirit:user:update'))
messages.error(request, _("Sorry, we were not able to change your email."))
return redirect(reverse('spirit:profile-update'))
return redirect(reverse('spirit:user:update'))
@login_required
@ -134,7 +134,7 @@ def topics(request, pk, slug):
request, pk, slug,
queryset=user_topics,
template='spirit/user/profile_topics.html',
reverse_to='spirit:profile-topics',
reverse_to='spirit:user:topics',
context_name='topics',
per_page=config.topics_per_page
)
@ -149,7 +149,7 @@ def comments(request, pk, slug):
request, pk, slug,
queryset=user_comments,
template='spirit/user/profile_comments.html',
reverse_to='spirit:profile-detail',
reverse_to='spirit:user:detail',
context_name='comments',
per_page=config.comments_per_page,
)
@ -165,7 +165,7 @@ def likes(request, pk, slug):
request, pk, slug,
queryset=user_comments,
template='spirit/user/profile_likes.html',
reverse_to='spirit:profile-likes',
reverse_to='spirit:user:likes',
context_name='comments',
per_page=config.comments_per_page,
)