Skip to content

Upgrade Django to 1.9 #1135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ sudo: false
language: python
python: 3.4
cache: pip
addons:
postgresql: "9.4"
services:
- postgresql
env:
global:
- DATABASE_URL=postgres://postgres:@127.0.0.1:5432/python.org
Expand Down
15 changes: 6 additions & 9 deletions base-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
dj-database-url==0.4.2
# TODO: Use builtin LoginRequiredMixin in Django 1.9:
# https://docs.djangoproject.com/en/1.9/releases/1.9/#permission-mixins-for-class-based-views
django-braces==1.11.0
# TODO: We'll switch to use 1.6.x for Django 1.9 support.
django-pipeline==1.5.4
django-pipeline==1.6.13
django-sitetree==1.8.0
Django==1.8.18
Django==1.9.13
docutils==0.12
Markdown==2.5.2
Pillow==2.7.0
Expand All @@ -18,21 +14,22 @@ beautifulsoup4==4.3.2
icalendar==3.8.4
chardet2==2.0.3
# TODO: We may drop 'django-imagekit' completely.
django-imagekit==3.2.7
django-imagekit==4.0.1
django-haystack==2.5.1
elasticsearch==1.3.0
pyelasticsearch==0.6.1
django-tastypie==0.12.2
# TODO: 0.14.0 only supports Django 1.8 and 1.11.
django-tastypie==0.13.0

pytz==2016.7
python-dateutil==2.4.0

requests==2.5.1

django-jsonfield==1.0.1
django-honeypot==0.6.0
django-markupfield==1.4.2

# TODO: 0.33.0 doesn't support Django 1.9.
django-allauth==0.32.0

django-waffle==0.12
Expand Down
6 changes: 2 additions & 4 deletions blogs/admin.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
from django.contrib import admin
from django.core.management import call_command
from django.utils.html import format_html

from cms.admin import ContentManageableModelAdmin

from .models import BlogEntry, Contributor, Translation, Feed, FeedAggregate



class TranslationAdmin(ContentManageableModelAdmin):
list_display = ['name', '_display_url']

def _display_url(self, obj):
return """<a href="{0}">{0}</a>""".format(obj.url)

_display_url.allow_tags = True
return format_html('<a href="{0}">{0}</a>'.format(obj.url))

admin.site.register(Translation, TranslationAdmin)

Expand Down
16 changes: 8 additions & 8 deletions blogs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class Migration(migrations.Migration):
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
('updated', models.DateTimeField(blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_contributor_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_contributor_modified', blank=True)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='blog_contributor')),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_contributor_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_contributor_modified', blank=True, on_delete=models.CASCADE)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='blog_contributor', on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Contributor',
Expand Down Expand Up @@ -84,8 +84,8 @@ class Migration(migrations.Migration):
('blog_name', models.CharField(help_text='Displayed Name', max_length=200)),
('last_entry_published', models.DateTimeField(db_index=True)),
('last_entry_title', models.CharField(max_length=500)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_relatedblog_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_relatedblog_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_relatedblog_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_relatedblog_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Related Blog',
Expand All @@ -101,8 +101,8 @@ class Migration(migrations.Migration):
('updated', models.DateTimeField(blank=True)),
('name', models.CharField(max_length=100)),
('url', models.URLField(verbose_name='URL')),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_translation_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_translation_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_translation_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='blogs_translation_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Translation',
Expand All @@ -114,7 +114,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='blogentry',
name='feed',
field=models.ForeignKey(to='blogs.Feed'),
field=models.ForeignKey(to='blogs.Feed', on_delete=models.CASCADE),
preserve_default=True,
),
]
8 changes: 6 additions & 2 deletions blogs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BlogEntry(models.Model):
summary = models.TextField(blank=True)
pub_date = models.DateTimeField()
url = models.URLField('URL')
feed = models.ForeignKey('Feed')
feed = models.ForeignKey('Feed', on_delete=models.CASCADE)

class Meta:
verbose_name = 'Blog Entry'
Expand Down Expand Up @@ -76,7 +76,11 @@ def get_absolute_url(self):

class Contributor(ContentManageable):
""" Blog Contributors """
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="blog_contributor")
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name='blog_contributor',
on_delete=models.CASCADE,
)

