Example #1
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'))
Example #2
0
    def __init__(self, view, inbox):
        super().__init__(view)
        self.add_child(H(view, 1, text=_('Inbox')))
        self.list = self.add_child(Ul(view))

        for task in inbox.get_tasks():
            self.list.add_child(TaskBox(view, task))
Example #3
0
 def add_uploaded_list(self):
     ul = self.upload_form.add_child(Ul(self.view))
     for persisted_file in self.persisted_file_class.get_persisted_for_form(
             self.input_form, self.name):
         ul.add_child(
             FileUploadLi(self.upload_form.form, self.events.remove_file,
                          persisted_file))
Example #4
0
 def create_html_representation(self):
     ul = self.add_child(Ul(self.view))
     self.set_html_representation(ul)
     ul.append_class('reahl-menu')
     return ul