def render_modal_dialog(form_fields, id, action, open=False):
    hidden = html.input(type="hidden", name="_action", value=action)
    submit = html.input(type="submit", value="Submit", class_="button-primary")
    form = html.form(form_fields, hidden, submit, method="post")
    close = html.span(SafeString("×"), class_="close", onclick="closeDialog('%s');" % id)
    content = html.div(close, form, class_="modal-content")
    class_val = "modal"
    if open:
        class_val = "modal modal-open"
    return html.div(content, id=id, class_=class_val)
Exemple #2
0
 def test_view_breadcrumbs_committee(self):
     committee = data_models.Committee('EDU', 'Education')
     crumbs = views.view_breadcrumbs(committee)
     expected = html.div(html.a('Dashboard', href='/'), ' / ',
                         html.a('Committee List', href='/committee_list'),
                         ' / ', html.a('Education', href='/committee/EDU'))
     self.assertEqual(expected, crumbs)
 def test_create_payment_no_grants(self):
     user = db.User.query().get()
     role = db.Role(parent=user.key)
     role.type_index = RoleType.PAYMENT_ADMIN
     role.put()
     supplier = db.Supplier(id=6)
     supplier.paid_in_sterling = False
     supplier.name = "Sup-6"
     supplier.put()
     with app.test_request_context('/supplier/123',
                                   method='POST',
                                   data={'_action': 'startTransfer'}):
         args = suppliers.view_supplier('Supplier-6')
     expected = html.div(
         html.div('No grants are pending - nothing to transfer',
                  class_='error'))
     self.assertEquals(expected, args.get('errors'))
Exemple #4
0
 def test_view_breadcrumbs_list2(self):
     role = db.Role.query().get()
     user = role.key.parent().get()
     user_id = user.key.urlsafe()
     crumbs = views.view_breadcrumbs(user, 'Role')
     expected = html.div(html.a('Dashboard', href='/'), ' / ',
                         html.a('User List', href='/user_list'), ' / ',
                         html.a('Keith', href='/user/' + user_id), ' / ',
                         html.a('Role List', href='/role_list/' + user_id))
     self.assertEqual(expected, crumbs)
def render_grid(values, labels, num_wide=0):
    rows = []
    numItems = len(values) - num_wide
    for x in range(0, numItems, 3):
        cols = []
        for y in range(3):
            index = x + y
            if index >= numItems:
                break
            value = values[index]
            legend = html.legend(labels[index])
            col = html.div(legend, value, class_="four columns")
            cols.append(col)
        rows.append(html.div(*cols, class_="row"))
    for i in range(numItems, len(values)):
        value = values[i]
        legend = html.legend(labels[i])
        rows.append(html.div(legend, value,  class_="u-full-width"))
    return html.div(rows)
Exemple #6
0
def radio_field_widget(field, **kwargs):
    kwargs.setdefault('id', field.id)
    children = []
    for val, label, selected in field.iter_choices():
        children.append(label)
        children.append(
            html.input(type="radio",
                       name=field.name,
                       value=val,
                       checked=selected))
    return html.div(*children, **kwargs)
Exemple #7
0
 def test_view_breadcrumbs_none(self):
     crumbs = views.view_breadcrumbs(None)
     expected = html.div(html.a('Dashboard', href='/'))
     self.assertEqual(expected, crumbs)
def render_errors(errors):
    error_list = [html.div(error, class_='error') for error in errors]
    return html.div(*error_list)
def render_div(*content, **kwargs):
    return html.div(*content, **kwargs)
def render_single_column(values, labels):
    rows = []
    for i in range(0, len(values)):
        legend = html.b(labels[i] + ": ")
        rows.append(html.div(legend, values[i]))
    return html.div(rows)
Exemple #11
0
def form_field_widget(form_field, **kwargs):
    children = render_fields(form_field)
    return html.div(*children, **kwargs)