mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-24 06:43:46 +00:00
Drone will now check that
from __future__ absolute_import, unicode_literals
is part of every Python source file, to ensure a consistent experience
across all versions of Python.
See #2392 for an instance where missing `unicode_literals` was causing
problems.
Add missing absolute_import, unicode_literals to all files
Explicitly ensure strings are of the correct types
Now that unicode_literals is in every file, some things that used to
be py2 `str`s were now `unicode` instead. This caused issues with
generated class / function names, which must be `str` in all versions of
Python. This means bytes in py2, and unicode in py3. A test also checked
for the incorrect type of SafeString. HTML content should always be
unicode, so this has been fixed.
28 lines
754 B
Python
28 lines
754 B
Python
from __future__ import absolute_import, unicode_literals
|
|
|
|
from django.db import models
|
|
|
|
from .registry import register_setting
|
|
|
|
__all__ = ['BaseSetting', 'register_setting']
|
|
|
|
|
|
class BaseSetting(models.Model):
|
|
"""
|
|
The abstract base model for settings. Subclasses must be registered using
|
|
:func:`~wagtail.contrib.settings.registry.register_setting`
|
|
"""
|
|
|
|
site = models.OneToOneField(
|
|
'wagtailcore.Site', unique=True, db_index=True, editable=False, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
@classmethod
|
|
def for_site(cls, site):
|
|
"""
|
|
Get an instance of this setting for the site.
|
|
"""
|
|
instance, created = cls.objects.get_or_create(site=site)
|
|
return instance
|