Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Bug 1116335: Re-lint all of kuma through to Django 1.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
ubernostrum committed Jun 1, 2015
1 parent adeaa00 commit b8b8f83
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 33 deletions.
4 changes: 2 additions & 2 deletions kuma/actioncounters/models.py
@@ -1,7 +1,7 @@
"""Models for activity counters"""
from django.conf import settings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.db import models
from django.db.models import F
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -44,7 +44,7 @@ class ActionCounterUnique(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name="content type",
related_name="content_type_set_for_%(class)s",)
object_pk = models.CharField(_('object ID'), max_length=32)
content_object = generic.GenericForeignKey('content_type', 'object_pk')
content_object = GenericForeignKey('content_type', 'object_pk')
name = models.CharField(_('name of the action'), max_length=64,
db_index=True, blank=False)

Expand Down
4 changes: 2 additions & 2 deletions kuma/authkeys/models.py
Expand Up @@ -5,8 +5,8 @@
from django.conf import settings
from django.db import models

from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

from django.utils.translation import ugettext_lazy as _

Expand Down Expand Up @@ -63,5 +63,5 @@ class KeyAction(models.Model):
notes = models.TextField(null=True)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
content_object = GenericForeignKey('content_type', 'object_id')
created = models.DateTimeField(auto_now_add=True)
4 changes: 2 additions & 2 deletions kuma/contentflagging/models.py
@@ -1,6 +1,6 @@
"""Models for content moderation flagging"""
from django.conf import settings
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core import urlresolvers
from django.core.mail import send_mail
Expand Down Expand Up @@ -109,7 +109,7 @@ class Meta:
verbose_name="content type",
related_name="content_type_set_for_%(class)s",)
object_pk = models.CharField(_('object ID'), max_length=32, editable=False)
content_object = generic.GenericForeignKey('content_type', 'object_pk')
content_object = GenericForeignKey('content_type', 'object_pk')

ip = models.CharField(max_length=40, editable=False, blank=True, null=True)
user_agent = models.CharField(max_length=128, editable=False,
Expand Down
4 changes: 2 additions & 2 deletions kuma/core/cache.py
@@ -1,4 +1,4 @@
from django.core.cache import get_cache
from django.core.cache import caches

# just a helper to not have to redefine that all over the place
memcache = get_cache('memcache')
memcache = caches['memcache']
4 changes: 2 additions & 2 deletions kuma/core/helpers.py
Expand Up @@ -23,7 +23,7 @@
from django.utils.encoding import smart_str, force_text
from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django.utils.tzinfo import LocalTimezone
from django.utils.timezone import get_default_timezone

from soapbox.models import Message
from statici18n.utils import get_filename
Expand Down Expand Up @@ -145,7 +145,7 @@ def timesince(d, now=None):
'%(number)d seconds ago', n))]
if not now:
if d.tzinfo:
now = datetime.datetime.now(LocalTimezone(d))
now = datetime.datetime.now(get_default_timezone())
else:
now = datetime.datetime.now()

Expand Down
3 changes: 2 additions & 1 deletion kuma/core/tests/__init__.py
@@ -1,3 +1,5 @@
from importlib import import_module

from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.messages.storage.fallback import FallbackStorage
Expand All @@ -6,7 +8,6 @@
from django.test import TestCase, TransactionTestCase
from django.test.client import Client
from django.utils.functional import wraps
from django.utils.importlib import import_module
from django.utils.translation import trans_real

from constance import config
Expand Down
2 changes: 1 addition & 1 deletion kuma/demos/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from django.contrib.admin import helpers
from django.contrib.admin.util import model_ngettext, get_deleted_objects
from django.contrib.admin.utils import model_ngettext, get_deleted_objects
from django.db import router
from django.core.exceptions import PermissionDenied
from django.template.response import TemplateResponse
Expand Down
5 changes: 3 additions & 2 deletions kuma/demos/helpers.py
Expand Up @@ -7,7 +7,8 @@
import jinja2

from django.conf import settings
from django.utils.tzinfo import LocalTimezone

from django.utils.timezone import get_default_timezone

import jingo
from jingo import register
Expand Down Expand Up @@ -315,7 +316,7 @@ def timesince(d, now=None):
'%(number)d seconds ago', n))]
if not now:
if d.tzinfo:
now = datetime.datetime.now(LocalTimezone(d))
now = datetime.datetime.now(get_default_timezone())
else:
now = datetime.datetime.now()

Expand Down
5 changes: 3 additions & 2 deletions kuma/search/filters.py
@@ -1,5 +1,6 @@
import collections

from django.conf import settings
from django.utils.datastructures import SortedDict

from elasticsearch_dsl import F, Q, query
from rest_framework.filters import BaseFilterBackend
Expand All @@ -11,7 +12,7 @@


def get_filters(getter_func):
filters = SortedDict()
filters = collections.OrderedDict()
for slug in FilterGroup.objects.values_list('slug', flat=True):
for filters_slug in getter_func(slug, []):
filters[filters_slug] = None
Expand Down
4 changes: 2 additions & 2 deletions kuma/search/models.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.dispatch import receiver
Expand Down Expand Up @@ -110,7 +110,7 @@ class OutdatedObject(models.Model):
created_at = models.DateTimeField(default=timezone.now)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
content_object = GenericForeignKey('content_type', 'object_id')


