Esempio n. 1
0
    def __init__(self, view, account_management_interface):
        super().__init__(view)
        self.add_child(
            P(view,
              text=
              _('There is no record of someone trying to register the email address "%s".'
                ) % account_management_interface.email))
        self.add_child(
            P(view,
              text=
              _('Perhaps you mistyped your email address when registering? The system also removes '
                'such a registration request if you take a long time to get around to verifying it.'
                )))

        register_bookmark = self.user_interface.get_bookmark(
            relative_path='/register')
        last_p = P(
            view,
            text=_(
                'Whatever the case, please {register} to rectify the problem.')
        )
        self.add_child(
            last_p.format(register=A.from_bookmark(
                view, register_bookmark.with_description(_(
                    'register again')))))
Esempio n. 2
0
def tabs_with_sub_options(fixture):
    """A TabbedPanel can have Tabs that are each composed of multiple sub-options."""
    fixture.request.query_string = 'tab=mult2'
    tabbed_panel = TabbedPanel(fixture.view)
    multi_tab = MultiTab(fixture.view, 'tab 1 name', 'multitab-main')
    multi_tab.add_tab(
        Tab(fixture.view, 'multi tab 1', 'mult1',
            P.factory(text='tab 1/1 content')))
    multi_tab.add_tab(
        Tab(fixture.view, 'multi tab 2', 'mult2',
            P.factory(text='tab 1/2 content')))
    tabbed_panel.add_tab(multi_tab)

    tester = WidgetTester(tabbed_panel)

    expected_html = \
     '''<ul class="nav nav-tabs reahl-menu">'''\
     '''<li class="dropdown nav-item">'''\
      '''<a data-target="-" data-toggle="dropdown" href="/?open_item=tab+1+name&amp;tab=mult2" class="active dropdown-toggle nav-link reahl-ajaxlink">tab 1 name<span class="caret"></span></a>'''\
      '''<div class="dropdown-menu">'''\
       '''<a data-target="#tab_mult1" data-toggle="tab" href="/?tab=mult1" class="dropdown-item">multi tab 1</a>'''\
       '''<a data-target="#tab_mult2" data-toggle="tab" href="/?tab=mult2" class="active dropdown-item">multi tab 2</a>'''\
      '''</div>'''\
     '''</li>'''\
    '''</ul>'''\
    '''<div class="tab-content">'''\
     '''<div id="tab_mult1" class="tab-pane"><p>tab 1/1 content</p></div>'''\
     '''<div id="tab_mult2" class="active tab-pane"><p>tab 1/2 content</p></div>'''\
    '''</div>'''

    actual = tester.render_html()
    vassert(actual == expected_html)
Esempio n. 3
0
 def __init__(self, view, account_management_interface,
              register_help_bookmark, verify_bookmark):
     super().__init__(view)
     self.add_child(P(view, text=_('You have successfully registered.')))
     self.add_child(
         P(view,
           text=
           _('Before we can allow you to log in, however, you need to prove to us that you are indeed the owner of %s.'
             ) % account_management_interface.email))
     p = P(view, text=_('In order to do this, an email was sent to {email} containing a secret code. '\
                        'Please check your email, retrieve the code and then enter it on {verify}.'))
     self.add_child(
         p.format(verify=A.from_bookmark(
             view,
             verify_bookmark.with_description(_('the verification page'))),
                  email=TextNode(view, account_management_interface.email)))
     self.add_child(
         P(view,
           text=
           _('Sometimes these emails arrive immediately, but they may also be delayed.'
             )))
     last_p = P(
         view,
         text=
         _('If you do not receive the email within an hour or so, please follow {trouble}.'
           ))
     self.add_child(
         last_p.format(trouble=A.from_bookmark(
             view,
             register_help_bookmark.with_description(
                 _('our troubleshooting procedure')))))
Esempio n. 4
0
    def assemble(self):

        home = self.define_view('/', title='Page 1')
        home.set_slot(
            'main',
            P.factory(
                text='In this slot will be some main content for the view on /'
            ))
        home.set_slot('secondary',
                      P.factory(text='Some secondary content related to /'))

        another = self.define_view('/page2', title='Page 2')
        another.set_slot(
            'main',
            P.factory(
                text=
                'This could, for example, be where a photo gallery shows a large photo.'
            ))
        another.set_slot(
            'secondary',
            P.factory(
                text='Thumbnails will then sit on the side of the big photo.'))

        bookmarks = [home.as_bookmark(self), another.as_bookmark(self)]
        self.define_page(MyCustomPage, bookmarks)
