'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) settings_hierarkey.add_type( RelativeDateWrapper, serialize=lambda rdw: rdw.to_string(),
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, serialize=lambda s: json.dumps(s.data), unserialize=i18n_unserialise) hierarkey.add_default("show_schedule", "True", bool) hierarkey.add_default("schedule_display", "proportional", str) hierarkey.add_default("show_featured", "pre_schedule", str) # always, never, pre-schedule hierarkey.add_default("show_widget_if_not_public", "False", bool) hierarkey.add_default("export_html_on_schedule_release", "False", bool) hierarkey.add_default("imprint_url", None, str) hierarkey.add_default("html_export_url", "", str) hierarkey.add_default("custom_domain", "", str) hierarkey.add_default("use_tracks", "True", bool) hierarkey.add_default("present_multiple_times", "False", bool) hierarkey.add_default("display_header_pattern", "", str) hierarkey.add_default("cfp_flow", "", str)
('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) settings_hierarkey.add_type(RelativeDateWrapper, serialize=lambda rdw: rdw.to_string(), unserialize=lambda s: RelativeDateWrapper.from_string(s))
return instance_identifier def i18n_unserialise(value): try: return LazyI18nString(json.loads(value)) except ValueError: return LazyI18nString(str(value)) hierarkey.add_type( LazyI18nString, serialize=lambda s: json.dumps(s.data), unserialize=i18n_unserialise ) hierarkey.add_default('show_on_dashboard', 'True', bool) hierarkey.add_default('show_schedule', 'True', bool) hierarkey.add_default('show_sneak_peek', 'True', bool) hierarkey.add_default('export_html_on_schedule_release', 'False', bool) hierarkey.add_default('custom_domain', '', str) hierarkey.add_default('use_tracks', 'False', bool) hierarkey.add_default('display_header_pattern', '', str) hierarkey.add_default('cfp_request_abstract', 'True', bool) hierarkey.add_default('cfp_request_description', 'True', bool) hierarkey.add_default('cfp_request_biography', 'True', bool) hierarkey.add_default('cfp_request_availabilities', 'True', bool) hierarkey.add_default('cfp_request_notes', 'True', bool) hierarkey.add_default('cfp_request_do_not_record', 'True', bool) hierarkey.add_default('cfp_request_image', 'True', bool)
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}.