示例#1
0
    def setUp(self):
        super(TestAppDataAdmin, self).setUp()
        app_registry.register('publish', AppDataContainer.from_form(PublishAppForm))
        app_registry.register('rss', AppDataContainer.from_form(RSSAppForm))
        self.url =  '/admin/test_app_data/article/'
        User.objects.create_superuser('admin', '*****@*****.**', 'secret')

        self.client.login(username='******', password='******')
示例#2
0
    def setUp(self):
        super(TestAppDataAdmin, self).setUp()
        app_registry.register('publish',
                              AppDataContainer.from_form(PublishAppForm))
        app_registry.register('rss', AppDataContainer.from_form(RSSAppForm))
        self.url = '/admin/test_app_data/article/'
        User.objects.create_superuser('admin', '*****@*****.**', 'secret')

        self.client.login(username='******', password='******')
示例#3
0
文件: utils.py 项目: Venturi/oldcms
def setup_config(form_class, config_model):
    """
    Register the provided form as config form for the provided config model
    :param form_class: Form class derived from AppDataForm
    :param config_model: Model class derived from AppHookConfig
    :return:
    """
    app_registry.register('config', AppDataContainer.from_form(form_class), config_model)
示例#4
0
def setup_config(form_class, config_model):
    """
    Register the provided form as config form for the provided config model
    :param form_class: Form class derived from AppDataForm
    :param config_model: Model class derived from AppHookConfig
    :return:
    """
    app_registry.register('config', AppDataContainer.from_form(form_class),
                          config_model)
示例#5
0
def setup_config(form_class, config_model=None):
    """
    Register the provided form as config form for the provided config model

    This can be used as a decorator by adding a `model` attribute to the config form::

        @setup_config
        class ExampleConfigForm(AppDataForm):
            model = ExampleConfig

    :param form_class: Form class derived from AppDataForm
    :param config_model: Model class derived from AppHookConfig
    :return:
    """
    # allow use as a decorator
    if config_model is None:
        return setup_config(form_class, form_class.model)

    app_registry.register('config', AppDataContainer.from_form(form_class), config_model)
示例#6
0
from django import forms

from app_data import app_registry, AppDataForm, AppDataContainer

from ella.core.models import Category
from ella.core.conf import core_settings

class CategoryAppForm(AppDataForm):
    archive_template = forms.CharField(initial=core_settings.ARCHIVE_TEMPLATE, required=False)
    no_home_listings = forms.BooleanField(initial=core_settings.CATEGORY_NO_HOME_LISTINGS, required=False)
    listing_handler = forms.CharField(initial='default', required=False)
    paginate_by = forms.IntegerField(initial=core_settings.CATEGORY_LISTINGS_PAGINATE_BY, required=False)
    propagate_listings = forms.BooleanField(initial=True, required=False)

app_registry.register('ella', AppDataContainer.from_form(CategoryAppForm), Category)

示例#7
0
    alternate_registry = NamespaceRegistry()
    app_data = AppDataField(app_registry=alternate_registry)


class PublishAppForm(AppDataForm):
    publish_from = forms.DateTimeField()
    published = forms.BooleanField(required=False)
    publish_to = forms.DateTimeField(required=False)


class RSSAppForm(AppDataForm):
    title = forms.CharField(max_length=20)
    author = forms.CharField(max_length=20)
    description = forms.CharField(max_length=200)


class PersonalAppForm(AppDataForm):
    first_name = forms.CharField(max_length=20, required=False)
    last_name = forms.CharField(max_length=20, required=False)


class AlternateRegistryAppForm(AppDataForm):
    alternate_field = forms.CharField(max_length=20, required=False)


app_registry.register('publish', AppDataContainer.from_form(PublishAppForm))
app_registry.register('rss', AppDataContainer.from_form(RSSAppForm))
app_registry.register('personal', AppDataContainer.from_form(PersonalAppForm))
AlternateRegistryModel.alternate_registry.register(
    'alternate', AppDataContainer.from_form(AlternateRegistryAppForm))
示例#8
0
class Author(models.Model):
    publishable = models.ForeignKey(Publishable)
    app_data = AppDataField()

class AlternateRegistryModel(models.Model):
    alternate_registry = NamespaceRegistry()
    app_data = AppDataField(app_registry=alternate_registry)

class PublishAppForm(AppDataForm):
    publish_from = forms.DateTimeField()
    published = forms.BooleanField(required=False)
    publish_to = forms.DateTimeField(required=False)

class RSSAppForm(AppDataForm):
    title = forms.CharField(max_length=20)
    author = forms.CharField(max_length=20)
    description = forms.CharField(max_length=200)

class PersonalAppForm(AppDataForm):
    first_name = forms.CharField(max_length=20, required=False)
    last_name = forms.CharField(max_length=20, required=False)

class AlternateRegistryAppForm(AppDataForm):
    alternate_field = forms.CharField(max_length=20, required=False)

app_registry.register('publish', AppDataContainer.from_form(PublishAppForm))
app_registry.register('rss', AppDataContainer.from_form(RSSAppForm))
app_registry.register('personal', AppDataContainer.from_form(PersonalAppForm))
AlternateRegistryModel.alternate_registry.register(
    'alternate', AppDataContainer.from_form(AlternateRegistryAppForm))