Esempio n. 5
0
    def __init__(self, view, account_management_interface):
        super().__init__(view)
        self.add_child(
            P(view,
              text=_('You are trying to register using the email address "%s"')
              % account_management_interface.email))
        self.add_child(
            P(view,
              text=
              _('That address is already registered and active on the system.'
                'This means that you (or someone else) must have registered using that email address'
                ' previously.')))

        forgot_password_bookmark = self.user_interface.get_bookmark(
            relative_path='/resetPassword')
        last_p = P(
            view,
            text=
            _('You can gain access to this account by following our {procedure}.'
              ))
        self.add_child(
            last_p.format(procedure=A.from_bookmark(
                view,
                forgot_password_bookmark.with_description(
                    _(' password reset procedure')))))
Esempio n. 6
0
def test_tabs_with_sub_options(web_fixture):
    """A TabbedPanel can have Tabs that are each composed of multiple sub-options."""

    web_fixture.request.query_string = 'tab=mult2'
    tabbed_panel = TabbedPanel(web_fixture.view)
    multi_tab = MultiTab(web_fixture.view, 'tab 1 name', 'multitab-main')
    multi_tab.add_tab(Tab(web_fixture.view, 'multi tab 1', 'mult1', P.factory(text='tab 1/1 content')))
    multi_tab.add_tab(Tab(web_fixture.view, 'multi tab 2', 'mult2', P.factory(text='tab 1/2 content')))
    tabbed_panel.add_tab(multi_tab)

    tester = WidgetTester(tabbed_panel)

    expected_html = \
     '''<ul role="tablist" class="nav nav-tabs reahl-menu">'''\
     '''<li class="dropdown nav-item">'''\
      '''<a aria-haspopup="true" data-toggle="dropdown" href="/?open_item=tab+1+name&amp;tab=mult2" role="button" class="active dropdown-toggle nav-link reahl-ajaxlink">tab 1 name</a>'''\
      '''<div class="dropdown-menu">'''\
       '''<a id="nav_tab_mult1_tab" aria-controls="tab_mult1" aria-selected="false" data-target="#tab_mult1" data-toggle="tab" href="/?tab=mult1" role="tab" class="dropdown-item">multi tab 1</a>'''\
       '''<a id="nav_tab_mult2_tab" aria-controls="tab_mult2" aria-selected="true" data-target="#tab_mult2" data-toggle="tab" href="/?tab=mult2" role="tab" class="active dropdown-item">multi tab 2</a>'''\
      '''</div>'''\
     '''</li>'''\
    '''</ul>'''\
    '''<div class="tab-content">'''\
     '''<div id="tab_mult1" aria-labelledby="nav_tab_mult1_tab" role="tabpanel" class="tab-pane"><p>tab 1/1 content</p></div>'''\
     '''<div id="tab_mult2" aria-labelledby="nav_tab_mult2_tab" role="tabpanel" class="active tab-pane"><p>tab 1/2 content</p></div>'''\
    '''</div>'''

    actual = tester.render_html()
    assert actual == expected_html
Esempio n. 7
0
    def assemble(self):
        contents_layout = ColumnLayout(
            ('main', ResponsiveSize(lg=6))).with_slots()
        page_layout = PageLayout(contents_layout=contents_layout,
                                 document_layout=Container())
        self.define_page(HTML5Page).use_layout(page_layout)

        comment = Comment()

        home = self.define_view('/', title='Page flow demo')
        home.set_slot('main', CommentForm.factory(comment))

        thanks = self.define_view('/thanks', title='Thank you!')
        thanks_text = 'Thanks for submitting your comment'
        thanks.set_slot('main', P.factory(text=thanks_text))

        none_submitted = self.define_view('/none', title='Nothing to say?')
        none_text = 'Mmm, you submitted an empty comment??'
        none_submitted.set_slot('main', P.factory(text=none_text))

        self.define_transition(comment.events.submit,
                               home,
                               thanks,
                               guard=Action(comment.contains_text))
        self.define_transition(comment.events.submit,
                               home,
                               none_submitted,
                               guard=Not(Action(comment.contains_text)))
