Browse files

[bug 1121588] Update django 1.7.7

1 parent a529710 commit 226331e36c6a5052b46b54130ebbb6d3062640fe @rlr rlr committed Mar 19, 2015
View
11 kitsune/messages/__init__.py
@@ -1,2 +1,13 @@
+from django.apps import AppConfig
+
+
+default_app_config = 'kitsune.messages.MessagesConfig'
+
+
+class MessagesConfig(AppConfig):
+ name = 'kitsune.messages'
+ label = 'kitsune_messages'
+
+
# The number of threads per page.
MESSAGES_PER_PAGE = 20
View
14 kitsune/notifications/__init__.py
@@ -0,0 +1,14 @@
+from django.apps import AppConfig
+from django.contrib.auth.models import User
+
+import actstream.registry
+
+
+default_app_config = 'kitsune.notifications.NotificationsConfig'
+
+
+class NotificationsConfig(AppConfig):
+ name = 'kitsune.notifications'
+
+ def ready(self):
+ actstream.registry.register(User)
View
4 kitsune/notifications/models.py
@@ -7,7 +7,6 @@
from django.db.models.signals import post_save
from django.dispatch import receiver
-import actstream.registry
from actstream.models import Action
from kitsune.sumo.models import ModelBase
@@ -37,9 +36,6 @@ class PushNotificationRegistration(ModelBase):
push_url = models.CharField(max_length=256)
-actstream.registry.register(User)
-
-
@receiver(post_save, sender=Action, dispatch_uid='action_create_notifications')
def add_notification_for_action(sender, instance, created, **kwargs):
"""When an Action is created, notify every user following something in the Action."""
View
16 kitsune/questions/__init__.py
@@ -0,0 +1,16 @@
+from django.apps import AppConfig
+
+import actstream.registry
+
+
+default_app_config = 'kitsune.questions.QuestionsConfig'
+
+
+class QuestionsConfig(AppConfig):
+ name = 'kitsune.questions'
+
+ def ready(self):
+ Question = self.get_model('Question')
+ actstream.registry.register(Question)
+ Answer = self.get_model('Answer')
+ actstream.registry.register(Answer)
View
5 kitsune/questions/models.py
@@ -18,7 +18,6 @@
from django.http import Http404
import actstream
-import actstream.registry
import actstream.actions
from product_details import product_details
from statsd import statsd
@@ -1379,10 +1378,6 @@ def _content_parsed(obj, locale):
return html
-actstream.registry.register(Question)
-actstream.registry.register(Answer)
-
-
@receiver(post_save, sender=Question, dispatch_uid='question_create_actionstream')
def add_action_for_new_question(sender, instance, created, **kwargs):
if created:
View
8 kitsune/search/admin.py
@@ -263,7 +263,7 @@ def search(request):
})
-admin.site.register_view('search-maintenance', view=search,
+admin.site.register_view(path='search-maintenance', view=search,
name='Search - Index Maintenance')
@@ -336,7 +336,7 @@ def index_view(request):
})
-admin.site.register_view('search-index', view=index_view,
+admin.site.register_view(path='search-index', view=index_view,
name='Search - Index Browsing')
@@ -425,7 +425,7 @@ def troubleshooting_view(request):
})
-admin.site.register_view('search-troubleshooting', view=troubleshooting_view,
+admin.site.register_view(path='search-troubleshooting', view=troubleshooting_view,
name='Search - Index Troubleshooting')
@@ -490,5 +490,5 @@ def synonym_editor(request):
})
-admin.site.register_view('synonym_bulk', view=synonym_editor,
+admin.site.register_view(path='synonym_bulk', view=synonym_editor,
name='Search - Synonym Editor')
View
4 kitsune/settings.py
@@ -504,10 +504,8 @@
# TODO: Figure out why changing the order of apps (for example, moving
# taggit higher in the list) breaks tests.
INSTALLED_APPS = (
- # south needs to come early so tests don't fail
- 'south',
- 'django.contrib.auth',
'django.contrib.contenttypes',
+ 'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
View
9 kitsune/sumo/monkeypatch.py
@@ -82,6 +82,15 @@ def _collect(self, objs, source_attr=None, **kwargs):
util.NestedObjects.collect = _collect
+ # Monkey-patch admin site.
+ from django.contrib import admin
+ from django.contrib.auth.decorators import login_required
+ from adminplus.sites import AdminSitePlus
+
+ # Patch the admin
+ admin.site = AdminSitePlus()
+ admin.site.login = login_required(admin.site.login)
+
# Make |safe less necessary for form fields
import jingo.monkey
jingo.monkey.patch()
View
30 kitsune/sumo/redis_utils.py
@@ -1,5 +1,6 @@
from django.conf import settings
-from django.core.cache import parse_backend_uri
+from django.core.cache.backends.base import InvalidCacheBackendError
+from django.utils.six.moves.urllib.parse import parse_qsl
from redis import Redis, ConnectionError
@@ -48,3 +49,30 @@ def redis_client(name):
raise RedisError(
'Unable to connect to redis backend: {k}'.format(k=name))
return redis
+
+
+# Copy/pasted from django 1.6:
+# https://github.com/django/django/blob/9d915ac1be1e7b8cfea3c92f707a4aeff4e62583/django/core/cache/__init__.py
+def parse_backend_uri(backend_uri):
+ """
+ Converts the "backend_uri" into a cache scheme ('db', 'memcached', etc), a
+ host and any extra params that are required for the backend. Returns a
+ (scheme, host, params) tuple.
+ """
+ if backend_uri.find(':') == -1:
+ raise InvalidCacheBackendError("Backend URI must start with scheme://")
+ scheme, rest = backend_uri.split(':', 1)
+ if not rest.startswith('//'):
+ raise InvalidCacheBackendError("Backend URI must start with scheme://")
+
+ host = rest[2:]
+ qpos = rest.find('?')
+ if qpos != -1:
+ params = dict(parse_qsl(rest[qpos+1:]))
+ host = rest[2:qpos]
+ else:
+ params = {}
+ if host.endswith('/'):
+ host = host[:-1]
+
+ return scheme, host, params
View
6 kitsune/sumo/utils.py
@@ -95,7 +95,11 @@ def delete_files_for_obj(sender, **kwargs):
if not hasattr(obj, field_name):
continue
# Get the class and value of the field.
- field_class = sender._meta.get_field(field_name)
+ try:
+ field_class = sender._meta.get_field(field_name)
+ except models.FieldDoesNotExist:
+ # This works around a weird issue in Django 1.7.
+ continue
field_value = getattr(obj, field_name)
# Check if it's a FileField instance and the field is set.
if isinstance(field_class, models.FileField) and field_value:
View
12 kitsune/urls.py
@@ -1,20 +1,22 @@
from django.conf.urls import include, patterns, url
from django.conf import settings
-from django.contrib import admin
-from django.contrib.auth.decorators import login_required
from django.views.i18n import javascript_catalog
from django.views.decorators.cache import cache_page
from django.views.generic.base import RedirectView
import authority
import badger
-from adminplus.sites import AdminSitePlus
from waffle.views import wafflejs
-admin.site = AdminSitePlus()
+# Note: This must come before importing admin because it patches the
+# admin.
+from kitsune.sumo.monkeypatch import patch
+patch()
+
+from django.contrib import admin
admin.autodiscover()
-admin.site.login = login_required(admin.site.login)
+
authority.autodiscover()
badger.autodiscover()
View
4 kitsune/users/tests/test_templates.py
@@ -507,8 +507,8 @@ def test_new_pw_doesnt_match(self):
'new_password2': self.new_pw + '1'})
eq_(200, r.status_code)
doc = pq(r.content)
- eq_("Your old password was entered incorrectly. Please enter it "
- "again. The two password fields didn't match.",
+ eq_("The two password fields didn't match. Your old password was "
+ "entered incorrectly. Please enter it again.",
doc('ul.errorlist').text())
View
4 requirements/default.txt
@@ -40,8 +40,8 @@ cryptography==0.7.2
# sha256: MxnZwEi7pMyJqWkRgdDgIYei8JtDQ_0vz2zL-EtO4Yo
dennis==0.6.1
-# sha256: flDlc-SEQ1hzs1FdeYLYAJOyaVq6F_0P8CQwdFTcOlY
-Django==1.6.11
+# sha256: SBb4kgY1acqad1hPojy0mVwbO5VO-HUQKoIZIpy9LjM
+Django==1.7.7
# sha256: M7YuOXN4svxB-YixuXUuT1Y5rfNYJN5wxGqKDmv1pVs
django-activity-stream==0.5.1
View
1 scripts/travis/test.sh
@@ -7,7 +7,6 @@ export DISPLAY=:99.0
python manage.py test \
--noinput --logging-clear-handlers \
- --with-fixture-bundling \
--no-skip \
--with-nicedots
echo 'Booyahkasha!'
View
16 wsgi/kitsune.wsgi
@@ -34,19 +34,19 @@ execfile(activate_env, dict(__file__=activate_env))
import manage
import django.conf
-import django.core.handlers.wsgi
-import django.core.management
-import django.utils
+# import django.core.management
+# import django.utils
# Do validate and activate translations like using `./manage.py runserver`.
# http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
-django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
-utility = django.core.management.ManagementUtility()
-command = utility.fetch_command('runserver')
-command.validate()
+# django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
+# utility = django.core.management.ManagementUtility()
+# command = utility.fetch_command('runserver')
+# command.validate()
# This is what mod_wsgi runs.
-django_app = django.core.handlers.wsgi.WSGIHandler()
+from django.core.wsgi import get_wsgi_application
+django_app = get_wsgi_application()
# Normally we could let WSGIHandler run directly, but while we're dark
# launching, we want to force the script name to be empty so we don't create

0 comments on commit 226331e

Please sign in to comment.