class Meta:
verbose_name = 'Contributor'
Expand Down
4 changes: 2 additions & 2 deletions boxes/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Migration(migrations.Migration):
('content', markupfield.fields.MarkupField(rendered_field=True)),
('content_markup_type', models.CharField(max_length=30, choices=[('', '--'), ('html', 'html'), ('plain', 'plain'), ('markdown', 'markdown'), ('restructuredtext', 'restructuredtext')], default='restructuredtext')),
('_content_rendered', models.TextField(editable=False)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='boxes_box_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='boxes_box_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='boxes_box_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='boxes_box_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'boxes',
Expand Down
6 changes: 5 additions & 1 deletion boxes/templatetags/boxes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import logging

from django import template
from django.utils.html import mark_safe

from ..models import Box

log = logging.getLogger(__name__)
register = template.Library()


@register.simple_tag
def box(label):
try:
return Box.objects.only('content').get(label=label).content.rendered
return mark_safe(Box.objects.only('content').get(label=label).content.rendered)
except Box.DoesNotExist:
log.warning('WARNING: box not found: label=%s', label)
return ''
16 changes: 14 additions & 2 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@ class ContentManageable(models.Model):
# object we'll get an error. This is a reasonable compromise that lets us
# track creators fairly well without necessarily over-enforcing it in places
# where it'd be invasive.
creator = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, related_name="%(app_label)s_%(class)s_creator")
last_modified_by = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, related_name="%(app_label)s_%(class)s_modified")
creator = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name='%(app_label)s_%(class)s_creator',
null=True,
blank=True,
on_delete=models.CASCADE,
)
last_modified_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name='%(app_label)s_%(class)s_modified',
null=True,
blank=True,
on_delete=models.CASCADE,
)

def save(self, **kwargs):
self.updated = timezone.now()
Expand Down
9 changes: 3 additions & 6 deletions cms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ def legacy_path(path):
return urljoin(LEGACY_PYTHON_DOMAIN, path)


def custom_404(request, template_name='404.html'):
""" Custom 404 handler to only cache 404s for 5 mintues """

def custom_404(request, exception, template_name='404.html'):
"""Custom 404 handler to only cache 404s for 5 minutes."""
context = {
'legacy_path': legacy_path(request.path),
'download_path': reverse('download:download'),
'doc_path': reverse('documentation'),
'pypi_path': PYPI_URL,
}
response = render(request, template_name, context)
response = render(request, template_name, context=context, status=404)
response['Cache-Control'] = 'max-age=300'
response.status_code = 404

return response
4 changes: 2 additions & 2 deletions codesamples/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Migration(migrations.Migration):
('copy_markup_type', models.CharField(max_length=30, choices=[('', '--'), ('html', 'html'), ('plain', 'plain'), ('markdown', 'markdown'), ('restructuredtext', 'restructuredtext')], default='html', blank=True)),
('is_published', models.BooleanField(db_index=True, default=False)),
('_copy_rendered', models.TextField(editable=False)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='codesamples_codesample_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='codesamples_codesample_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='codesamples_codesample_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='codesamples_codesample_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'sample',
Expand Down
26 changes: 13 additions & 13 deletions community/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals

from django.db import models, migrations
import jsonfield.fields
import django.contrib.postgres.fields.jsonb
import markupfield.fields
import django.utils.timezone
from django.conf import settings
Expand All @@ -22,8 +22,8 @@ class Migration(migrations.Migration):
('created', models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)),
('updated', models.DateTimeField(blank=True)),
('url', models.URLField(max_length=1000, verbose_name='URL', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_link_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_link_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_link_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_link_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Link',
Expand All @@ -43,8 +43,8 @@ class Migration(migrations.Migration):
('image_url', models.URLField(max_length=1000, verbose_name='Image URL', blank=True)),
('caption', models.TextField(blank=True)),
('click_through_url', models.URLField(blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_photo_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_photo_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_photo_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_photo_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'photo',
Expand All @@ -67,10 +67,10 @@ class Migration(migrations.Migration):
('_content_rendered', models.TextField(editable=False)),
('media_type', models.IntegerField(choices=[(1, 'text'), (2, 'photo'), (3, 'video'), (4, 'link')], default=1)),
('source_url', models.URLField(max_length=1000, blank=True)),
('meta', jsonfield.fields.JSONField(default={}, blank=True)),
('meta', django.contrib.postgres.fields.jsonb.JSONField(default={}, blank=True)),
('status', models.IntegerField(db_index=True, choices=[(1, 'private'), (2, 'public')], default=1)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_post_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_post_modified', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_post_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_post_modified', blank=True, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'post',
Expand All @@ -90,9 +90,9 @@ class Migration(migrations.Migration):
('video_data', models.FileField(upload_to='community/videos/', blank=True)),
('caption', models.TextField(blank=True)),
('click_through_url', models.URLField(verbose_name='Click Through URL', blank=True)),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_video_creator', blank=True)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_video_modified', blank=True)),
('post', models.ForeignKey(editable=False, null=True, to='community.Post', related_name='related_video')),
('creator', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_video_creator', blank=True, on_delete=models.CASCADE)),
('last_modified_by', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='community_video_modified', blank=True, on_delete=models.CASCADE)),
('post', models.ForeignKey(editable=False, null=True, to='community.Post', related_name='related_video', on_delete=models.CASCADE)),
],
options={
'verbose_name': 'video',
Expand All @@ -105,13 +105,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='photo',
name='post',
field=models.ForeignKey(editable=False, null=True, to='community.Post', related_name='related_photo'),
field=models.ForeignKey(editable=False, null=True, to='community.Post', related_name='related_photo', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='link',
name='post',
field=models.ForeignKey(editable=False, null=True, to='community.Post', related_name='related_link'),
field=models.ForeignKey(editable=False, null=True, to='community.Post', related_name='related_link', on_delete=models.CASCADE),
preserve_default=True,
),
]
Loading