Esempio n. 8
0
 def __init__(self, view, account_management_interface, register_help_bookmark):
     super(CongratsWidget, self).__init__(view)
     self.add_child(P(view, text=_('You have successfully registered.')))
     self.add_child(P(view, text=_('Before we can allow you to log in, however, you need to prove to us that you are indeed the owner of %s.') % account_management_interface.email))
     self.add_child(P(view, text=_('You can do that by following instructions just emailed to that address.')))
     self.add_child(P(view, text=_('Sometimes these emails arrive immediately, but they may also be delayed.')))
     last_p = P(view, text=_('If you do not receive the email within an hour or so, please follow {trouble}.'))
     self.add_child(last_p.format(trouble=A.from_bookmark(view, register_help_bookmark.with_description(_('our troubleshooting procedure')))))
Esempio n. 9
0
 def __init__(self, view):
     super().__init__(view)
     self.add_child(
         P(view, text=_('Thank you for verifying your email address.')))
     self.add_child(
         P(view,
           text=
           _('Your account is now active, and you can proceed to log in using the details you provided.'
             )))
Esempio n. 10
0
 def __init__(self, view, account_management_interface):
     super().__init__(view)
     self.add_child(
         P(view,
           text=_('A new registration email was sent to "%s"') %
           account_management_interface.email))
     self.add_child(
         P(view,
           text=
           _('Please watch your inbox and follow the instructions in the email.'
             )))
Esempio n. 11
0
    def add_two(self):
        layout = ColumnLayout(('left', ResponsiveSize(md=4)),
                              ('right', ResponsiveSize(md=8)))

        div = Div(self.view).use_layout(layout)
        self.body.add_child(div)

        div.layout.columns['left'].add_child(
            P(self.view, text='4/12ths on md and larger'))
        div.layout.columns['right'].add_child(
            P(self.view, text='8/12ths on md and larger'))
Esempio n. 12
0
    def __init__(self, view):
        super(MyPage, self).__init__(view)
        self.body.use_layout(Container())

        carousel = Carousel(view, 'my_example_carousel_id', show_indicators=True)
        self.body.add_child(carousel)

        carousel.add_slide(PlaceholderImage(view, 900, 500, text='Slide 1', alt='Slide 1 was here'),
                           caption_widget=P(view, text='a paragraph with text'))

        carousel.add_slide(PlaceholderImage(view, 900, 500, text='Slide 2', alt='Slide 2 was here'),
                           caption_widget=P(view, text='a different paragraph'))
Esempio n. 13
0
    def __init__(self, view):
        super(MyPage, self).__init__(view)

        tabbed_panel = self.body.add_child(TabbedPanel(view))

        contents1 = P.factory(text='A paragraph to give content to the first tab.')
        tabbed_panel.add_tab(Tab(view, 'Tab 1', '1', contents1))

        contents2 = P.factory(text='And another ...  to give content to the second tab.')
        tabbed_panel.add_tab(Tab(view, 'Tab 2', '2', contents2))
        
        contents3 = P.factory(text='Something else on the third tab.')
        tabbed_panel.add_tab(Tab(view, 'Tab 3', '3', contents3))
Esempio n. 14
0
            def __init__(self, view):
                super(PopulatedTabbedPanel, self).__init__(view)
                multi_tab = MultiTab(view, 'multitab name', 'multi-main')
                tab1 = Tab(view, 'tab 1 name', 'multi1', P.factory(text='tab 1/1 content'))
                tab2 = Tab(view, 'tab 2 name', 'multi2', P.factory(text='tab 1/2 content'))
                multi_tab.add_tab(tab1)
                multi_tab.add_tab(tab2)
                self.add_tab(multi_tab)

                tab3 = Tab(view, 'tab 3 name', 'tab3', P.factory(text='tab 3 content'))
                self.add_tab(tab3)
                tab4 = Tab(view, 'tab 4 name', 'tab4', P.factory(text='tab 4 content'))
                self.add_tab(tab4)
