Commits

Scott Nixon committed f82fb96

Support for Django 1.5

Comments (0)

Files changed (9)

articles/admin.py

 import logging
 
 from django.contrib import admin
-from django.contrib.auth.models import User
 from django.utils.translation import ugettext_lazy as _
 from forms import ArticleAdminForm
 from models import Tag, Article, ArticleStatus, Attachment
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
 
 log = logging.getLogger('articles.admin')
 
 admin.site.register(Tag, TagAdmin)
 admin.site.register(Article, ArticleAdmin)
 admin.site.register(ArticleStatus, ArticleStatusAdmin)
-

articles/management/commands/check_for_articles_from_email.py

 import time
 
 from django.conf import settings
-from django.contrib.auth.models import User
 from django.contrib.sites.models import Site
 from django.core.management.base import BaseCommand
 from django.utils.translation import ugettext_lazy as _
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
 
 from articles.models import Article, Attachment, MARKUP_HTML, MARKUP_MARKDOWN, MARKUP_REST, MARKUP_TEXTILE
 
 
             if i > len(decoded):
                 raise StopIteration
-

articles/models.py

 
 from django.db import models
 from django.db.models import Q
-from django.contrib.auth.models import User
 from django.contrib.markup.templatetags import markup
 from django.contrib.sites.models import Site
 from django.core.cache import cache
 from django.utils.translation import ugettext_lazy as _
 from django.utils.text import truncate_html_words
 
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
+
 from decorators import logtime, once_per_instance
 
 WORD_LIMIT = getattr(settings, 'ARTICLES_TEASER_LIMIT', 75)
             content_type = 'text_plain'
 
         return content_type
-

articles/templates/articles/_articles.html

 {% load i18n %}
+{% load url from future %}
 {% if forloop.first %}<ol class="article-list">{% endif %}
     <li>
         <h3><a href="{{ article.get_absolute_url }}" title="{% trans 'Read this article' %}">{{ article.title }}</a></h3>
         <div class="quiet">
             {% trans 'Posted on' %} {{ article.publish_date|date:"F jS, Y" }}
-            {% trans 'by' %} <a href="{% url articles_by_author article.author.username %}" title="{% trans 'View articles posted by' %} {{ article.author.get_name }}">{{ article.author.get_name }}</a>
+            {% trans 'by' %} <a href="{% url "articles_by_author" article.author.username %}" title="{% trans 'View articles posted by' %} {{ article.author.get_name }}">{{ article.author.get_name }}</a>
         </div>
     </li>
 {% if forloop.last %}</ol>{% endif %}

articles/templates/articles/_meta.html

 {% load i18n humanize %}
+{% load url from future %}
 
 <div id="article-meta">
   <h4>Meta</h4>
 
   <p><strong>{% trans 'Published' %}</strong>: {{ article.publish_date|naturalday }}</p>
 
-  <p><strong>{% trans 'Author' %}</strong>: <a href="{% url articles_by_author article.author.username %}" title="{% trans 'Read other articles by this author' %}">{{ article.author.get_name }}</a></p>
+  <p><strong>{% trans 'Author' %}</strong>: <a href="{% url "articles_by_author" article.author.username %}" title="{% trans 'Read other articles by this author' %}">{{ article.author.get_name }}</a></p>
 
   <p><strong>{% trans 'Comments' %}</strong>: <a href="#disqus_thread">&nbsp;</a></p>
 
   {% endfor %}
 </div>
 <div class="clear"></div>
-

articles/templates/articles/article_detail.html

 {% extends 'articles/base.html' %}
 {% load i18n %}
+{% load url from future %}
 
 {% block title %}{% trans article.title %}{% endblock %}
 {% block meta-keywords %}{{ article.keywords|escape }}{% endblock %}
 {% block extra-head %}
 {{ block.super }}
 {% for tag in article.tags.all %}
