}, 'update_check_result_warning': { 'default': 'False', 'type': bool }, 'update_check_last': { 'default': None, 'type': datetime }, 'update_check_id': { 'default': None, 'type': str } } settings_hierarkey = Hierarkey(attribute_name='settings') for k, v in DEFAULTS.items(): settings_hierarkey.add_default(k, v['default'], v['type']) def i18n_uns(v): try: return LazyI18nString(json.loads(v)) except ValueError: return LazyI18nString(str(v)) settings_hierarkey.add_type(LazyI18nString, serialize=lambda s: json.dumps(s.data), unserialize=i18n_uns)
('full_transcription', { 'fields': ( ('full_name', _('Full name'), 1), ('latin_transcription', _('Latin transcription'), 2), ), 'concatenation': lambda d: str(d.get('full_name', '')), 'sample': { 'full_name': '庄司', 'latin_transcription': 'Shōji', '_scheme': 'full_transcription', }, }), ]) settings_hierarkey = Hierarkey(attribute_name='settings') for k, v in DEFAULTS.items(): settings_hierarkey.add_default(k, v['default'], v['type']) def i18n_uns(v): try: return LazyI18nString(json.loads(v)) except ValueError: return LazyI18nString(str(v)) settings_hierarkey.add_type(LazyI18nString, serialize=lambda s: json.dumps(s.data), unserialize=i18n_uns)
import datetime as dt import json import uuid from django.utils.translation import gettext_noop from hierarkey.models import GlobalSettingsBase, Hierarkey from i18nfield.strings import LazyI18nString hierarkey = Hierarkey(attribute_name="settings") @hierarkey.set_global() class GlobalSettings(GlobalSettingsBase): def get_instance_identifier(self): instance_identifier = self.settings.get("instance_identifier") if not instance_identifier: instance_identifier = uuid.uuid4() self.settings.set("instance_identifier", str(instance_identifier)) else: instance_identifier = uuid.UUID(instance_identifier) return instance_identifier def i18n_unserialise(value): try: return LazyI18nString(json.loads(value)) except ValueError: return LazyI18nString(str(value)) hierarkey.add_type(LazyI18nString,
import json import uuid from datetime import datetime from django.utils.translation import ugettext_noop from hierarkey.models import GlobalSettingsBase, Hierarkey from i18nfield.strings import LazyI18nString hierarkey = Hierarkey(attribute_name='settings') @hierarkey.set_global() class GlobalSettings(GlobalSettingsBase): def get_instance_identifier(self): instance_identifier = self.settings.get('instance_identifier') if not instance_identifier: instance_identifier = uuid.uuid4() self.settings.set('instance_identifier', str(instance_identifier)) else: instance_identifier = uuid.UUID(instance_identifier) return instance_identifier def i18n_unserialise(value): try: return LazyI18nString(json.loads(value)) except ValueError: return LazyI18nString(str(value)) hierarkey.add_type(
}, 'update_check_result_warning': { 'default': 'False', 'type': bool }, 'update_check_last': { 'default': None, 'type': datetime }, 'update_check_id': { 'default': None, 'type': str } } settings_hierarkey = Hierarkey(attribute_name='settings') for k, v in DEFAULTS.items(): settings_hierarkey.add_default(k, v['default'], v['type']) def i18n_uns(v): try: return LazyI18nString(json.loads(v)) except ValueError: return LazyI18nString(str(v)) settings_hierarkey.add_type(LazyI18nString, serialize=lambda s: json.dumps(s.data), unserialize=i18n_uns)
from django.db import models from hierarkey.models import GlobalSettingsBase, Hierarkey from cloudlaunch import models as cl_models from djcloudbridge import models as cb_models import yaml hierarkey = Hierarkey(attribute_name='settings') @hierarkey.set_global() class GlobalSettings(GlobalSettingsBase): pass class CMCluster(models.Model): """CloudMan cluster details.""" # Automatically add timestamps when object is created added = models.DateTimeField(auto_now_add=True) # Automatically add timestamps when object is updated updated = models.DateTimeField(auto_now=True) name = models.CharField(max_length=60, unique=True) cluster_type = models.CharField(max_length=255, blank=False, null=False) autoscale = models.BooleanField( default=True, help_text="Whether autoscaling is activated") _connection_settings = models.TextField( max_length=1024 * 16, help_text="External provider specific settings " "for this cluster.", blank=True, null=True, db_column='connection_settings')
from django.utils.translation import ugettext_noop from hierarkey.models import GlobalSettingsBase, Hierarkey from i18nfield.strings import LazyI18nString settings_hierarkey = Hierarkey(attribute_name='settings') @settings_hierarkey.set_global() class GlobalSettings(GlobalSettingsBase): pass settings_hierarkey.add_default('cfp_show_settings', 'False', bool) settings_hierarkey.add_default('mail_from', '*****@*****.**', str) settings_hierarkey.add_default('smtp_use_custom', 'False', bool) settings_hierarkey.add_default('smtp_host', '', str) settings_hierarkey.add_default('smtp_port', '587', int) settings_hierarkey.add_default('smtp_username', '', str) settings_hierarkey.add_default('smtp_password', '', str) settings_hierarkey.add_default('smtp_use_tls', 'True', bool) settings_hierarkey.add_default('smtp_use_ssl', 'False', bool) settings_hierarkey.add_default( 'mail_text_reset', LazyI18nString.from_gettext( ugettext_noop("""Hello {name}, you have requested a new password for your submission account at {event}. To reset your password, click on the following link: {url}
from django.utils.translation import ugettext_noop from hierarkey.models import GlobalSettingsBase, Hierarkey from i18nfield.strings import LazyI18nString settings_hierarkey = Hierarkey(attribute_name='settings') @settings_hierarkey.set_global() class GlobalSettings(GlobalSettingsBase): pass settings_hierarkey.add_default('show_schedule', 'True', bool) settings_hierarkey.add_default('custom_domain', '', str) settings_hierarkey.add_default('allow_override_votes', 'False', bool) settings_hierarkey.add_default('review_min_score', 0, int) settings_hierarkey.add_default('review_max_score', 1, int) settings_hierarkey.add_default('mail_from', '*****@*****.**', str) settings_hierarkey.add_default('smtp_use_custom', 'False', bool) settings_hierarkey.add_default('smtp_host', '', str) settings_hierarkey.add_default('smtp_port', '587', int) settings_hierarkey.add_default('smtp_username', '', str) settings_hierarkey.add_default('smtp_password', '', str) settings_hierarkey.add_default('smtp_use_tls', 'True', bool) settings_hierarkey.add_default('smtp_use_ssl', 'False', bool) settings_hierarkey.add_default('mail_text_reset', LazyI18nString.from_gettext(ugettext_noop("""Hello {name}, you have requested a new password for your submission account at {event}.