Skip to content

Commit

Permalink
Merge pull request #24 from pinax/django-20
Browse files Browse the repository at this point in the history
Update for Django v2.0
  • Loading branch information
grahamu committed Dec 7, 2017
2 parents 5f2c66f + e45d055 commit c06cab0
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 181 deletions.
96 changes: 96 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
version: 2.0

common: &common
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v2-deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
- v2-deps-
- run:
name: install dependencies
command: pip install --user tox
- run:
name: run tox
command: ~/.local/bin/tox
- run:
name: upload coverage report
command: |
if [[ "$UPLOAD_COVERAGE" != 0 ]]; then
PATH=$HOME/.local/bin:$PATH
pip install --user codecov
coverage xml
~/.local/bin/codecov --required -X search gcov pycov -f coverage.xml --flags $CIRCLE_JOB
fi
- save_cache:
paths:
- .tox
- ~/.cache/pip
- ~/.local
- ./eggs
key: v2-deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}

jobs:
lint:
<<: *common
docker:
- image: circleci/python:3.6.1
environment:
- TOXENV=checkqa
- UPLOAD_COVERAGE=0
py27dj111:
<<: *common
docker:
- image: circleci/python:2.7
environment:
TOXENV=py27-dj111
py34dj111:
<<: *common
docker:
- image: circleci/python:3.4
environment:
TOXENV=py34-dj111
py34dj20:
<<: *common
docker:
- image: circleci/python:3.4
environment:
TOXENV=py34-dj20
py35dj111:
<<: *common
docker:
- image: circleci/python:3.5
environment:
TOXENV=py35-dj111
py35dj20:
<<: *common
docker:
- image: circleci/python:3.5
environment:
TOXENV=py35-dj20
py36dj111:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV=py36-dj111
py36dj20:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV=py36-dj20

workflows:
version: 2
test:
jobs:
- lint
- py27dj111
- py34dj111
- py34dj20
- py35dj111
- py35dj20
- py36dj111
- py36dj20
46 changes: 38 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
build
dist
.coverage
.tox
MANIFEST
*.pyc
*.egg-info
*.egg
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]


# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
docs/_build/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
*.eggs
.python-version

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.eggs
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# IDEs
.idea/
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

47 changes: 47 additions & 0 deletions makemigrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python
import os
import sys

import django

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"pinax.eventlog",
"pinax.eventlog.tests"
],
MIDDLEWARE_CLASSES=[],
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
SITE_ID=1,
SECRET_KEY="notasecret",
)


def run(*args):
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)

django.setup()

parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)

django.core.management.call_command(
"makemigrations",
"eventlog",
*args
)


if __name__ == "__main__":
run(*sys.argv[1:])
5 changes: 3 additions & 2 deletions pinax/eventlog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django.db.models.deletion
import jsonfield.fields
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models

import jsonfield.fields


class Migration(migrations.Migration):
Expand Down
4 changes: 2 additions & 2 deletions pinax/eventlog/migrations/0002_auto_20150113_1450.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand All @@ -15,7 +15,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='log',
name='content_type',
field=models.ForeignKey(to='contenttypes.ContentType', null=True),
field=models.ForeignKey(to='contenttypes.ContentType', null=True, on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
Expand Down
1 change: 1 addition & 0 deletions pinax/eventlog/migrations/0003_auto_20160111_0208.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import unicode_literals

from django.db import migrations

import jsonfield.fields


Expand Down
2 changes: 1 addition & 1 deletion pinax/eventlog/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def extra_data(self):

@property
def user(self):
if self.request.user.is_authenticated():
if self.request.user.is_authenticated:
return self.request.user
return None

Expand Down
9 changes: 4 additions & 5 deletions pinax/eventlog/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.conf import settings
from django.db import models
from django.utils import timezone
from django.contrib.contenttypes.fields import GenericForeignKey

from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils import timezone

import jsonfield

Expand All @@ -19,7 +18,7 @@ class Log(models.Model):
)
timestamp = models.DateTimeField(default=timezone.now, db_index=True)
action = models.CharField(max_length=50, db_index=True)
content_type = models.ForeignKey(ContentType, null=True)
content_type = models.ForeignKey(ContentType, null=True, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField(null=True)
obj = GenericForeignKey("content_type", "object_id")
extra = jsonfield.JSONField()
Expand All @@ -33,7 +32,7 @@ class Meta:


def log(user, action, extra=None, obj=None, dateof=None):
if (user is not None and not user.is_authenticated()):
if (user is not None and not user.is_authenticated):
user = None
if extra is None:
extra = {}
Expand Down
1 change: 0 additions & 1 deletion pinax/eventlog/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import django.dispatch


event_logged = django.dispatch.Signal(providing_args=["event"])
9 changes: 4 additions & 5 deletions pinax/eventlog/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from datetime import timedelta

from django.test import TestCase
from django.utils import timezone

from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.utils import timezone

from ..mixins import EventLogMixin
from ..models import log, Log
from ..models import Log, log
from ..signals import event_logged
from ..stats import used_active, stats
from ..stats import stats, used_active


class TestStats(TestCase):
Expand Down
9 changes: 0 additions & 9 deletions pinax/eventlog/tests/urls.py

This file was deleted.

1 change: 0 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
}
},
SITE_ID=1,
ROOT_URLCONF="pinax.eventlog.tests.urls",
SECRET_KEY="notasecret",
)

Expand Down

0 comments on commit c06cab0

Please sign in to comment.