mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
* Add Django 1.8 to test environments in tox.ini * Update python versions supported by Django master in tox.ini * Don't load 'url' from template library 'future' - it is no longer available in Django master, and is not needed in Django 1.4 and later, which is as far back as django-constance tests * get_cache dropped from Django master * post_syncdb signal dropped * django.utils.importlib dropped There are still errors on some environments that I didn't try to address: * coverage seems broken on py32 * django-master seems currently broken on py27 (non-ASCII character somewhere, I expect django-master will be fixed soon since they still claim py27 support) * django14 seems broken: "NoReverseMatch: u"'admin" is not a registered namespace"
26 lines
882 B
Python
26 lines
882 B
Python
from django.db.models import signals
|
|
|
|
|
|
def create_perm(*args, **kwargs):
|
|
"""
|
|
Creates a fake content type and permission
|
|
to be able to check for permissions
|
|
"""
|
|
from django.contrib.auth.models import Permission
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
if ContentType._meta.installed and Permission._meta.installed:
|
|
content_type, created = ContentType.objects.get_or_create(
|
|
app_label='constance',
|
|
model='config')
|
|
|
|
permission, created = Permission.objects.get_or_create(
|
|
name='Can change config',
|
|
content_type=content_type,
|
|
codename='change_config')
|
|
|
|
|
|
if hasattr(signals, 'post_syncdb'):
|
|
signals.post_syncdb.connect(create_perm, dispatch_uid="constance.create_perm")
|
|
else:
|
|
signals.post_migrate.connect(create_perm, dispatch_uid="constance.create_perm")
|