Esempio n. 15
0
    def add_four(self):
        layout = ColumnLayout(ColumnOptions('first', ResponsiveSize(md=6)),
                              ColumnOptions('second', ResponsiveSize(md=6)),
                              ColumnOptions('third', ResponsiveSize(md=6)),
                              ColumnOptions('fourth', ResponsiveSize(md=6)))

        div = Div(self.view).use_layout(layout)
        self.body.add_child(div)

        message = '6/12ths on md and larger, else defaults to 12/12ths'
        div.layout.columns['first'].add_child(P(self.view, text=message))
        div.layout.columns['second'].add_child(P(self.view, text=message))
        div.layout.columns['third'].add_child(P(self.view, text=message))
        div.layout.columns['fourth'].add_child(P(self.view, text=message))
Esempio n. 16
0
    def __init__(self, view, account_management_interface):
        super(RegistrationPendingWidget, self).__init__(view)
        config = WebExecutionContext.get_context().config
        self.add_child(P(view, text=_('There is a registration pending for email address "%s".') % account_management_interface.email))
        self.add_child(P(view, text=_('Before you can log in using it, you need to act on the automated email '\
                                      'sent to that address. It looks like you did not do that.')))
        self.add_child(P(view, text=_('You should receive the automated email anything between a minute to an hour after '\
                                      'registration. Sometimes though, your email software may mistakenly identify our '\
                                      'email as junk email. If this happens it will be hidden away in a "junk email" '\
                                      'folder or just not shown to you.')))
        self.add_child(P(view, text=_('You can have the email re-sent to you by clicking on the button below.')))
        self.add_child(P(view, text=_('Before you do that, however, please make sure that your email system will allow '\
                                      'emails from "%s" through to you.') % config.accounts.admin_email))

        self.add_child(RegistrationPendingForm(view))
Esempio n. 17
0
    def add_twelve(self):
        div = Div(self.view).use_layout(ColumnLayout())
        self.body.add_child(div)

        for i in range(1, 13):
            column = div.layout.add_column(str(i), size=ResponsiveSize(md=1))
            column.add_child(P(self.view, text='1/12th on md and larger'))
Esempio n. 18
0
    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'))
Esempio n. 19
0
 def __init__(self, view):
     super(PopupTestPanel, self).__init__(view)
     popup_a = self.add_child(PopupA(view, view.as_bookmark(), '#contents'))
     popup_a.add_js_button('Butt1')
     popup_a.add_js_button('Butt2')
     popup_contents = self.add_child(P(view, text='this is the content of the popup'))
     popup_contents.set_id('contents')
Esempio n. 20
0
    def __init__(self, view, address):
        form_name = 'address_%s' % address.id
        super(AddressBox, self).__init__(view, form_name)
        self.use_layout(FormLayout())

        par = self.add_child(P(view, text='%s: %s ' % (address.name, address.email_address)))
        par.add_child(Button(self, address.events.edit.with_arguments(address_id=address.id)))
Esempio n. 21
0
    def __init__(self, view):
        super(PageLayoutPage, self).__init__(view)
        self.body.use_layout(Container())
        column_layout = ColumnLayout(
            ColumnOptions('left', ResponsiveSize(md=4)),
            ColumnOptions('right', ResponsiveSize(md=8)))
        self.use_layout(PageLayout(contents_layout=column_layout))

        self.layout.header.add_child(P(view, text='The header'))
        self.layout.footer.add_child(P(view, text='The footer'))

        left = column_layout.columns['left']
        left.add_child(P(view, text='To the left'))

        right = column_layout.columns['right']
        right.add_child(P(view, text='To the right'))
Esempio n. 22
0
 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)
Esempio n. 23
0
    def __init__(self, view):
        super().__init__(view, 'simple_form')
        self.use_layout(FormLayout())
        if self.exception:
            self.layout.add_alert_for_domain_exception(self.exception)

        domain_object = self.get_or_create_domain_object()

        link = self.add_child(
            A(view, Url('/'), description='Open another tab...'))
        link.set_attribute('target', '_blank')
        self.add_child(
            P(view,
              text=
              '...and increment the value there. Come back here and submit the value. A Concurrency error will be shown'
              ))

        #Your own widget that tracks changes
        self.add_child(MyConcurrencyWidget(view, domain_object))

        self.layout.add_input(
            TextInput(self, domain_object.fields.some_field_value))
        self.define_event_handler(domain_object.events.submit)
        self.add_child(Button(self, domain_object.events.submit))
        self.define_event_handler(domain_object.events.increment)
        self.add_child(Button(self, domain_object.events.increment))
