From 3a03cb71fe4f59940a3fc445ce0ad63339f162e7 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 4 Sep 2014 09:16:56 +0200 Subject: [PATCH] Add support for custom user models --- djangocms_blog/models.py | 18 +++++++++++------- .../djangocms_blog/includes/blog_item.html | 2 +- .../djangocms_blog/plugins/authors.html | 2 +- .../templates/djangocms_blog/post_detail.html | 2 +- djangocms_blog/views.py | 13 ++++++++----- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index f052c45..1ae7ed8 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from cms.models import PlaceholderField, CMSPlugin from cmsplugin_filer_image.models import ThumbnailOption -from django.contrib.auth.models import User +from django.conf import settings as dj_settings from django.core.urlresolvers import reverse from django.db import models from django.utils import timezone @@ -62,7 +62,8 @@ class Post(ModelMeta, TranslatableModel): """ Blog post """ - author = models.ForeignKey(User, verbose_name=_('Author'), null=True, blank=True, + author = models.ForeignKey(dj_settings.AUTH_USER_MODEL, + verbose_name=_('Author'), null=True, blank=True, related_name='djangocms_blog_post_author') date_created = models.DateTimeField(auto_now_add=True) @@ -217,11 +218,14 @@ class LatestPostsPlugin(CMSPlugin): class AuthorEntriesPlugin(CMSPlugin): - authors = models.ManyToManyField(User, verbose_name=_('Authors'), - limit_choices_to={'djangocms_blog_post_author__publish': True} - ) - latest_posts = models.IntegerField(_(u'Articles'), default=settings.BLOG_LATEST_POSTS, - help_text=_('The number of author articles to be displayed.')) + authors = models.ManyToManyField( + dj_settings.AUTH_USER_MODEL, verbose_name=_('Authors'), + limit_choices_to={'djangocms_blog_post_author__publish': True} + ) + latest_posts = models.IntegerField( + _(u'Articles'), default=settings.BLOG_LATEST_POSTS, + help_text=_('The number of author articles to be displayed.') + ) def __unicode__(self): return u"%s latest articles by author" % self.latest_posts diff --git a/djangocms_blog/templates/djangocms_blog/includes/blog_item.html b/djangocms_blog/templates/djangocms_blog/includes/blog_item.html index f7884d0..f5c2022 100644 --- a/djangocms_blog/templates/djangocms_blog/includes/blog_item.html +++ b/djangocms_blog/templates/djangocms_blog/includes/blog_item.html @@ -7,7 +7,7 @@ {% block blog_meta %}