def test_create_new_section(self): template = util.insert_new_template() section = {'type': 'text', 'title': 'foobar'} new_section_id = sc.create_new_section(section, template.id) # assert this is the first new section self.assertEquals(new_section_id, 1) # assert that the title and type were passed properly self.assertEquals(TemplateSection.query.get(new_section_id).__class__.__name__, 'TextSection') self.assertEquals(TemplateSection.query.get(new_section_id).title, 'foobar')
def new_section(template_id, section_type=None): new_section = { 'type': section_type, 'title': request.args.get('section_title', '') } if request.args.get('boilerplate', False): new_section['html'] = html_boilerplate.get( request.args.get('boilerplate'), 'Please insert your text here.' ) new_section_id = sc.create_new_section(new_section, template_id) if new_section_id: return redirect( url_for('builder.edit_template', template_id=template_id, section_id=new_section_id) ) return abort(403)
def new_section(template_id, section_type=None): new_section = { 'type': section_type, 'title': request.args.get('section_title', '') } if request.args.get('boilerplate', False): new_section['html'] = html_boilerplate.get( request.args.get('boilerplate'), 'Please insert your text here.') new_section_id = sc.create_new_section(new_section, template_id) if new_section_id: return redirect( url_for('builder.edit_template', template_id=template_id, section_id=new_section_id)) return abort(403)