def __init__(self, view): super(FormWithCueInput, self).__init__(view, 'test') self.use_layout(FormLayout()) cue_input = CueInput( TextInput(self, fixture.domain_object.fields.field), P(view, 'this is your cue')) self.layout.add_input(cue_input)
def __init__(self, view, event_channel_name, account_management_interface): super().__init__(view, event_channel_name) self.account_management_interface = account_management_interface if self.exception: self.add_child( Alert(view, self.exception.as_user_message(), 'warning')) login_inputs = self.add_child( FieldSet(view, legend_text=_('Please specify'))).use_layout(FormLayout()) email_cue = P(view, _('The email address you used to register here.')) login_inputs.layout.add_input( CueInput( TextInput(self, self.account_management_interface.fields.email), email_cue)) password_cue = P( view, _('The secret password you supplied upon registration.')) password_cue_input = CueInput( PasswordInput(self, self.account_management_interface.fields.password), password_cue) forgot_password_bookmark = self.user_interface.get_bookmark( relative_path='/resetPassword', description=_('Forgot your password?')) password_cue_input.add_child( A.from_bookmark(view, forgot_password_bookmark)) login_inputs.layout.add_input(password_cue_input) stay_cue = P(view, _('If selected, you will stay logged in for longer.')) login_inputs.layout.add_input( CueInput( CheckboxInput( self, self.account_management_interface.fields.stay_logged_in), stay_cue)) login_buttons = self.add_child(ActionButtonGroup(view)) btn = login_buttons.add_child( Button(self, account_management_interface.events.login_event, style='primary'))
def create_identification_inputs(self): identification_inputs = self.add_child(FieldSet(self.view, legend_text=_('How will you identify yourself?'))).use_layout(FormLayout()) email_cue = P(self.view, _('You identify yourself to us by your email address.' \ 'This information is not divulged to others.')) error_message=_('Sorry, you can only register once per email address and someone is ' \ 'already registered as $value. Did you perhaps register long ago?') unique_email_field = self.account_management_interface.fields.email.as_with_validation_constraint(UniqueEmailConstraint(error_message)) identification_inputs.layout.add_input(CueInput(TextInput(self, unique_email_field), email_cue)) password_cue = P(self.view, _('Upon logging in, you will be asked for your password. Your password should be a '\ 'secret, known only to yourself, and be difficult to guess.') ) identification_inputs.layout.add_input(CueInput(PasswordInput(self, self.account_management_interface.fields.password), password_cue)) repeat_password_cue = P(self.view, _('By typing the same password again you help us to make sure you did not make any typing mistakes.')) identification_inputs.layout.add_input(CueInput(PasswordInput(self, self.account_management_interface.fields.repeat_password), repeat_password_cue))
def create_terms_inputs(self): terms_inputs = self.add_child(FieldSet(self.view, legend_text=_('Terms and conditions'))).use_layout(FormLayout()) terms_prompt = P(self.view, text=_('Please read and accept our {terms}. You may also be interested ' 'to read our {privacypolicy} and our {disclaimer}.')) popup = PopupA(self.view, self.bookmarks.terms_bookmark, '#terms', close_button=False) terms_inputs.add_child(terms_prompt.format(terms=popup, privacypolicy=PopupA(self.view, self.bookmarks.privacy_bookmark, '#privacypolicy'), disclaimer=PopupA(self.view, self.bookmarks.disclaimer_bookmark, '#disclaimer'))) terms_cue = P(self.view, _('You can only register if you agree to the terms and conditions.')) accept_checkbox = CheckboxInput(self, self.account_management_interface.fields.accept_terms) terms_inputs.layout.add_input(CueInput(accept_checkbox, terms_cue)) popup.add_js_button(_('Accept'), CheckCheckboxScript(accept_checkbox), style='primary') popup.add_js_button(_('Cancel'))
def __init__(self, view, event_channel_name): super().__init__(view, event_channel_name) self.use_layout(FormLayout()) model_object = ModelObject() self.layout.add_input( TextInput(self, model_object.fields.text_input_field)) self.layout.add_input( CheckboxInput(self, model_object.fields.boolean_field)) self.layout.add_input( PasswordInput(self, model_object.fields.password_field)) self.layout.add_input( TextArea(self, model_object.fields.text_area_field, rows=5, columns=60)) self.layout.add_input( SelectInput(self, model_object.fields.choice_field)) self.layout.add_input( SelectInput(self, model_object.fields.multi_choice_field)) self.layout.add_input( CheckboxInput(self, model_object.fields.another_multi_choice_field)) self.layout.add_input( RadioButtonSelectInput(self, model_object.fields.radio_choice_field, contents_layout=ChoicesLayout(inline=True))) self.layout.add_input( TextInput(self, model_object.fields.fuzzy_date_field, fuzzy=True)) self.layout.add_input(TextInput( self, model_object.fields.text_input_without_label, placeholder=True), hide_label=True) self.layout.add_input( CueInput(TextInput(self, model_object.fields.cue_field), P(view, text='This is a cue'))) self.define_event_handler(model_object.events.do_something) self.add_child( ButtonInput(self, model_object.events.do_something, style='primary'))