Example #1
0
class Timeline(Template):
    id = 'timeline'
    name = 'Timeline'

    instruction = (
        '<p>To add this article to a timeline, you must include the relevant timeline'
        '<b style="font-weight: bold;">Tag</b> in the <b style="font-weight: bold;">Basic fields</b> tab. </p>'
        '<p>If creating a new timeline, timeline tags must be prefixed with <b style="font-weight: bold;">"timeline-"</b>'
        'and followed by the timeline title with each word separated by hyphen e.g. '
        '<b style="font-weight: bold;">"timeline-The-Galloway-Case"</b>.</p>')
    INSTRUCTIONS = (('instruction', instruction))

    IMAGE_SIZE_OPTIONS = (('default', 'Default'), ('full', 'Full'))

    HEADER_LAYOUT_OPTIONS = (('right-image', 'Right Image'),
                             ('top-image', 'Top Image'), ('banner-image',
                                                          'Banner Image'))

    instructions = InstructionField('Instructions', options=INSTRUCTIONS)
    image_size = SelectField('Image Size', options=IMAGE_SIZE_OPTIONS)
    header_layout = SelectField('Header Layout',
                                options=HEADER_LAYOUT_OPTIONS,
                                required=True)
    description = TextField('Description', required=True)
    timeline_date = DateTimeField('Timeline Date', required=True)
Example #2
0
class Magazine(Template):
    id = 'magazine'
    name = 'Magazine - Article'

    COLOR_OPTIONS = (('green', 'Green'), ('pink', 'Pink'), ('blue', 'Blue'))

    DISPLAY_OPTIONS = (('default', 'Default'), ('basic', 'Basic'))

    byline = TextField('Byline')
    byline_2 = TextField('Byline 2')
    description = TextField('Description')
    color = SelectField('Accent Color', options=COLOR_OPTIONS)
    display = SelectField('Display type', options=DISPLAY_OPTIONS)
Example #3
0
class FullWidth(Template):
    id = 'fw-story'
    name = 'Full width story'

    IMAGE_SIZE_OPTIONS = (('default', 'Default'), ('full', 'Full'))

    HEADER_LAYOUT_OPTIONS = (('right-image', 'Right Image'),
                             ('top-image', 'Top Image'), ('banner-image',
                                                          'Banner Image'))

    description = TextField('Description')
    image_size = SelectField('Image Size', options=IMAGE_SIZE_OPTIONS)
    header_layout = SelectField('Header Layout', options=HEADER_LAYOUT_OPTIONS)
Example #4
0
    def test_select_field_required(self):
        """Required select fields should not accept empty values"""

        TEST_OPTIONS = [['1', 'Option 1'], ['2', 'Option 2']]

        testfield = SelectField('Test', options=TEST_OPTIONS, required=True)

        try:
            testfield.validate('')
            self.fail(
                'Empty string is not a valid option for this field, exception expected'
            )
        except InvalidField:
            pass
Example #5
0
class Default(Template):
    id = 'default'
    name = 'Default'

    IMAGE_SIZE_OPTIONS = (('default', 'Default'), ('full', 'Full'))

    image_size = SelectField('Image Size', options=IMAGE_SIZE_OPTIONS)
Example #6
0
    def test_select_field_empty(self):
        """Empty select fields cannot be required fields"""

        try:
            testfield = SelectField('Test', options=[], required=True)
            self.fail('Empty select fields cannot be required fields')
        except InvalidField:
            pass
Example #7
0
    def test_select_field_optional(self):
        """Optional select field should accept empty values"""

        TEST_OPTIONS = [['1', 'Option 1'], ['2', 'Option 2']]

        testfield = SelectField('Test', options=TEST_OPTIONS, required=False)

        try:
            testfield.validate('')
        except InvalidField:
            self.fail('Empty values are valid for optional select fields')

        try:
            testfield.validate(None)
        except InvalidField:
            self.fail('Empty values are valid for optional select fields')
Example #8
0
    def test_select_field(self):
        """Should be able to initialize select field and set data"""

        TEST_OPTIONS = [['1', 'Option 1'], ['2', 'Option 2']]

        testfield = SelectField('Test', options=TEST_OPTIONS)

        try:
            testfield.validate('2')
        except InvalidField:
            self.fail('"2" is a valid option for this field')

        try:
            testfield.validate('3')
            self.fail(
                '"3" is not a valid option for this field, exception expected')
        except InvalidField:
            pass