예제 #1
0
    def __init__(self, view):
        super().__init__(view)

        self.add_child(
            Alert(view, 'This is an alert in danger color', severity='danger'))
        self.add_child(
            Alert(view,
                  'This is an alert in primary color',
                  severity='primary'))
        self.add_child(A(view, Url('#'),
                         description='Link styled as button')).use_layout(
                             ButtonLayout(style='primary'))
예제 #2
0
파일: accounts.py 프로젝트: xmonader/reahl
    def __init__(self, view, account_management_interface):
        self.account_management_interface = account_management_interface
        super().__init__(view, 'choose_password')

        if self.exception:
            self.add_child(
                Alert(view, self.exception.as_user_message(), 'warning'))

        inputs = self.add_child(
            FieldSet(view, legend_text=_('Choose a new password'))).use_layout(
                FormLayout())
        inputs.layout.add_input(
            TextInput(self, account_management_interface.fields.email))
        inputs.layout.add_input(
            TextInput(self, account_management_interface.fields.secret))
        inputs.layout.add_input(
            PasswordInput(self, account_management_interface.fields.password))
        inputs.layout.add_input(
            PasswordInput(self,
                          account_management_interface.fields.repeat_password))

        actions = self.add_child(ActionButtonGroup(view))
        btn = actions.add_child(
            Button(self,
                   account_management_interface.events.choose_password_event))
        btn.use_layout(ButtonLayout(style='primary'))
예제 #3
0
    def add_alert_for_domain_exception(self,
                                       exception,
                                       form=None,
                                       unique_name='',
                                       severity='danger'):
        """Adds a formatted error message to the Form.

           :param exception: The Exception that should be displayed.
           :keyword form: The Form to which this exception relates (default is this Layout's .widget).
           :keyword unique_name: If more than one alert is added to the same Form, unique_name distinguishes between them.
           :keyword severity: (See :class:`~reahl.web.bootstrap.ui.Alert`).

           .. versionadded:: 5.0
        """
        form = form or self.widget
        alert = self.widget.add_child(
            Alert(self.widget.view, exception.as_user_message(), severity))
        alert.add_child(Hr(self.widget.view))
        if exception.detail_messages:
            ul = alert.add_child(Ul(self.widget.view))
            for detail_message in exception.detail_messages:
                ul.add_child(Li(self.widget.view)).add_child(
                    TextNode(self.widget.view, detail_message))

        reset_form = alert.add_child(
            NestedForm(self.widget.view,
                       'reset_%s%s' % (form.channel_name, unique_name)))
        reset_form.form.define_event_handler(form.events.reset)
        reset_form.add_child(Button(reset_form.form,
                                    form.events.reset)).use_layout(
                                        ButtonLayout(style='primary'))
예제 #4
0
파일: accounts.py 프로젝트: xmonader/reahl
    def __init__(self, view, event_channel_name, account_management_interface):
        self.account_management_interface = account_management_interface
        super().__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'))
예제 #5
0
파일: page.py 프로젝트: smohaorg/reahl
 def __init__(self, view):
     super().__init__(view)
     alert = self.add_child(Alert(view, _('An error occurred:'), 'danger'))
     alert.add_child(HTMLElement(view, 'hr'))
     alert.add_child(P(view, text=self.error_message))
     a = alert.add_child(A(view, Url(self.error_source_href), description='Ok'))
     a.use_layout(ButtonLayout(style='primary'))
예제 #6
0
def test_alerts(web_fixture):
    """An alert is used to display a message with a specific severity"""

    alert = Alert(web_fixture.view, 'Be careful', 'danger')

    assert alert.get_attribute('class') == 'alert alert-danger'
    assert alert.get_attribute('role') == 'alert'
    [message] = alert.children
    assert message.value == 'Be careful'
예제 #7
0
파일: accounts.py 프로젝트: dli7428/reahl
    def __init__(self, view):
        super(RegistrationPendingForm, self).__init__(view, 'register_pending')

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))
        
        actions = self.add_child(ActionButtonGroup(view, legend_text=_('Re-send registration email')))
        btn = actions.add_child(Button(self, self.user_interface.account_management_interface.events.resend_event))
        btn.use_layout(ButtonLayout(style='primary'))
예제 #8
0
def alerts(fixture):
    """An alert is used to display a message with a specific severity"""

    alert = Alert(fixture.view, 'Be careful', 'danger')

    vassert( alert.get_attribute('class') == 'alert alert-danger' )
    vassert( alert.get_attribute('role') == 'alert' )
    [message] = alert.children
    vassert( message.value == 'Be careful' )
예제 #9
0
def test_alert_with_widget_as_message(web_fixture):
    """An alert can also be constructed with a widget as message"""

    widget_contained_in_alert = P(web_fixture.view,
                                  text='Consider yourself warned')
    alert = Alert(web_fixture.view, widget_contained_in_alert, 'warning')

    [paragraph] = alert.children
    [message] = paragraph.children
    assert message.value == 'Consider yourself warned'
예제 #10
0
파일: accounts.py 프로젝트: dli7428/reahl
    def __init__(self, view, event_channel_name, bookmarks, account_management_interface):
        super(RegisterForm, self).__init__(view, event_channel_name)
        self.bookmarks = bookmarks
        self.account_management_interface = account_management_interface

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))

        self.create_identification_inputs()
        self.create_terms_inputs()
        self.create_action_buttons()
예제 #11
0
파일: accounts.py 프로젝트: dli7428/reahl
    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'))
예제 #12
0
    def __init__(self, view, accounts):
        super(LoginForm, self).__init__(view, 'login')
        self.use_layout(FormLayout())

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))

        self.layout.add_input(TextInput(self, accounts.fields.email))
        self.layout.add_input(PasswordInput(self, accounts.fields.password))

        self.define_event_handler(accounts.events.login_event)
        btn = self.add_child(Button(self, accounts.events.login_event))
        btn.use_layout(ButtonLayout(style='primary'))
예제 #13
0
파일: accounts.py 프로젝트: dli7428/reahl
    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'))
예제 #14
0
    def __init__(self, view, login_session):
        super().__init__(view, 'login')
        self.use_layout(FormLayout())
        if self.exception:
            self.add_child(
                Alert(view, self.exception.as_user_message(), 'warning'))

        self.layout.add_input(
            TextInput(self, login_session.fields.email_address))
        self.layout.add_input(
            PasswordInput(self, login_session.fields.password))

        self.define_event_handler(login_session.events.log_in)
        btn = self.add_child(Button(self, login_session.events.log_in))
        btn.use_layout(ButtonLayout(style='primary'))
예제 #15
0
파일: accounts.py 프로젝트: smohaorg/reahl
    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'))
예제 #16
0
    def add_allocation_controls(self):
        allocation_controls = self.add_child(
            FieldSet(self.view, legend_text='Investment allocation'))
        allocation_controls.use_layout(FormLayout())

        if self.exception:
            self.add_child(Alert(self.view, str(self.exception), 'warning'))

        total_amount_input = TextInput(self,
                                       self.investment_order.fields.amount,
                                       refresh_widget=self)
        allocation_controls.layout.add_input(total_amount_input)

        amount_or_percentage_radio = RadioButtonSelectInput(
            self,
            self.investment_order.fields.amount_or_percentage,
            refresh_widget=self)
        allocation_controls.layout.add_input(amount_or_percentage_radio)