def retrieve(self, request, pk, *args, **kwargs): """ Retrieve a core config """ group = CoreConfigGroup.get(pk) serializer = self.serializer_class(group, many=False) return Response(serializer.data)
class AnalyticsCoreConfig: GROUP_SLUG = 'analytics_core' GROUP = CoreConfigGroup(id=GROUP_SLUG, title="Analytics Website", order=1) INPUTS = [ CoreConfigInput( id=GOOGLE_ANALYTICS_TRACKING_ID, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=1, disabled=False, label="Google Analytics Tracking ID", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=GOOGLE_ANALYTICS_DOMAIN, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=2, disabled=False, label="Google Analytics Domain", placeholder='default: auto', validation=None, wrapper_class="col-12", group=GROUP_SLUG, ) ]
def list(self, request, format=None): """ List a queryset. """ groups = CoreConfigGroup.all() serializer = self.serializer_class(groups, many=True) return Response(serializer.data)
def get_object(self): obj = CoreConfigGroup.get(self.kwargs['pk']) return obj
def get_queryset(self): return CoreConfigGroup.all()
class EmailCoreConfig(AbstractCoreConfigModel): CONFIG_EMAIL_OPTION_SMTP = 'Smtp' CONFIG_EMAIL_OPTION_MAILGUN = 'Mailgun' CONFIG_EMAIL_OPTIONS = [{ 'id': CONFIG_EMAIL_OPTION_SMTP, 'name': 'Custom SMTP' }, { 'id': CONFIG_EMAIL_OPTION_MAILGUN, 'name': 'Mailgun API' }] CONFIG_SECURITY_OPTIONS = [ { 'id': 'none', 'name': 'None' }, { 'id': 'tls', 'name': 'TLS' }, { 'id': 'ssl', 'name': 'SSL' }, ] EMAIL_CONFIG_GROUP_SLUG = 'email_config' EMAIL_CONFIG_GROUP = CoreConfigGroup(id=EMAIL_CONFIG_GROUP_SLUG, title="Email", secure=True, order=5) CONFIG_EMAIL_LOGO = CoreConfigInput( id='email_logo', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=0, disabled=False, label="Email Default Logo", options=CONFIG_EMAIL_OPTIONS, placeholder="/path/to/the/logo.png", validation=None, wrapper_class="col-4", group=EMAIL_CONFIG_GROUP_SLUG, ) CONFIG_EMAIL_TYPE = CoreConfigInput( id='email_type', field_type=CoreConfigInput.FIELD_TYPE_SELECT, input_type="text", order=0, disabled=False, label="Email Type", options=CONFIG_EMAIL_OPTIONS, placeholder="Email Types", validation=None, wrapper_class="col-4", group=EMAIL_CONFIG_GROUP_SLUG, ) CONFIG_TEST_EMAIL = CoreConfigInput( id='email_test', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="email", order=0, disabled=False, label="Test Email To", options=None, placeholder="your@email_test.com", validation=None, wrapper_class="col-4", group=EMAIL_CONFIG_GROUP_SLUG, ) CONFIG_SENDER = CoreConfigInput( id='email_from', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="email", order=0, disabled=False, label="Email From", options=None, placeholder="*****@*****.**", validation=None, wrapper_class="col-6", group=EMAIL_CONFIG_GROUP_SLUG, ) CONFIG_USERNAME = CoreConfigInput( id='email_username', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=0, disabled=False, label="SMTP Username", options=None, placeholder="Username", validation=None, wrapper_class="col-6", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_SMTP] }) CONFIG_PWD = CoreConfigInput(id='email_pwd', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="password", order=0, disabled=False, label="SMTP Password", options=None, placeholder="Password", validation=None, wrapper_class="col-6", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_SMTP] }) CONFIG_HOST = CoreConfigInput(id='email_host', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=0, disabled=False, label="Host", options=None, placeholder="smtp.yourdomain.com", validation=None, wrapper_class="col-6", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_SMTP] }) CONFIG_PORT = CoreConfigInput(id='email_port', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="number", order=0, disabled=False, label="SMTP Port", options=None, placeholder="465", validation=None, wrapper_class="col-3", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_SMTP] }) CONFIG_SECURITY = CoreConfigInput( id='email_security', field_type=CoreConfigInput.FIELD_TYPE_SELECT, input_type="text", order=0, disabled=False, label="SMTP Security", options=CONFIG_SECURITY_OPTIONS, placeholder="None", validation=None, wrapper_class="col-3", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_SMTP] }) CONFIG_API_KEY = CoreConfigInput( id='email_api_key', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=0, disabled=False, label="API Key", options=None, placeholder="Api Key", validation=None, wrapper_class="col-6", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_MAILGUN] }) CONFIG_DOMAIN = CoreConfigInput(id='email_domain', field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=0, disabled=False, label="API Domain", options=None, placeholder="Api Domain", validation=None, wrapper_class="col-6", group=EMAIL_CONFIG_GROUP_SLUG, conditional={ "==": [{ 'var': CONFIG_EMAIL_TYPE.id }, CONFIG_EMAIL_OPTION_MAILGUN] }) EMAIL_CONFIG_INPUTS = [ CONFIG_EMAIL_LOGO, CONFIG_EMAIL_TYPE, CONFIG_TEST_EMAIL, CONFIG_SENDER, CONFIG_USERNAME, CONFIG_PWD, CONFIG_HOST, CONFIG_PORT, CONFIG_SECURITY, CONFIG_API_KEY, CONFIG_DOMAIN ]
STORAGE_OPTION_AZURE = 'AzureBlobStorage' STORAGE_OPTION_GOOGLE = 'GoogleStorage' STORAGE_OPTIONS = [{ 'id': '', 'name': 'File Storage' }, { 'id': STORAGE_OPTION_AZURE, 'name': 'Azure Blob Storage' }, { 'id': STORAGE_OPTION_GOOGLE, 'name': 'Goole Storage' }] MEDIA_CONFIG_GROUP_SLUG = 'media_config' MEDIA_CONFIG_GROUP = CoreConfigGroup(id=MEDIA_CONFIG_GROUP_SLUG, title="File Storage", order=10) MEDIA_CONFIGS = [ CoreConfigInput( id=CONFIG_STORAGE_CLASS, field_type=CoreConfigInput.FIELD_TYPE_SELECT, input_type="text", order=0, disabled=False, label="Storage Class", options=STORAGE_OPTIONS, placeholder="File Storage Class", validation=None, wrapper_class=None, group=MEDIA_CONFIG_GROUP_SLUG,
class CMSCoreConfig: GROUP_SLUG = 'cms_core' GROUP = CoreConfigGroup(id=GROUP_SLUG, title="Core Website", order=0) INPUTS = [ CoreConfigInput( id=CONFIG_HOME_PAGE, field_type=CoreConfigInput.FIELD_TYPE_NGSELECT, input_type="text", order=0, disabled=False, label="Home Page", select_model="Page", placeholder="Select your Default Home Page", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=DEFAULT_HEADER, field_type=CoreConfigInput.FIELD_TYPE_NGSELECT, input_type="text", order=0, disabled=False, label="Default Header ", select_model="Block", placeholder="Select your Default Header", validation=None, wrapper_class="col-6", group=GROUP_SLUG, options={'block_class': 'header'}, ), CoreConfigInput( id=DEFAULT_FOOTER, field_type=CoreConfigInput.FIELD_TYPE_NGSELECT, input_type="text", order=0, disabled=False, label="Default Footer", select_model="Block", placeholder="Select your Default Footer", validation=None, wrapper_class="col-6", options={'block_class': 'footer'}, group=GROUP_SLUG, ), CoreConfigInput( id=DEFAULT_I18N, field_type=CoreConfigInput.FIELD_TYPE_NGSELECT, input_type="text", order=0, disabled=False, label="Default Language", options=LANGUAGES, placeholder="Select your Default Website Language", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=GOOGLE_MAPS_API_KEY, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=10, disabled=False, label="Google Maps API KEY", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=DEFAULT_SITE_TITLE, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=12, disabled=False, label="Site Title", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=DEFAULT_TITLE_SEPARATOR, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=13, disabled=False, label="Site Title Separator", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=DEFAULT_TITLE_PLACEHOLDER, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=14, disabled=False, label="Site Title Placeholder", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=FAVICON, field_type=CoreConfigInput.FIELD_TYPE_TEXT, input_type="text", order=15, disabled=False, label="Favicon", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=THEME_STYLE_VARS, field_type=CoreConfigInput.FIELD_TYPE_CODE_EDITOR, options={'language': 'css'}, input_type="text", order=20, disabled=False, label="Theme Style Vars", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=CUSTOM_STYLE, field_type=CoreConfigInput.FIELD_TYPE_CODE_EDITOR, options={'language': 'css'}, input_type="text", order=25, disabled=False, label="Custom Style", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ), CoreConfigInput( id=CUSTOM_SCRIPT, field_type=CoreConfigInput.FIELD_TYPE_CODE_EDITOR, options={'language': 'javascript'}, input_type="text", order=28, disabled=False, label="Custom Script", validation=None, wrapper_class="col-12", group=GROUP_SLUG, ) ]