def __init__(self, view, address): super().__init__(view, 'edit_form') grouped_inputs = self.add_child(FieldSet(view, legend_text='Edit address')) grouped_inputs.use_layout(FormLayout()) grouped_inputs.layout.add_input(TextInput(self, address.fields.name)) grouped_inputs.layout.add_input(TextInput(self, address.fields.email_address)) grouped_inputs.add_child(Button(self, address.events.update, style='primary'))
def __init__(self, view): super().__init__(view, 'add_form') new_address = Address() grouped_inputs = self.add_child(FieldSet(view, legend_text='Add an address')) grouped_inputs.use_layout(FormLayout()) grouped_inputs.layout.add_input(TextInput(self, new_address.fields.name)) grouped_inputs.layout.add_input(TextInput(self, new_address.fields.email_address)) grouped_inputs.add_child(Button(self, new_address.events.save, style='primary'))
def __init__(self, view, address): super(EditAddressForm, self).__init__(view, 'edit_form') grouped_inputs = self.add_child(FieldSet(view, legend_text='Edit address')) grouped_inputs.use_layout(FormLayout()) grouped_inputs.layout.add_input(TextInput(self, address.fields.name)) grouped_inputs.layout.add_input(TextInput(self, address.fields.email_address)) btn = grouped_inputs.add_child(Button(self, address.events.update.with_arguments(address_book_id=address.address_book.id))) btn.use_layout(ButtonLayout(style='primary'))
def __init__(self, view, address_book): super(AddAddressForm, self).__init__(view, 'add_form') new_address = Address(address_book=address_book) grouped_inputs = self.add_child(FieldSet(view, legend_text='Add an address')) grouped_inputs.use_layout(FormLayout()) grouped_inputs.layout.add_input(TextInput(self, new_address.fields.name)) grouped_inputs.layout.add_input(TextInput(self, new_address.fields.email_address)) btn = grouped_inputs.add_child(Button(self, new_address.events.save.with_arguments(address_book_id=address_book.id))) btn.use_layout(ButtonLayout(style='primary'))
def __init__(self, view, account_management_interface): super(ResetPasswordForm, self).__init__(view, 'reset_password') if self.exception: self.add_child(Alert(view, self.exception.as_user_message(), 'warning')) inputs = self.add_child(FieldSet(view, legend_text=_('Request a secret key'))).use_layout(FormLayout()) inputs.layout.add_input(TextInput(self, account_management_interface.fields.email)) actions = self.add_child(ActionButtonGroup(view)) btn = actions.add_child(Button(self, account_management_interface.events.reset_password_event)) btn.use_layout(ButtonLayout(style='primary'))
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'))) grouped_inputs.use_layout(FormLayout()) grouped_inputs.layout.add_input(TextInput(self, new_address.fields.name)) grouped_inputs.layout.add_input(TextInput(self, new_address.fields.email_address)) self.define_event_handler(new_address.events.save) btn = grouped_inputs.add_child(Button(self, new_address.events.save)) btn.use_layout(ButtonLayout(style='primary'))
def __init__(self, view, account_management_interface): super(RegisterHelpForm, self).__init__(view, 'register_help') if self.exception: self.add_child(Alert(view, self.exception.as_user_message(), 'warning')) inputs = self.add_child(FieldSet(view, legend_text=_('Please supply the email address you tried to register with.'))).use_layout(FormLayout()) inputs.layout.add_input(TextInput(self, account_management_interface.fields.email), help_text=_('Please supply the email address you tried to register with.')) actions = self.add_child(ActionButtonGroup(view)) btn = actions.add_child(Button(self, account_management_interface.events.investigate_event)) btn.use_layout(ButtonLayout(style='primary'))
def __init__(self, view, address_book): super().__init__(view, 'add_collaborator_form') grouped_inputs = self.add_child( FieldSet(view, legend_text='Add a collaborator')) grouped_inputs.use_layout(FormLayout()) grouped_inputs.layout.add_input( SelectInput(self, address_book.fields.chosen_collaborator)) rights_inputs = grouped_inputs.add_child( FieldSet(view, legend_text='Rights')) rights_inputs.use_layout(FormLayout()) rights_inputs.layout.add_input( CheckboxInput(self, address_book.fields.may_edit_address)) rights_inputs.layout.add_input( CheckboxInput(self, address_book.fields.may_add_address)) grouped_inputs.add_child( Button(self, address_book.events.add_collaborator.with_arguments( address_book_id=address_book.id), style='primary'))
def __init__(self, view, event_channel_name, account_management_interface): self.account_management_interface = account_management_interface super(VerifyForm, self).__init__(view, event_channel_name) if self.exception: self.add_child(Alert(view, self.exception.as_user_message(), 'warning')) identification_inputs = self.add_child(FieldSet(view, legend_text=_('Please supply the following details'))).use_layout(FormLayout()) identification_inputs.layout.add_input(TextInput(self, account_management_interface.fields.email)) identification_inputs.layout.add_input(TextInput(self, account_management_interface.fields.secret)) identification_inputs.layout.add_input(PasswordInput(self, account_management_interface.fields.password)) actions = self.add_child(ActionButtonGroup(view)) btn = actions.add_child(Button(self, account_management_interface.events.verify_event)) btn.use_layout(ButtonLayout(style='primary'))
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, 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 __init__(self, view, unique_id, funding_request, submit_event): super(FundingRequestForm, self).__init__(view, unique_id) personal_info = self.add_child( FieldSet(view, legend_text='Personal information')) personal_info.use_layout(FormLayout()) personal_info.layout.add_input( TextInput(self, funding_request.fields.name)) personal_info.layout.add_input( TextInput(self, funding_request.fields.surname)) personal_info.layout.add_input( TextInput(self, funding_request.fields.email_address)) personal_info.layout.add_input( TextInput(self, funding_request.fields.username_on_za)) personal_info.layout.add_input( TextInput(self, funding_request.fields.origin_country)) personal_info.layout.add_input( TextInput(self, funding_request.fields.resident_country)) application = self.add_child(FieldSet(view, legend_text='Application')) application.use_layout(FormLayout()) application.layout.add_input( TextInput(self, funding_request.fields.amount_requested)) application.layout.add_input( TextInput(self, funding_request.fields.budget_own_contribution)) application.layout.add_input( TextArea(self, funding_request.fields.motivation)) application.layout.add_input( MyCheckboxInput(self, funding_request.fields.willing_to_help)) budget = self.add_child(FieldSet(view, legend_text='Budget')) budget.use_layout(FormLayout()) budget.layout.add_input( TextInput(self, funding_request.fields.budget_ticket)) budget.layout.add_input( TextInput(self, funding_request.fields.budget_travel)) budget.layout.add_input( TextInput(self, funding_request.fields.budget_accommodation)) budget.layout.add_input( TextInput(self, funding_request.fields.budget_food)) budget.layout.add_input( TextInput(self, funding_request.fields.budget_transport)) budget.layout.add_input( TextInput(self, funding_request.fields.budget_other)) budget.layout.add_input( TextInput(self, funding_request.fields.budget_other_describe)) admin_inputs = self.add_child(FieldSet(view, legend_text='Admin')) admin_inputs.use_layout(FormLayout()) admin_inputs.layout.add_input( MyCheckboxInput(self, funding_request.fields.allow_user_changes)) admin_inputs.layout.add_input( TextInput(self, funding_request.fields.grant_status)) admin_inputs.layout.add_input( TextArea(self, funding_request.fields.feedback_message)) admin_inputs.layout.add_input( TextInput(self, funding_request.fields.number_talks_proposed)) admin_inputs.layout.add_input( TextInput(self, funding_request.fields.number_talks_accepted)) admin_inputs.layout.add_input( TextInput(self, funding_request.fields.number_keynote_talks)) button = self.add_child(Button(self, submit_event)) button.use_layout(ButtonLayout(style='primary'))