Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'custom-user'

  • Loading branch information...
commit 8a29cccd5a1c8719c22130e66c67c62f02567e98 2 parents 66ef684 + f795daa
@Fantomas42 authored
View
3  zinnia/flags.py
@@ -1,5 +1,5 @@
"""Comment flags for Zinnia"""
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
from django.utils.functional import memoize
from zinnia.settings import COMMENT_FLAG_USER_ID
@@ -11,6 +11,7 @@
def _get_user_flagger():
+ User = get_user_model()
try:
user = User.objects.get(pk=COMMENT_FLAG_USER_ID)
except User.DoesNotExist:
View
2  zinnia/management/commands/wp2zinnia.py
@@ -138,7 +138,7 @@ def import_authors(self, tree):
def migrate_author(self, author_name):
"""Handle actions for migrating the authors"""
- action_text = "The author '%s' needs to be migrated to an User:\n"\
+ action_text = "The author '%s' needs to be migrated to an user:\n"\
"1. Use an existing user ?\n"\
"2. Create a new user ?\n"\
"Please select a choice: " % self.style.ITEM(author_name)
View
13 zinnia/models/author.py
@@ -1,18 +1,17 @@
"""Author model for Zinnia"""
from django.db import models
-from django.contrib.auth.models import User
-from django.contrib.auth.models import UserManager
+from django.contrib.auth import get_user_model
from zinnia.managers import entries_published
from zinnia.managers import EntryRelatedPublishedManager
-class Author(User):
+class Author(get_user_model()):
"""
- Proxy model around :class:`django.contrib.auth.models.User`.
+ Proxy model around :class:`django.contrib.auth.models.get_user_model`.
"""
- objects = UserManager()
+ objects = get_user_model()._default_manager
published = EntryRelatedPublishedManager()
def entries_published(self):
@@ -26,13 +25,13 @@ def get_absolute_url(self):
"""
Builds and returns the author's URL based on his username.
"""
- return ('zinnia_author_detail', (self.username,))
+ return ('zinnia_author_detail', [self.get_username()])
def __unicode__(self):
"""
If the user has a full name, use it instead of the username.
"""
- return self.get_full_name() or self.username
+ return self.get_full_name() or self.get_username()
class Meta:
"""
View
11 zinnia/tests/admin.py
@@ -1,12 +1,14 @@
"""Test cases for Zinnia's admin"""
from django.test import TestCase
-from django.contrib.auth.models import User
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia import settings
from zinnia.models.entry import Entry
+from zinnia.models.author import Author
from zinnia.models.category import Category
+@skipIfCustomUser
class EntryAdminTestCase(TestCase):
"""Test case for Entry Admin"""
urls = 'zinnia.tests.urls'
@@ -14,7 +16,8 @@ class EntryAdminTestCase(TestCase):
def setUp(self):
self.original_wysiwyg = settings.WYSIWYG
settings.WYSIWYG = None
- User.objects.create_superuser('admin', 'admin@example.com', 'password')
+ Author.objects.create_superuser(
+ 'admin', 'admin@example.com', 'password')
category_1 = Category.objects.create(title='Category 1', slug='cat-1')
Category.objects.create(title='Category 2', slug='cat-2',
parent=category_1)
@@ -52,12 +55,14 @@ def test_entry_add_and_change(self):
self.assertEquals(Entry.objects.count(), 1)
+@skipIfCustomUser
class CategoryAdminTestCase(TestCase):
"""Test cases for Category Admin"""
urls = 'zinnia.tests.urls'
def setUp(self):
- User.objects.create_superuser('admin', 'admin@example.com', 'password')
+ Author.objects.create_superuser(
+ 'admin', 'admin@example.com', 'password')
self.client.login(username='admin', password='password')
def test_category_add_and_change(self):
View
2  zinnia/tests/admin_filters.py
@@ -7,6 +7,7 @@
from django.utils.translation import activate
from django.utils.translation import deactivate
from django.contrib.admin.views.main import ChangeList
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
@@ -24,6 +25,7 @@ class MiniEntryCategoryAdmin(ModelAdmin):
list_filter = [CategoryListFilter]
+@skipIfCustomUser
class AuthorListFilterTestCase(TestCase):
"""Test case for AuthorListFilter"""
urls = 'zinnia.tests.urls'
View
2  zinnia/tests/author.py
@@ -1,12 +1,14 @@
"""Test cases for Zinnia's Author"""
from django.test import TestCase
from django.contrib.sites.models import Site
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
from zinnia.managers import PUBLISHED
+@skipIfCustomUser
class AuthorTestCase(TestCase):
def setUp(self):
View
8 zinnia/tests/entry.py
@@ -5,15 +5,16 @@
from django.test import TestCase
from django.utils import timezone
from django.contrib import comments
-from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.utils.translation import activate
from django.utils.translation import deactivate
from django.contrib.comments.models import CommentFlag
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models import entry
from zinnia.models.entry import Entry
+from zinnia.models.author import Author
from zinnia.managers import PUBLISHED
from zinnia.flags import PINGBACK, TRACKBACK
from zinnia.models.entry import get_entry_base_model
@@ -30,6 +31,7 @@ def setUp(self):
'slug': 'my-entry'}
self.entry = Entry.objects.create(**params)
+ @skipIfCustomUser
def test_discussions(self):
site = Site.objects.get_current()
self.assertEquals(self.entry.discussions.count(), 0)
@@ -53,8 +55,8 @@ def test_discussions(self):
self.assertEquals(self.entry.pingbacks.count(), 0)
self.assertEquals(self.entry.trackbacks.count(), 0)
- author = User.objects.create_user(username='webmaster',
- email='webmaster@example.com')
+ author = Author.objects.create_user(username='webmaster',
+ email='webmaster@example.com')
comment = comments.get_model().objects.create(
comment='My Comment 3',
View
2  zinnia/tests/feeds.py
@@ -10,6 +10,7 @@
from django.utils.feedgenerator import DefaultFeed
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth.tests.utils import skipIfCustomUser
from tagging.models import Tag
@@ -34,6 +35,7 @@
from zinnia.feeds import LatestDiscussions
+@skipIfCustomUser
class ZinniaFeedsTestCase(TestCase):
"""Test cases for the Feed classes provided"""
urls = 'zinnia.tests.urls'
View
2  zinnia/tests/flags.py
@@ -1,11 +1,13 @@
"""Test cases for Zinnia's flags"""
from django.test import TestCase
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia import flags
from zinnia.flags import get_user_flagger
from zinnia.flags import _get_user_flagger
+@skipIfCustomUser
class FlagsTestCase(TestCase):
"""Test cases for zinnia.flags"""
View
2  zinnia/tests/long_enough.py
@@ -2,6 +2,7 @@
from django.test import TestCase
from django.contrib import comments
from django.contrib.sites.models import Site
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
@@ -9,6 +10,7 @@
from zinnia.spam_checker.backends.long_enough import backend
+@skipIfCustomUser
class LongEnoughTestCase(TestCase):
"""Test cases for zinnia.spam_checker.long_enough"""
View
2  zinnia/tests/managers.py
@@ -1,6 +1,7 @@
"""Test cases for Zinnia's managers"""
from django.test import TestCase
from django.contrib.sites.models import Site
+from django.contrib.auth.tests.utils import skipIfCustomUser
from tagging.models import Tag
@@ -13,6 +14,7 @@
from zinnia.managers import entries_published
+@skipIfCustomUser
class ManagersTestCase(TestCase):
def setUp(self):
View
2  zinnia/tests/metaweblog.py
@@ -7,6 +7,7 @@
from django.test import TestCase
from django.contrib.sites.models import Site
from django.core.files.storage import default_storage
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
@@ -20,6 +21,7 @@
from zinnia.tests.utils import TestTransport
+@skipIfCustomUser
class MetaWeblogTestCase(TestCase):
"""Test cases for MetaWeblog"""
urls = 'zinnia.tests.urls'
View
2  zinnia/tests/mixins.py
@@ -4,6 +4,7 @@
from django.test import TestCase
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
@@ -286,6 +287,7 @@ def test_prefetch_related_mixin(self):
self.assertRaises(ImproperlyConfigured,
instance.get_queryset)
+ @skipIfCustomUser
def test_prefetch_categories_authors_mixin(self):
author = Author.objects.create_user(username='author',
email='author@example.com')
View
2  zinnia/tests/moderator.py
@@ -6,6 +6,7 @@
from django.core.urlresolvers import reverse
from django.contrib.comments.forms import CommentForm
from django.contrib.comments.moderation import moderator as moderator_stack
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
@@ -15,6 +16,7 @@
from zinnia.signals import disconnect_discussion_signals
+@skipIfCustomUser
class EntryCommentModeratorTestCase(TestCase):
"""Test cases for the moderator"""
View
2  zinnia/tests/pingback.py
@@ -10,6 +10,7 @@
from django.test.utils import restore_template_loaders
from django.test.utils import setup_test_template_loader
from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth.tests.utils import skipIfCustomUser
from BeautifulSoup import BeautifulSoup
@@ -26,6 +27,7 @@
from zinnia.signals import disconnect_discussion_signals
+@skipIfCustomUser
class PingBackTestCase(TestCase):
"""Test cases for pingbacks"""
urls = 'zinnia.tests.urls'
View
10 zinnia/tests/quick_entry.py
@@ -1,15 +1,17 @@
# coding=utf-8
"""Test cases for Zinnia's quick entry"""
from django.test import TestCase
-from django.contrib.auth.models import User
from django.test.utils import restore_template_loaders
from django.test.utils import setup_test_template_loader
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia import settings
from zinnia.models.entry import Entry
+from zinnia.models.author import Author
from zinnia.managers import DRAFT
+@skipIfCustomUser
class QuickEntryTestCase(TestCase):
"""Test cases for quick_entry view"""
urls = 'zinnia.tests.urls'
@@ -22,8 +24,10 @@ def setUp(self):
self.original_wysiwyg = settings.WYSIWYG
settings.WYSIWYG = None
- User.objects.create_user('user', 'user@example.com', 'password')
- User.objects.create_superuser('admin', 'admin@example.com', 'password')
+ Author.objects.create_user(
+ 'user', 'user@example.com', 'password')
+ Author.objects.create_superuser(
+ 'admin', 'admin@example.com', 'password')
def tearDown(self):
settings.WYSIWYG = self.original_wysiwyg
View
2  zinnia/tests/sitemaps.py
@@ -1,6 +1,7 @@
"""Test cases for Zinnia's sitemaps"""
from django.test import TestCase
from django.contrib.sites.models import Site
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.managers import PUBLISHED
from zinnia.models.entry import Entry
@@ -12,6 +13,7 @@
from zinnia.sitemaps import TagSitemap
+@skipIfCustomUser
class ZinniaSitemapsTestCase(TestCase):
"""Test cases for Sitemaps classes provided"""
urls = 'zinnia.tests.urls'
View
21 zinnia/tests/templatetags.py
@@ -6,9 +6,10 @@
from django.contrib import comments
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
-from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.contrib.comments.models import CommentFlag
+from django.contrib.auth.tests.utils import skipIfCustomUser
+
from tagging.models import Tag
from zinnia.models.entry import Entry
@@ -94,6 +95,7 @@ def test_get_categories_tree(self):
self.assertEquals(context['template'], 'custom_template.html')
self.assertEquals(context['context_category'], category)
+ @skipIfCustomUser
def test_get_authors(self):
source_context = Context({})
with self.assertNumQueries(1):
@@ -346,6 +348,7 @@ def test_get_calendar_entries(self):
self.assertEquals(context['previous_month'], datetime(2010, 1, 1))
self.assertEquals(context['next_month'], None)
+ @skipIfCustomUser
def test_get_recent_comments(self):
site = Site.objects.get_current()
with self.assertNumQueries(1):
@@ -369,8 +372,8 @@ def test_get_recent_comments(self):
self.assertEquals(context['comments'][0].content_object,
self.entry)
- author = User.objects.create_user(username='webmaster',
- email='webmaster@example.com')
+ author = Author.objects.create_user(username='webmaster',
+ email='webmaster@example.com')
comment_2 = comments.get_model().objects.create(
comment='My Comment 2', site=site,
content_object=self.entry)
@@ -385,9 +388,10 @@ def test_get_recent_comments(self):
self.assertEquals(context['comments'][1].content_object,
self.entry)
+ @skipIfCustomUser
def test_get_recent_linkbacks(self):
- user = User.objects.create_user(username='webmaster',
- email='webmaster@example.com')
+ user = Author.objects.create_user(username='webmaster',
+ email='webmaster@example.com')
site = Site.objects.get_current()
with self.assertNumQueries(1):
context = get_recent_linkbacks()
@@ -524,6 +528,7 @@ def __init__(self, get_dict):
self.assertEquals(context['middle'], [])
self.assertEquals(context['end'], [5, 6, 7])
+ @skipIfCustomUser
def test_zinnia_breadcrumbs(self):
class FakeRequest(object):
def __init__(self, path):
@@ -593,9 +598,8 @@ def check_only_last_have_no_url(crumb_list):
self.assertEquals(len(context['breadcrumbs']), 3)
check_only_last_have_no_url(context['breadcrumbs'])
- User.objects.create_user(username='webmaster',
- email='webmaster@example.com')
- author = Author.objects.get(username='webmaster')
+ author = Author.objects.create_user(username='webmaster',
+ email='webmaster@example.com')
source_context = Context(
{'request': FakeRequest(author.get_absolute_url()),
'object': author})
@@ -705,6 +709,7 @@ def test_get_tag_cloud(self):
self.assertEquals(context['template'], 'custom_template.html')
self.assertEquals(context['context_tag'], tag)
+ @skipIfCustomUser
def test_zinnia_statistics(self):
with self.assertNumQueries(9):
context = zinnia_statistics()
View
2  zinnia/tests/views.py
@@ -11,6 +11,7 @@
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.signals import user_logged_in
from django.contrib.auth.models import update_last_login
+from django.contrib.auth.tests.utils import skipIfCustomUser
from zinnia.models.entry import Entry
from zinnia.models.author import Author
@@ -23,6 +24,7 @@
from zinnia.signals import disconnect_discussion_signals
+@skipIfCustomUser
class ViewsBaseCase(TestCase):
"""
Setup and utility function base case.
Please sign in to comment.
Something went wrong with that request. Please try again.