-<link rel="alternate" type="application/rss+xml" title="Blog Articles Tagged '{{ tag.name }}' RSS Feed" href="{% url articles_rss_feed_tag tag.rss_name %}" />
-<link rel="alternate" type="application/atom+xml" title="Blog Articles Tagged '{{ tag.name }}' Atom Feed" href="{% url articles_atom_feed_tag tag.rss_name %}" />{% endfor %}
+<link rel="alternate" type="application/rss+xml" title="Blog Articles Tagged '{{ tag.name }}' RSS Feed" href="{% url "articles_rss_feed_tag" tag.rss_name %}" />
+<link rel="alternate" type="application/atom+xml" title="Blog Articles Tagged '{{ tag.name }}' Atom Feed" href="{% url "articles_atom_feed_tag" tag.rss_name %}" />{% endfor %}
 {% endblock %}
 
 {% block content %}
     //]]>
     </script>
 {% endif %}
-{% endblock %}
+{% endblock %}

articles/templates/articles/base.html

 {% extends 'base.html' %}
 {% load article_tags i18n %}
+{% load url from future %}
 
 {% block extra-head %}
 {{ block.super }}
-<link rel="alternate" type="application/rss+xml" title="Latest Blog Articles RSS Feed" href="{% url articles_rss_feed_latest %}" />
-<link rel="alternate" type="application/atom+xml" title="Latest Blog Articles Atom Feed" href="{% url articles_atom_feed_latest %}" />
+<link rel="alternate" type="application/rss+xml" title="Latest Blog Articles RSS Feed" href="{% url "articles_rss_feed_latest" %}" />
+<link rel="alternate" type="application/atom+xml" title="Latest Blog Articles Atom Feed" href="{% url "articles_atom_feed_latest" %}" />
 {% endblock %}
 
 {% block content %}
             <strong>{{ year.0 }}</strong>
             <ul class="months">
             {% for month in year.1 %}
-                <li><a href="{% url articles_in_month month.year,month.month %}" title="{% trans 'View articles posted in this month' %}">{{ month|date:"N" }}</a></li>
+                <li><a href="{% url "articles_in_month" month.year,month.month %}" title="{% trans 'View articles posted in this month' %}">{{ month|date:"N" }}</a></li>
             {% endfor %}
             </ul>
             <div class="clear">&nbsp;</div>
 {% endifnotequal %}
 {% endif %}
 {% endblock %}
-

articles/templates/articles/display_tag.html

 {% extends 'articles/base.html' %}
 {% load i18n %}
+{% load url from future %}
 
 {% block title %}{% trans 'Articles Tagged' %}: {{ tag.name }}{% endblock %}
 {% block extra-head %}
 {{ block.super }}
-<link rel="alternate" type="application/rss+xml" title="Blog Articles Tagged '{{ tag.name }}' RSS Feed" href="{% url articles_rss_feed_tag tag.rss_name %}" />
-<link rel="alternate" type="application/atom+xml" title="Blog Articles Tagged '{{ tag.name }}' Atom Feed" href="{% url articles_atom_feed_tag tag.rss_name %}" />
+<link rel="alternate" type="application/rss+xml" title="Blog Articles Tagged '{{ tag.name }}' RSS Feed" href="{% url "articles_rss_feed_tag" tag.rss_name %}" />
+<link rel="alternate" type="application/atom+xml" title="Blog Articles Tagged '{{ tag.name }}' Atom Feed" href="{% url "articles_atom_feed_tag" tag.rss_name %}" />
 {% endblock %}
 
 {% block articles-content %}
 {% for article in page_obj.object_list %}
 {% include 'articles/_articles.html' %}
 {% endfor %}
-{% endblock %}
+{% endblock %}

articles/views.py

 import logging
 
 from django.conf import settings
-from django.contrib.auth.models import User
 from django.core.cache import cache
 from django.core.paginator import Paginator, EmptyPage
 from django.core.urlresolvers import reverse
 from django.template import RequestContext
 from articles.models import Article, Tag
 from datetime import datetime
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
 
 ARTICLE_PAGINATION = getattr(settings, 'ARTICLE_PAGINATION', 20)
 
         return response
 
     return HttpResponse()
-