diff --git a/.flake8 b/.flake8 index e114b8d..56a18b8 100644 --- a/.flake8 +++ b/.flake8 @@ -5,4 +5,4 @@ max-line-length = 100 # E12x continuation line indentation # E251 no spaces around keyword / parameter equals # E303 too many blank lines (3) -ignore = E12,E251,E303 +ignore = E12,E251,E303,E402,E731,E501 diff --git a/.travis.yml b/.travis.yml index 32f3fea..0bf9d23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ env: - DJANGO_VERSION=1.3 - DJANGO_VERSION=1.4 - DJANGO_VERSION=1.5 + - DJANGO_VERSION=1.6 + - DJANGO_VERSION=1.7 + - DJANGO_VERSION=1.8 install: - "pip install django==$DJANGO_VERSION --use-mirrors" - "pip install -r requirements.txt --use-mirrors" diff --git a/MANIFEST.in b/MANIFEST.in index 7c41aa8..206ee98 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,5 +5,6 @@ include LICENSE recursive-include django_settings/templates * recursive-include django_settings/templates/admin * recursive-include django_settings/templates/admin/django_settings * +recursive-include django_settings/migrations * exclude example* exclude tests* diff --git a/README.rst b/README.rst index 8e6be08..7c0a42f 100644 --- a/README.rst +++ b/README.rst @@ -20,7 +20,7 @@ Supported versions ------------------ * Python: 2.6, 2.7 (python 2.6 requires importlib) -* Django: 1.3, 1.4, 1.5 +* Django: 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 API diff --git a/django_settings/__init__.py b/django_settings/__init__.py index d5f63d0..0850601 100644 --- a/django_settings/__init__.py +++ b/django_settings/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -VERSION = '1.3.12' +VERSION = '1.3.13' __version__ = VERSION __author__ = "Kuba Janoszek" diff --git a/django_settings/admin.py b/django_settings/admin.py index fb5f1d3..3cf459a 100644 --- a/django_settings/admin.py +++ b/django_settings/admin.py @@ -6,6 +6,7 @@ from django.utils.translation import ugettext as _ from django.http import Http404, HttpResponseRedirect +import django # module local from . import models, forms, dataapi @@ -89,10 +90,11 @@ def response_add(self, request, obj, post_url_continue='../%s/'): def response_change(self, request, obj): response = super(SettingAdmin, self).response_change(request, obj) app_label = obj._meta.app_label - module_name = obj._meta.module_name + module_model = obj._meta.module_name if django.VERSION < (1, 5) else obj._meta.model_name + module_name = module_model if '_addanother' in request.POST: - url_name = 'admin:%s_%s_add' % (app_label, module_name) + url_name = 'admin:%s_%s_add' % (app_label, module_model) url = reverse(url_name, current_app=self.admin_site.name) typename = self.get_setting_model(obj, request).__name__ return self._response_url(url, typename) diff --git a/django_settings/migrations/0001_initial.py b/django_settings/migrations/0001_initial.py new file mode 100644 index 0000000..0981a67 --- /dev/null +++ b/django_settings/migrations/0001_initial.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ] + + operations = [ + migrations.CreateModel( + name='Email', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('value', models.EmailField(max_length=254)), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Integer', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('value', models.IntegerField()), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='PositiveInteger', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('value', models.PositiveIntegerField()), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Setting', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('setting_id', models.PositiveIntegerField()), + ('name', models.CharField(unique=True, max_length=255)), + ('setting_type', models.ForeignKey(to='contenttypes.ContentType')), + ], + options={ + 'verbose_name': 'Setting', + 'verbose_name_plural': 'Settings', + }, + ), + migrations.CreateModel( + name='String', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('value', models.CharField(max_length=254)), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/django_settings/migrations/__init__.py b/django_settings/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_settings/models.py b/django_settings/models.py index f45f15e..94ae0e0 100644 --- a/django_settings/models.py +++ b/django_settings/models.py @@ -2,7 +2,11 @@ # framework from django.db import models from django.contrib.contenttypes.models import ContentType -from django.contrib.contenttypes import generic +import django +if django.VERSION >= (1, 8): + from django.contrib.contenttypes import fields as generic_fields +else: + from django.contrib.contenttypes import generic as generic_fields from django.utils.translation import ugettext_lazy as _ from django.dispatch import receiver from django.db.models.signals import post_syncdb @@ -59,7 +63,7 @@ class Meta: setting_type = models.ForeignKey(ContentType) setting_id = models.PositiveIntegerField() - setting_object = generic.GenericForeignKey('setting_type', 'setting_id') + setting_object = generic_fields.GenericForeignKey('setting_type', 'setting_id') name = models.CharField(max_length=255, unique=conf.DJANGO_SETTINGS_UNIQUE_NAMES) diff --git a/django_settings/templatetags/settings_admin_urls.py b/django_settings/templatetags/settings_admin_urls.py index e76e073..cba3001 100644 --- a/django_settings/templatetags/settings_admin_urls.py +++ b/django_settings/templatetags/settings_admin_urls.py @@ -2,13 +2,16 @@ from django.core.urlresolvers import reverse from django import template +import django + register = template.Library() @register.filter def add_url_for_setting_type(admin_change_list, type_name): cl = admin_change_list - url_name = 'admin:%s_%s_%s' % (cl.opts.app_label, cl.opts.module_name, 'add') + param2 = cl.opts.module_name if django.VERSION < (1, 6) else cl.opts.model_name + url_name = 'admin:%s_%s_%s' % (cl.opts.app_label, param2, 'add') query = "typename=%(type)s%(popup)s" % dict( type=type_name, popup='_popup=1' if cl.is_popup else '', diff --git a/requirements.txt b/requirements.txt index 0a7cee5..568e1af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,10 @@ -nose==1.3.0 +argparse==1.2.1 flake8==2.0 +mccabe==0.3 +nose==1.3.0 +pep8==1.6.2 +py==1.4.26 +pyflakes==0.8.1 +tox==1.9.2 +virtualenv==12.1.1 +wsgiref==0.1.2 diff --git a/tests/test_admin/tests.py b/tests/test_admin/tests.py index 852b464..ce217ab 100644 --- a/tests/test_admin/tests.py +++ b/tests/test_admin/tests.py @@ -44,8 +44,8 @@ def test_admin_settings_list(self): def set_all_data(): for type_name, name, value in data: django_settings.set(type_name, name, value) - - self.assert_queries_count(len(data) * 4, set_all_data) + query_count = 4 if django.VERSION < (1, 6) else 6 + self.assert_queries_count(len(data) * query_count, set_all_data) # end # run request and check number of quesries diff --git a/tests/test_admin/urls.py b/tests/test_admin/urls.py index acdc5e2..5e3f5db 100644 --- a/tests/test_admin/urls.py +++ b/tests/test_admin/urls.py @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import patterns, include +import django +if django.VERSION < (1, 6): + from django.conf.urls.defaults import patterns, include +else: + from django.conf.urls import patterns, include from django.contrib import admin admin.autodiscover()