class FilterGroup(models.Model):
Expand Down
9 changes: 4 additions & 5 deletions kuma/search/serializers.py
@@ -1,7 +1,6 @@
import collections
from operator import attrgetter

from django.utils.datastructures import SortedDict

from elasticsearch_dsl import document
from rest_framework import serializers, pagination
from tower import ugettext as _
Expand Down Expand Up @@ -71,10 +70,10 @@ def get_filters(self, obj):
view = self.context['view']

url = QueryURLObject(view.url)
filter_mapping = SortedDict((filter_['slug'], filter_)
for filter_ in view.serialized_filters)
filter_mapping = OrderedDict((filter_['slug'], filter_)

This comment has been minimized.

Copy link
@groovecoder

groovecoder Jun 1, 2015

Contributor
18:14:00 web.1        |   File "/home/vagrant/src/kuma/search/serializers.py", line 73, in get_filters
18:14:00 web.1        |     filter_mapping = OrderedDict((filter_['slug'], filter_)
18:14:00 web.1        | NameError: global name 'OrderedDict' is not defined
for filter_ in view.serialized_filters)

filter_groups = SortedDict()
filter_groups = OrderedDict()

try:
facet_counts = [
Expand Down
4 changes: 2 additions & 2 deletions kuma/users/backends.py
@@ -1,8 +1,8 @@
import collections
import hashlib

from django.contrib.auth.hashers import BasePasswordHasher, mask_hash
from django.utils.crypto import constant_time_compare
from django.utils.datastructures import SortedDict

from tower import ugettext as _

Expand All @@ -29,7 +29,7 @@ def verify(self, password, encoded):
def safe_summary(self, encoded):
algorithm, salt, hash = encoded.split('$', 2)
assert algorithm == self.algorithm
return SortedDict([
return OrderedDict([
(_('algorithm'), algorithm),
(_('salt'), mask_hash(salt, show=2)),
(_('hash'), mask_hash(hash)),
Expand Down
2 changes: 1 addition & 1 deletion kuma/users/helpers.py
Expand Up @@ -92,7 +92,7 @@ def provider_login_url(context, provider_id, **params):
request = context['request']
provider = providers.registry.by_id(provider_id)
if 'next' not in params:
next = request.REQUEST.get('next')
next = request.GET.get('next')
if next:
params['next'] = next
else:
Expand Down
3 changes: 2 additions & 1 deletion kuma/users/urls.py
@@ -1,5 +1,6 @@
import importlib

from django.conf.urls import include, url
from django.utils import importlib

from allauth.account import views as account_views
from allauth.socialaccount import providers, views as socialaccount_views
Expand Down
4 changes: 2 additions & 2 deletions kuma/users/views.py
@@ -1,3 +1,4 @@
import collections
import operator

from django import forms
Expand All @@ -9,7 +10,6 @@
from django.db.models import Q
from django.http import Http404, HttpResponseForbidden, HttpResponseBadRequest
from django.shortcuts import get_object_or_404, render, redirect
from django.utils.datastructures import SortedDict

from allauth.account.adapter import get_adapter
from allauth.account.models import EmailAddress
Expand Down Expand Up @@ -273,7 +273,7 @@ def get_form(self, form_class):
"""
Returns an instance of the form to be used in this view.
"""
self.email_addresses = SortedDict()
self.email_addresses = OrderedDict()

This comment has been minimized.

Copy link
@groovecoder

groovecoder Jun 1, 2015

Contributor
  File "/home/vagrant/src/kuma/users/views.py", line 276, in get_form
    self.email_addresses = OrderedDict()
NameError: global name 'OrderedDict' is not defined
form = super(SignupView, self).get_form(form_class)
form.fields['email'].label = _('Email address')
self.matching_user = None
Expand Down
4 changes: 2 additions & 2 deletions kuma/wiki/views.py
Expand Up @@ -1590,8 +1590,8 @@ def translate(request, document_slug, document_locale, revision_id=None):
# HACK: Seems weird, but sticking the translate-to locale in a query
# param is the best way to avoid the MindTouch-legacy locale
# redirection logic.
document_locale = request.REQUEST.get('tolocale',
document_locale)
document_locale = request.GET.get('tolocale',
document_locale)

# Set a "Discard Changes" page
discard_href = ''
Expand Down
4 changes: 2 additions & 2 deletions settings.py
Expand Up @@ -538,8 +538,8 @@ def JINJA_CONFIG():
import jinja2
from django.conf import settings
from django.core.cache.backends.memcached import MemcachedCache
from django.core.cache import get_cache
cache = get_cache('memcache')
from django.core.cache import caches
cache = caches['memcache']
config = {'extensions': ['jinja2.ext.i18n', 'tower.template.i18n',
'jinja2.ext.with_', 'jinja2.ext.loopcontrols',
'jinja2.ext.autoescape'],
Expand Down

0 comments on commit b8b8f83

Please sign in to comment.