Skip to content

Commit

Permalink
Fix a few cases of compatibility with really old Django versions
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 27, 2018
1 parent b24aebe commit ab5d329
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 29 deletions.
11 changes: 2 additions & 9 deletions plata/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import re

from django import forms, VERSION
from django import forms
from django.core.exceptions import ValidationError
from django.db import models
from django.utils import six
Expand All @@ -23,13 +23,6 @@
raise Exception("simplejson>=2.1 with support for use_decimal required.")


if VERSION >= (1, 8):
_JSONFieldBase = models.TextField
else:
# Django < 1.8, deprecated code, remove it after Django 1.9 release (in
# December 2015)
_JSONFieldBase = six.with_metaclass(models.SubfieldBase, models.TextField)

#: Field offering all defined currencies
CurrencyField = curry(
models.CharField,
Expand Down Expand Up @@ -100,7 +93,7 @@ def clean(self, value, *args, **kwargs):
return super(JSONFormField, self).clean(value, *args, **kwargs)


class JSONField(_JSONFieldBase):
class JSONField(models.TextField):
"""
TextField which transparently serializes/unserializes JSON objects
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -1092,15 +1092,6 @@ def _compare(data):
reloaded_order = Order.objects.get(pk=order.pk)
self.assertEqual(data, reloaded_order.data)

import django

if django.VERSION >= (1, 5):
timezone_now = timezone.now
else:
# XXX Somehow, this testcase always fails with timezones in
# Django 1.4, and I'm too lazy right now.
timezone_now = datetime.now

_compare({"the_answer": 42, "the_cost": Decimal("37.50")})

_compare(
Expand All @@ -1112,18 +1103,18 @@ def _compare(data):

_compare(
{
"now_tz": timezone_now().replace(microsecond=0),
"now_tz_with_ms": timezone_now(),
"now_tz": timezone.now().replace(microsecond=0),
"now_tz_with_ms": timezone.now(),
}
)

_compare({"today": date.today()})

_compare(
{
"now_tz_with_ms": timezone_now().time(),
"now_tz_with_ms": timezone.now().time(),
"now_with_ms": datetime.now().time(),
"now_tz": timezone_now().replace(microsecond=0).time(),
"now_tz": timezone.now().replace(microsecond=0).time(),
"now": datetime.now().replace(microsecond=0).time(),
}
)
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions tests/testapp/tests/__init__.py

This file was deleted.

0 comments on commit ab5d329

Please sign in to comment.