Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper.attrs = {'data_abide': ''}
        self.helper.form_action = '.'

        part1 = [_('Part 1')] + part_1_crispies(pack=self.helper.template_pack)
        part2 = [_('Part 2')] + part_2_crispies(pack=self.helper.template_pack)
        part3 = [_('Part 3')] + part_3_crispies(pack=self.helper.template_pack)
        part4 = [_('Part 4')] + part_4_crispies(pack=self.helper.template_pack)

        self.helper.layout = Layout(
            AccordionHolder(
                AccordionItem(*part1),
                AccordionItem(*part2),
                AccordionItem(*part3),
                AccordionItem(*part4),
            ), *buttons_crispies(pack=self.helper.template_pack))
def test_accordion(output_test_path, render_output, rendered_template, helper,
                   client):
    form = AdvancedForm()
    pack = helper.template_pack

    # Define 'css_id' to avoid test fails with automatic generated random ID
    helper.layout = Layout(
        AccordionHolder(AccordionItem('Group 1', 'simple'),
                        AccordionItem('Group 2', 'opt_in'),
                        AccordionItem('Group 3', 'longtext'),
                        css_id="meep-meep"))

    rendered = rendered_template(form, helper=helper)

    attempted = render_output(
        os.path.join(output_test_path, pack, "test_accordion.html"))
    #write_output(output_test_path, pack, "test_accordion.html", rendered)

    assert parse_html(attempted) == parse_html(rendered)
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     self.helper = FormHelper()
     self.helper.attrs = {'data_abide': ''}
     self.helper.form_action = '.'
     
     part1 = [_('Part 1')]+part_1_crispies()
     part2 = [_('Part 2')]+part_2_crispies()
     part3 = [_('Part 3')]+part_3_crispies()
     part4 = [_('Part 4')]+part_4_crispies()
     
     self.helper.layout = Layout(
         AccordionHolder(
             AccordionItem(*part1),
             AccordionItem(*part2),
             AccordionItem(*part3),
             AccordionItem(*part4),
         ),
         *buttons_crispies()
     )
     
     super(FormByAccordionsForm, self).__init__(*args, **kwargs)