Skip to content

Commit

Permalink
Merge pull request #9 from FundersClub/django2
Browse files Browse the repository at this point in the history
Django2
  • Loading branch information
eranrund authored Dec 21, 2017
2 parents 23cb98c + eaa48d0 commit e9550da
Show file tree
Hide file tree
Showing 24 changed files with 241 additions and 26 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
Version 1.1.7
------------------------
* Experimental Django2.0 support
* Dropped support for Django 1.7, 1.8, 1.9, Python 3.3, Python 3.4


Version 1.1.6
------------------------
* Gracefully handle models not registered in admin when rendering papertrail entry admin pages.


Version 1.1.5
------------------------
* Update the `message` field to be a TextField.


Version 1.1.4
------------------------
* Django 1.10 and 1.11 support.
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies:
override:
- pip install tox tox-pyenv
- pyenv local 2.7.9 3.2.5 3.3.3 3.4.0 3.5.0
- pyenv local 2.7.11 3.5.3 3.6.2

test:
override:
Expand Down
2 changes: 1 addition & 1 deletion papertrail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.1.6'
__version__ = '1.1.7'
default_app_config = 'papertrail.apps.PapertrailConfig'
6 changes: 5 additions & 1 deletion papertrail/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.conf.urls import url
from django.contrib import admin
from django.core import serializers
from django.core.urlresolvers import NoReverseMatch, reverse
from django.db.models import Q
from django.shortcuts import get_object_or_404, render
from django.utils.encoding import force_text
Expand All @@ -16,6 +15,11 @@
import papertrail
from papertrail.models import Entry, EntryRelatedObject

try:
from django.core.urlresolvers import NoReverseMatch, reverse
except ImportError:
from django.urls import NoReverseMatch, reverse


def admin_reverse_for_model(model):
return reverse('admin:{}_{}_change'.format(model._meta.app_label, model._meta.model_name), args=[model.id])
Expand Down
4 changes: 2 additions & 2 deletions papertrail/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('relation_name', models.CharField(max_length=100, db_index=True)),
('related_id', models.PositiveIntegerField(db_index=True)),
('entry', models.ForeignKey(related_name='targets', to='papertrail.Entry')),
('related_content_type', models.ForeignKey(to='contenttypes.ContentType')),
('entry', models.ForeignKey(related_name='targets', to='papertrail.Entry', on_delete=models.CASCADE)),
('related_content_type', models.ForeignKey(to='contenttypes.ContentType', on_delete=models.CASCADE)),
],
options={
},
Expand Down
4 changes: 2 additions & 2 deletions papertrail/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def targets_model(self):

class RelatedObject(models.Model):
relation_name = models.CharField(max_length=100, db_index=True)
related_content_type = models.ForeignKey(ContentType)
related_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
related_id = models.PositiveIntegerField(db_index=True)
related_object = GenericForeignKey('related_content_type', 'related_id')

Expand All @@ -250,7 +250,7 @@ def safe_related_object(self):


class EntryRelatedObject(RelatedObject):
entry = models.ForeignKey('Entry', related_name='targets')
entry = models.ForeignKey('Entry', related_name='targets', on_delete=models.CASCADE)
owner_field_name = 'entry'


Expand Down
7 changes: 6 additions & 1 deletion papertrail/templatetags/papertrail.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from django import template
from django.core.urlresolvers import NoReverseMatch, reverse
from django.db import models

try:
from django.core.urlresolvers import NoReverseMatch, reverse
except ImportError:
from django.urls import NoReverseMatch, reverse


register = template.Library()


Expand Down
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

setup(
name='django-papertrail',
version='1.1.6',
version='1.1.7',
packages=['papertrail'],
install_requires=[
'Django>=1.7',
'Django>=1.10,<2.0;python_version<"3.0"',
'Django>=1.10;python_version>"3.0"',
'six',
'django-apptemplates',
],
Expand All @@ -27,21 +28,18 @@
'Environment :: Web Environment',
'Development Status :: 5 - Production/Stable',
'Framework :: Django',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.00',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Database',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
Expand Down
15 changes: 15 additions & 0 deletions test_site/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_site.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
1 change: 1 addition & 0 deletions test_site/papertrail
Empty file added test_site/test_app/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions test_site/test_app/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions test_site/test_app/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class TestAppConfig(AppConfig):
name = 'test_app'
Empty file.
3 changes: 3 additions & 0 deletions test_site/test_app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions test_site/test_app/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions test_site/test_app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from . import views

urlpatterns = [
path('', views.index, name='index'),
]
18 changes: 18 additions & 0 deletions test_site/test_app/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import papertrail

from django.http import HttpResponse
from django.utils import timezone


def index(request):
papertrail.log(
'hello-world',
'Hi!',
targets={
'user': request.user if request.user.is_authenticated else None,
},
data={
'now': timezone.now(),
},
)
return HttpResponse("Hello, world.")
Empty file added test_site/test_site/__init__.py
Empty file.
126 changes: 126 additions & 0 deletions test_site/test_site/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""
Django settings for test_site project.
Generated by 'django-admin startproject' using Django 2.0.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0%te(_0m&$gr#4#1_&2_%d_mc2+-t11s*&1w-dk_cg-zo1_zqp'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'test_app',
'papertrail',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'test_site.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'test_site.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'papertrail-test',
'USER': '',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '5432',
}
}


# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/'
7 changes: 7 additions & 0 deletions test_site/test_site/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('', include('test_app.urls')),
path('admin/', admin.site.urls),
]
16 changes: 16 additions & 0 deletions test_site/test_site/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for test_site project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_site.settings")

application = get_wsgi_application()
4 changes: 2 additions & 2 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.conf.urls import include, url
from django.conf.urls import url
from django.contrib import admin

admin.autodiscover()

app_name = 'tests'
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
]
14 changes: 5 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
[tox]
envlist =
py{27,33,34}-django{17,18},
py{27,34,35}-django19,
py{27,35}-django110,
py{27,35}-django111,
py{27,35,36}-django110,
py{27,35,36}-django111,
py36-django200,
flake8,
isort

[testenv]
basepython =
py27: python2.7
py33: python3.3
py34: python3.4
py35: python3.5
py36: python3.6
commands = make test
deps =
psycopg2
django-jsonfield
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django11: Django>=1.11,<1.12
django200: Django>=2.0,<2.1
setenv =
PYTHONPATH = {toxinidir}
whitelist_externals = make
Expand Down

0 comments on commit e9550da

Please sign in to comment.