def __init__(self, view, name): super(MyForm, self).__init__(view, name) checkbox = self.add_child( CheckboxInput(self, model_object.fields.an_attribute)) self.define_event_handler(model_object.events.an_event) self.add_child(ButtonInput(self, model_object.events.an_event)) fixture.checkbox = checkbox
def new_form(self): form = Form(self.web_fixture.view, 'some_form') event = Event(label='click me', action=Action(self.action)) event.bind('an_event', None) form.define_event_handler(event, target=self.target) form.add_child(ButtonInput(form, event)) return form
def __init__(self, view, name): super(MyForm, self).__init__(view, name) field = model_object.fields.an_attribute self.add_child( TextInput(self, model_object.fields.an_attribute)) self.define_event_handler(model_object.events.an_event) self.add_child(ButtonInput(self, model_object.events.an_event))
def __init__(self, view, name): super(MyForm, self).__init__(view, name) self.define_event_handler(self.events.an_event) self.add_child(ButtonInput(self, self.events.an_event)) self.add_child(TextInput(self, model_object1.fields.field_name)) self.add_child(TextInput(self, model_object2.fields.field_name))
def __init__(self, view, name): super(MyForm, self).__init__(view, name) self.add_child( ButtonInput( self, model_object.events.an_event.with_arguments( one_argument=1, another_argument='another')))
def __init__(self, view): super().__init__(view, 'test_events') self.add_child( ButtonInput( self, model_object.events.an_event.with_arguments(arg1='1', arg2='2')))
def __init__(self, view): super(TestPanel, self).__init__(view) form = self.add_child(Form(view, 'some_form')) form.define_event_handler(model_object.events.an_event) form.add_child(ButtonInput(form, model_object.events.an_event)) form.add_child(TextInput(form, model_object.fields.field_name)) fixture.form = form
def __init__(self, view): super().__init__(view, 'test') file_input = self.add_child(SimpleFileInput(self, domain_object.fields.file)) if file_input.validation_error: self.add_child(self.create_error_label(file_input)) self.define_event_handler(domain_object.events.upload) self.add_child(ButtonInput(self, domain_object.events.upload))
def __init__(self, view): super().__init__(view) form = self.add_child(Form(view, 'some_form')) form.define_event_handler(model_object.events.an_event) button = form.add_child(ButtonInput(form, model_object.events.an_event)) if button.validation_error: form.add_child(form.create_error_label(button)) fixture.form = form
def __init__(self, view, name): super(MyNestedForm, self).__init__(view, name) self.define_event_handler(nested_model_object.events.nested_event) self.add_child( ButtonInput(self.form, nested_model_object.events.nested_event)) self.add_child( TextInput(self.form, nested_model_object.fields.nested_field))
def __init__(self, view): super(FormWithIncorrectButtonToParameterisedView, self).__init__(view, 'test_events') self.add_child( ButtonInput( self, model_object.events.an_event.with_arguments(arg1='1', arg2='2')))
def __init__(self, view, name): super(MyForm, self).__init__(view, name) self.define_event_handler(model_object.events.an_event) self.add_child( ButtonInput( self, model_object.events.an_event.with_arguments( some_argument='f~nnystuff')))
def __init__(self, view): super(MyForm, self).__init__(view, 'myform') self.set_attribute( 'target', '_blank' ) # We want to make sure the initial page is not refreshed so we can check the button status self.define_event_handler(self.events.an_event) self.add_child(TextInput(self, self.fields.field_name)) self.add_child(ButtonInput(self, self.events.an_event))
def __init__(self, view, name, other_view): super(MyForm, self).__init__(view, name) if fixture.target_is_other_view: target = other_view else: target = view.as_factory() self.define_event_handler(model_object.events.an_event, target=target) self.add_child(ButtonInput(self, model_object.events.an_event))
def __init__(self, view): super(MyForm, self).__init__(view, 'myform') self.use_layout(FormLayout()) self.set_attribute('novalidate', 'novalidate') if self.exception: self.layout.add_alert_for_domain_exception(self.exception) self.layout.add_input( TextInput(self, fixture.model_object.fields.some_field)) self.define_event_handler(fixture.model_object.events.submit) self.add_child( ButtonInput(self, fixture.model_object.events.submit)) self.define_event_handler( fixture.model_object.events.submit_break) self.add_child( ButtonInput(self, fixture.model_object.events.submit_break))
def __init__(self, view, name, other_view): super(MyForm, self).__init__(view, name) self.define_event_handler(model_object.events.an_event, target=other_view) self.add_child(ButtonInput(self, model_object.events.an_event)) text_input = self.add_child( TextInput(self, model_object.fields.field_name)) if text_input.validation_error: self.add_child(self.create_error_label(text_input))
def __init__(self, view, name): super().__init__(view, name) checkbox = self.add_child( input_widget_class( self, fixture.model_object.fields.an_attribute)) self.define_event_handler(fixture.model_object.events.an_event) self.add_child( ButtonInput(self, fixture.model_object.events.an_event)) fixture.checkbox = checkbox
def __init__(self, view): super().__init__(view, css_id='sedrick') self.enable_refresh() self.add_child(P(self.view, text='My state is now %s' % self.fancy_state)) if self.fancy_state == 2: form = self.add_child(NestedForm(view, 'nestedform')) form.define_event_handler(self.events.submit) form.add_child(ButtonInput(form.form, self.events.submit)) fixture.widget = self
def __init__(self, view, name): super().__init__(view, name) self.define_event_handler(self.events.an_event) self.add_child(ButtonInput(self, self.events.an_event)) self.add_child(TextInput(self, model_object1.fields.field_name)) self.add_child( TextInput(self, model_object2.fields.field_name, name_discriminator='2'))
def validation_of_event_arguments(fixture): """Buttons cannot be created for Events with invalid default arguments.""" class ModelObject(object): @exposed def events(self, events): events.an_event = Event(label='Click me', argument=Field(required=True)) model_object = ModelObject() form = Form(fixture.view, 'test') form.define_event_handler(model_object.events.an_event) with expected(ProgrammerError): ButtonInput(form, model_object.events.an_event) with expected(NoException): ButtonInput( form, model_object.events.an_event.with_arguments(argument='something'))
def __init__(self, view): super().__init__(view, 'myform') self.enable_refresh() self.choice = 1 self.use_layout(FormLayout()) if self.exception: self.layout.add_alert_for_domain_exception(self.exception) self.layout.add_input( SelectInput(self, self.fields.choice, refresh_widget=self)) self.define_event_handler(self.events.submit_break) self.add_child(ButtonInput(self, self.events.submit_break)) self.add_child(P(view, 'Chosen: %s' % self.choice))
def __init__(self, view, name, other_view): super().__init__(view, name) if self.exception: self.add_child( P(view, ','.join(self.exception.detail_messages))) self.define_event_handler(model_object.events.an_event, target=other_view) self.add_child(ButtonInput(self, model_object.events.an_event)) text_input = self.add_child( TextInput(self, model_object.fields.field_name)) if text_input.validation_error: self.add_child(self.create_error_label(text_input))
def __init__(self, view, an_object): super(MyForm, self).__init__(view, 'myform') self.use_layout(FormLayout()) self.an_object = an_object self.enable_refresh(on_refresh=an_object.events.choice_changed) if self.exception: self.layout.add_alert_for_domain_exception(self.exception) self.change_trigger_input = TextInput(self, an_object.fields.choice, refresh_widget=self) self.layout.add_input(self.change_trigger_input) self.add_child(P(self.view, text='My state is now %s' % an_object.choice)) fixture.add_to_form(self, an_object) self.define_event_handler(an_object.events.submit) self.add_child(ButtonInput(self, an_object.events.submit))
def __init__(self, view): super(MyForm, self).__init__(view, 'my_form') self.define_event_handler(model_object.events.an_event) self.add_child(ButtonInput(self, model_object.events.an_event)) input = self.add_child( SelectInput(self, model_object.fields.no_validation_exception_field)) if input.validation_error: self.add_child(self.create_error_label(input)) input = self.add_child( SelectInput(self, model_object.fields.validation_exception_field)) if input.validation_error: self.add_child(self.create_error_label(input))
def __init__(self, view): super().__init__(view, 'myform') self.use_layout(FormLayout()) self.set_attribute('novalidate', 'novalidate') if self.exception: self.layout.add_alert_for_domain_exception(self.exception) self.layout.add_input( TextInput(self, fixture.model_object.fields.some_field)) self.define_event_handler(fixture.model_object.events.submit) submit_button = self.add_child( ButtonInput(self, fixture.model_object.events.submit)) submit_button.set_attribute( 'formnovalidate', 'formnovalidate' ) # TODO: the form's novalidate already does not, but somehow the browser still # validates the input and disables the button. May be because the browser # has cached javascript against our expectations because of a previous run? # We need to clear the browser's cached files before each test. self.define_event_handler( fixture.model_object.events.submit_break) self.add_child( ButtonInput(self, fixture.model_object.events.submit_break))
def __init__(self, view, an_object): super(MyForm, self).__init__(view, 'myform') self.an_object = an_object self.enable_refresh(on_refresh=an_object.events.choice_changed) if self.exception: self.add_child(P(self.view, text=str(self.exception))) self.change_trigger_input = TextInput(self, an_object.fields.choice, refresh_widget=self) self.add_child(Label(view, for_input=self.change_trigger_input)) self.add_child(self.change_trigger_input) self.add_child(P(self.view, text='My choice state is now %s' % an_object.choice)) self.change3_non_trigger_input = TextInput(self, an_object.fields.choice3) self.add_child(Label(view, for_input=self.change3_non_trigger_input)) self.add_child(self.change3_non_trigger_input) self.add_child(P(self.view, text='My calculated state is now %s' % an_object.calculated_state)) self.define_event_handler(an_object.events.submit) self.add_child(ButtonInput(self, an_object.events.submit))
def __init__(self, view): super(AddAddressForm, self).__init__(view, 'add_form') new_address = Address() grouped_inputs = self.add_child( FieldSet(view, legend_text='Add an address')) name_input = TextInput(self, new_address.fields.name) grouped_inputs.add_child(Label(view, for_input=name_input)) grouped_inputs.add_child(name_input) email_input = TextInput(self, new_address.fields.email_address) grouped_inputs.add_child(Label(view, for_input=email_input)) grouped_inputs.add_child(email_input) self.define_event_handler(new_address.events.save) grouped_inputs.add_child(ButtonInput(self, new_address.events.save))
def __init__(self, view): super(MyForm, self).__init__(view, 'myform') self.enable_refresh() if self.exception: self.add_child(P(view, text='Exception raised')) model_object = ModelObject() checkbox_input = fixture.trigger_input_type(self, model_object.fields.trigger_field, refresh_widget=self) self.add_child(Label(view, for_input=checkbox_input)) self.add_child(checkbox_input) if model_object.trigger_field: email_input = TextInput(self, model_object.fields.email) self.add_child(Label(self.view, for_input=email_input)) self.add_child(email_input) self.define_event_handler(model_object.events.an_event) self.add_child(ButtonInput(self, model_object.events.an_event))
def __init__(self, view): super().__init__(view, 'myform') self.define_event_handler(self.events.an_event) self.add_child(ButtonInput(self, self.events.an_event))
def nothing_allowed_on_button(self): self.readable = Allowed(False) self.writable = Allowed(False) self.input_widget = ButtonInput(self.form, self.event) self.expected_html = ''