1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00
Files
seahub/thirdpart/constance/models.py

25 lines
808 B
Python

from django.db.models import signals
def create_perm(app, created_models, verbosity, db, **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(
name='config',
app_label='constance',
model='config')
permission, created = Permission.objects.get_or_create(
name='Can change config',
content_type=content_type,
codename='change_config')
signals.post_syncdb.connect(create_perm, dispatch_uid="constance.create_perm")