Example #1
0
def EditPage(options, selection):
    """Print a web page to edit the values of an option."""
    if options == "categories":
        option = "category"
    else:
        option = options[:-1]
    title = "Edit %s" % option.capitalize()
    content = HTML.Container()
    content.Add(HTML.Header("Edit %s" % option.capitalize()))
    selections = DatabaseModule.Read(options, "options")
    form = HTML.Form("ModifyOption.py")
    table = HTML.Table([200, 350], cellspacing="0", align="center")
    row = HTML.Row()
    row.Add(HTML.HeaderCell(option.capitalize()))
    row.Add(HTML.HeaderCell(selection, class_="sunday"))
    table.Add(row)
    row = HTML.Row()
    row.Add(HTML.HeaderCell("Description"))
    if selections[selection]:
        row.Add(
            HTML.Cell(
                HTML.TextArea("description",
                              ConvertBreaks(selections[selection]),
                              rows=5,
                              cols=40)))
    else:
        row.Add(HTML.Cell(HTML.TextArea("description", rows=5, cols=40)))
    table.Add(row)
    form.Add(table)
    form.Add(
        HTML.Para("%s%s%s%s%s" %
                  (HTML.Submit("modify",
                               "Modify %s" % option.capitalize()), HTML.TAB,
                   HTML.Submit("delete", "Delete %s" % option.capitalize()),
                   HTML.TAB, HTML.Submit("cancel", "Cancel")),
                  class_="center"))
    form.Add(HTML.HiddenInput("options", options))
    form.Add(HTML.HiddenInput("selection", selection))
    content.Add(form)
    content.Add(PrintModule.BottomMonthsTable())
    return HTML.Page(title, content)