Exemplo n.º 1
0
class ModelList(ModelBlock):
    """Abstract StructBlock that can generate a list from a Django model.

    Subclasses must define a 'render' method that renders the model QuerySet
    to a string.

    For example:

        def render(self, value, context=None):
            value['objects'] = self.get_queryset(value)
            template = 'path/to/template.html'
            return render_to_string(template, value)

    """
    limit = atoms.IntegerBlock(
        default=5,
        label='Maximum items',
        min_value=0,
        help_text='Limit list to this number of items'
    )

    def __init__(self, *args, **kwargs):
        super(ModelList, self).__init__(*args, **kwargs)

    def get_limit(self, value):
        return value.get('limit')

    class Meta:
        icon = 'list-ul'
Exemplo n.º 2
0
class ConferenceRegistrationForm(AbstractFormBlock):
    heading = blocks.CharBlock(
        required=False,
        help_text=('Note: Additional form field options will appear in '
                   'Preview and Publish modes.'))
    code = blocks.CharBlock(label='GovDelivery Code')
    sessions = blocks.ListBlock(blocks.CharBlock(label='Session'),
                                label='Sessions attending')
    capacity = atoms.IntegerBlock(help_text=(
        'Enter an integer that will be the conference attendance limit.'))
    success_message = blocks.RichTextBlock(help_text=(
        'Enter a message that will be shown on successful registration.'))
    at_capacity_message = organisms.FullWidthText(help_text=(
        'Enter a message that will be shown when the event is at capacity.'))
    failure_message = blocks.CharBlock(
        help_text=('Enter a message that will be shown if the GovDelivery '
                   'subscription fails.'))

    class Meta:
        handler = 'data_research.handlers.ConferenceRegistrationHandler'
        template = '_includes/conference-registration-form.html'