mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
More test fixes.
This commit is contained in:
parent
13768bc7ae
commit
b36aaf8fa6
3 changed files with 16 additions and 12 deletions
|
|
@ -3,7 +3,7 @@ from decimal import Decimal
|
|||
import hashlib
|
||||
from operator import itemgetter
|
||||
|
||||
from django import forms
|
||||
from django import forms, VERSION
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin, messages
|
||||
from django.contrib.admin import widgets
|
||||
|
|
@ -11,8 +11,7 @@ from django.contrib.admin.options import csrf_protect_m
|
|||
from django.core.exceptions import PermissionDenied, ImproperlyConfigured
|
||||
from django.forms import fields
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response
|
||||
from django.template.context import RequestContext
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils import six
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils.formats import localize
|
||||
|
|
@ -86,6 +85,7 @@ class ConstanceForm(forms.Form):
|
|||
|
||||
|
||||
class ConstanceAdmin(admin.ModelAdmin):
|
||||
change_list_template = 'admin/constance/change_list.html'
|
||||
|
||||
def get_urls(self):
|
||||
info = self.model._meta.app_label, self.model._meta.module_name
|
||||
|
|
@ -143,10 +143,11 @@ class ConstanceAdmin(admin.ModelAdmin):
|
|||
'form_field': form[name],
|
||||
})
|
||||
context['config'].sort(key=itemgetter('name'))
|
||||
context_instance = RequestContext(request,
|
||||
current_app=self.admin_site.name)
|
||||
return render_to_response('admin/constance/change_list.html',
|
||||
context, context_instance=context_instance)
|
||||
request.current_app = self.admin_site.name
|
||||
# compatibility to be removed when 1.7 is deprecated
|
||||
extra = {'current_app': self.admin_site.name} if VERSION < (1, 8) else {}
|
||||
return TemplateResponse(request, self.change_list_template, context,
|
||||
**extra)
|
||||
|
||||
def has_add_permission(self, *args, **kwargs):
|
||||
return False
|
||||
|
|
@ -166,10 +167,12 @@ class Config(object):
|
|||
object_name = 'Config'
|
||||
model_name = module_name = 'config'
|
||||
verbose_name_plural = _('config')
|
||||
get_ordered_objects = lambda x: False
|
||||
abstract = False
|
||||
swapped = False
|
||||
|
||||
def get_ordered_objects(self):
|
||||
return False
|
||||
|
||||
def get_change_permission(self):
|
||||
return 'change_%s' % self.model_name
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.utils import six
|
||||
|
||||
from constance.admin import settings, Config
|
||||
|
||||
|
|
@ -46,8 +48,5 @@ class TestAdmin(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_str(self):
|
||||
from django.utils import six
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
ct = ContentType.objects.get(app_label='constance', model='config')
|
||||
|
||||
self.assertEqual(six.text_type(ct), 'config')
|
||||
|
|
|
|||
4
tox.ini
4
tox.ini
|
|
@ -1,7 +1,7 @@
|
|||
[tox]
|
||||
envlist =
|
||||
{py27,py33,py34,pypy}-django-{17,18},
|
||||
{py27,py34,py35,pypy}-django-{master}
|
||||
{py27,py34,py35,pypy}-django-master
|
||||
|
||||
[testenv]
|
||||
basepython =
|
||||
|
|
@ -21,3 +21,5 @@ usedevelop = true
|
|||
commands =
|
||||
coverage run {envbindir}/django-admin.py test --settings=tests.settings -v2
|
||||
coverage report
|
||||
setenv =
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
|
|
|||
Loading…
Reference in a new issue