You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.1 KiB

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django import forms
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from aldryn_apphooks_config.utils import setup_config
from aldryn_apphooks_config.models import AppHookConfig
from app_data import AppDataForm
from parler.models import TranslatableModel
from parler.models import TranslatedFields
from cms.models.fields import PlaceholderField
class ServiceConfig(TranslatableModel, AppHookConfig):
"""Adds some translatable, per-app-instance fields."""
translations = TranslatedFields(
app_title=models.CharField(_('application title'), max_length=234),
)
category_slug = models.CharField(
_('Category slug'),
blank=True,
max_length=255,
help_text=_('Only category to display'))
placeholder_base_top = PlaceholderField(
'service_base_top',
related_name='service_base_top',
)
placeholder_base_sidebar = PlaceholderField(
'service_base_sidebar',
related_name='service_base_sidebar',
)
placeholder_list_top = PlaceholderField(
'service_list_top',
related_name='service_list_top',
)
placeholder_list_footer = PlaceholderField(
'service_list_footer',
related_name='service_list_footer',
)
placeholder_detail_top = PlaceholderField(
'service_detail_top',
related_name='service_detail_top',
)
placeholder_detail_bottom = PlaceholderField(
'service_detail_bottom',
related_name='service_detail_bottom',
)
placeholder_detail_footer = PlaceholderField(
'service_detail_footer',
related_name='service_detail_footer',
)
def get_app_title(self):
return getattr(self, 'app_title', _('untitled'))
class SeviceConfigForm(AppDataForm):
default_published = forms.BooleanField(
label=_(u'Post published by default'), required=False,
initial=getattr(settings, 'service_DEFAULT_PUBLISHED', True))
setup_config(ServiceConfigForm, ServiceConfig)