Esempio n. 24
0
 def __init__(self, view, address):
     super(AddressBox, self).__init__(view)
     formatted_date = babel.dates.format_date(address.added_date,
                                              locale=_.current_locale)
     self.add_child(
         P(view,
           text='%s: %s (%s)' %
           (address.name, address.email_address, formatted_date)))
Esempio n. 25
0
 def __init__(self, view, address):
     form_name = 'address_%s' % address.id  # Forms need unique names!
     super(AddressBox, self).__init__(view, form_name)
     paragraph = self.add_child(
         P(view, text='%s: %s ' % (address.name, address.email_address)))
     paragraph.add_child(
         Button(self,
                address.events.edit.with_arguments(address_id=address.id)))
Esempio n. 26
0
    def assemble(self):
        contents_layout = ColumnLayout(ColumnOptions('main', ResponsiveSize())).with_slots()

        self.define_page(HTML5Page).use_layout(PageLayout(document_layout=Container(),
                                                          contents_layout=contents_layout))

        home = self.define_view('/', title='Layout demo')
        home.set_slot('main', CommentForm.factory())

        header_text = lots_of('This text is located in the header,'
                              'which is added by the PageLayout. ')
        home.set_slot('header', P.factory(text=header_text))


        footer_text = lots_of('The footer spans the bottom of all the '
                              'columns on a PageLayout ')
        home.set_slot('footer', P.factory(text=footer_text))
Esempio n. 27
0
def test_default_active_tab(web_fixture, default_tab_scenarios):
    """The first tab is active by default (if the active tab is not indicated in the query_string)."""

    tab1 = Tab(web_fixture.view, 'tab 1 name', 'tab1', P.factory(text='tab 1 content'))
    tab2 = Tab(web_fixture.view, 'tab 2 name', 'tab2', P.factory(text='tab 2 content'))

    tabbed_panel = TabbedPanel(web_fixture.view)
    tabbed_panel.add_tab(tab1)
    tabbed_panel.add_tab(tab2)

    [menu_item1, menu_item2] = tabbed_panel.nav.menu_items
    assert menu_item1.is_active == default_tab_scenarios.tab1_active
    assert menu_item2.is_active == default_tab_scenarios.tab2_active

    tester = WidgetTester(tabbed_panel)
    panel_contents = tester.get_html_for('//div[@class="tab-content"]/div[contains(@class, "active")]/*')
    assert panel_contents == default_tab_scenarios.expected_contents
Esempio n. 28
0
    def __init__(self, view, funding_request, apply_bookmark):
        super(FundingRequestSummary, self).__init__(view)

        self.add_child(H(view, 1, 'Application for Financial Aid'))
        self.add_child(P(view, text='Name: %s' % funding_request.name))
        self.add_child(P(view, text='Surname: %s' % funding_request.surname))
        self.add_child(
            P(view, text='Email: %s' % funding_request.email_address))
        self.add_child(
            P(view, text='Current status: %s.' % funding_request.grant_status))

        self.add_child(H(view, 2, 'Feedback from the financial aid team'))
        if funding_request.feedback_message:
            self.add_child(P(view, text=funding_request.feedback_message))
        else:
            self.add_child(
                P(view,
                  text=
                  'There is no feedback message for you from the organisers'))

        if funding_request.allow_user_changes:
            self.add_child(
                P(view, text='You can still edit/change your request'))
            self.add_child(
                Nav(view).with_bookmarks(
                    [apply_bookmark.with_description('Edit application')]))
Esempio n. 29
0
    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'))
Esempio n. 30
0
    def assemble(self):
        comment = Comment()

        home = self.define_view('/', title='Page flow demo')
        home.set_slot('main', CommentForm.factory(comment))

        thanks = self.define_view('/thanks', title='Thank you!')
        thanks_text = 'Thanks for submitting your comment'
        thanks.set_slot('main', P.factory(text=thanks_text))

        none_submitted = self.define_view('/none', title='Nothing to say?')
        none_text = 'Mmm, you submitted an empty comment??'
        none_submitted.set_slot('main', P.factory(text=none_text))

        self.define_transition(comment.events.submit, home, thanks, 
                               guard=Action(comment.contains_text))
        self.define_transition(comment.events.submit, home, none_submitted, 
                               guard=Not(Action(comment.contains_text)))