Skip to content

Commit

Permalink
Use Django 3.1 models.JSONField
Browse files Browse the repository at this point in the history
This drops all prior Django support and will take us to v5 for this library.  As such, migrations have been reset to a single initial migration which should be fine if upgrading prior versions as there has been no schema change but should alleviate having to have postgres installed just to run migrations.
  • Loading branch information
paltman committed Aug 15, 2020
1 parent 36a93d7 commit 39a8151
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 196 deletions.
39 changes: 9 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,30 @@ jobs:
environment:
- TOXENV=checkqa
- UPLOAD_COVERAGE=0
py36dj22:
py36dj31:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV=py36-dj22
py36dj30:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV=py36-dj30
py37dj22:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV=py37-dj22
py37dj30:
TOXENV=py36-dj31
py37dj31:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV=py37-dj30
py38dj22:
<<: *common
docker:
- image: circleci/python:3.8
environment:
TOXENV=py38-dj22
py38dj30:
TOXENV=py37-dj31
py38dj31:
<<: *common
docker:
- image: circleci/python:3.8
environment:
TOXENV=py38-dj30
TOXENV=py38-dj31

workflows:
version: 2
test:
jobs:
- lint
- py36dj22
- py36dj30
- py37dj22
- py37dj30
- py38dj22
- py38dj30
- py36dj31
- py37dj31
- py38dj31
2 changes: 0 additions & 2 deletions makemigrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import sys

import django

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
Expand Down
33 changes: 0 additions & 33 deletions pinax/eventlog/fields.py

This file was deleted.

29 changes: 14 additions & 15 deletions pinax/eventlog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Generated by Django 3.1 on 2020-08-15 09:54

import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
import django.core.serializers.json
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone

try:
import jsonfield.fields
field = jsonfield.fields.JSONField(default=dict)
except ImportError:
field = models.TextField()

class Migration(migrations.Migration):

initial = True

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Log',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('timestamp', models.DateTimeField(default=django.utils.timezone.now, db_index=True)),
('action', models.CharField(max_length=50, db_index=True)),
('extra', field),
('user', models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=django.db.models.deletion.SET_NULL, null=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('timestamp', models.DateTimeField(db_index=True, default=django.utils.timezone.now)),
('action', models.CharField(db_index=True, max_length=50)),
('object_id', models.PositiveIntegerField(null=True)),
('extra', models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder)),
('content_type', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.contenttype')),
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-timestamp'],
},
bases=(models.Model,),
),
]
27 changes: 0 additions & 27 deletions pinax/eventlog/migrations/0002_auto_20150113_1450.py

This file was deleted.

26 changes: 0 additions & 26 deletions pinax/eventlog/migrations/0003_auto_20160111_0208.py

This file was deleted.

19 changes: 0 additions & 19 deletions pinax/eventlog/migrations/0004_auto_20191205_2033.py

This file was deleted.

20 changes: 0 additions & 20 deletions pinax/eventlog/migrations/0005_auto_20200428_2208.py

This file was deleted.

9 changes: 1 addition & 8 deletions pinax/eventlog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

from .signals import event_logged

if "sqlite" in settings.DATABASES["default"]["ENGINE"]:
from .fields import JSONField
elif "mysql" in settings.DATABASES["default"]["ENGINE"]:
from django_mysql.models import JSONField, Model
else:
from django.contrib.postgres.fields import JSONField


class Log(models.Model):

Expand All @@ -27,7 +20,7 @@ class Log(models.Model):
content_type = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL)
object_id = models.PositiveIntegerField(null=True)
obj = GenericForeignKey("content_type", "object_id")
extra = JSONField(DjangoJSONEncoder)
extra = models.JSONField(encoder=DjangoJSONEncoder)

@property
def template_fragment_name(self):
Expand Down
2 changes: 0 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import sys

import django

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
Expand Down
12 changes: 4 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.0.1"
VERSION = "5.0.0"
LONG_DESCRIPTION = """
.. image:: http://pinaxproject.com/pinax-design/patches/pinax-eventlog.svg
:target: https://pypi.python.org/pypi/pinax-eventlog/
Expand Down Expand Up @@ -43,9 +43,7 @@
+-----------------+-----+-----+-----+
| Django / Python | 3.6 | 3.7 | 3.8 |
+=================+=====+=====+=====+
| 2.2 | * | * | * |
+-----------------+-----+-----+-----+
| 3.0 | * | * | * |
| 3.1 | * | * | * |
+-----------------+-----+-----+-----+
"""

Expand All @@ -67,8 +65,7 @@
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand All @@ -80,8 +77,7 @@
"Topic :: Software Development :: Libraries :: Python Modules",
],
install_requires=[
"django>=2.2",
"psycopg2-binary>=2.8.4"
"django>=3.1",
],
tests_require=[
],
Expand Down
11 changes: 5 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ show_missing = True
[tox]
envlist =
checkqa,
py{36,37,38}-dj{22,30}
py{36,37,38}-dj{31}

[testenv]
passenv = CI CIRCLECI CIRCLE_*
deps =
coverage<5
codecov
dj22: Django>=2.2,<3.0
dj30: Django>=3.0,<3.1
dj30: Django>=3.1
master: https://github.com/django/django/tarball/master

usedevelop = True
Expand All @@ -49,6 +48,6 @@ commands =
flake8 pinax
isort --recursive --check-only --diff pinax -sp tox.ini
deps =
flake8 == 3.7.9
flake8-quotes == 2.1.1
isort == 4.3.21
flake8 == 3.8.3
flake8-quotes == 3.2.0
isort == 5.4.2

0 comments on commit 39a8151

Please sign in to comment.