Next / Previous / Contents / TCC Help System / NM Tech homepage

8.7. regx.cgi: startForm(): Set up the form and static controls

regx.cgi
# - - -   s t a r t F o r m

def startForm(page):
    '''Set up the form and general controls on the regional index.

      [ page is a tp.TCCPage instance ->
          page  :=  page with the regional index form added except for
                    the index entries ]
    '''

The form of the code here follows the structure described in Section 4.2, “General controls on the regional index page”.

regx.cgi
    form = subElement(page.content,
        E.form(method=regform.METHOD,
            action='http://www.nmt.edu/~shipman/z/cbc/cbchist/hist.cgi'))

    form.append(
      E.p("To generate a report showing all the records for one "
          "or more circles:"))

    ol = subElement(form, E.ol())

    if RegArgs().firstYear == lib.MIN_YEAR: firstValue = {}
    else: firstValue = { 'value': RegArgs().firstYear }

    if RegArgs().lastYear == lib.MAX_YEAR: lastValue = {}
    else: lastValue = { 'value': RegArgs().lastYear }

    ol.append(
      E.li(
        E.p("If you would like to limit your search to specific "
            "years, enter the first and/or last year numbers "
            "here.  Year number 1 is 1900-1901; 110 is 2009-2010; "
            "and so on. Leave these fields blank to select "
            "all years."),
        E.p(
          E.b("Year number 1 is 1900-1901; year 110 is 2009-2010; "
              "and so on. "),
          "In general, the CBC year number is the year of that "
          "Christmas minus 1899."),
        E.table({'cellspacing': '8', 'rules': 'none',
                 'border': '0'},
          E.tr(
            E.td(
              E.label(lib.FOR(regform.FIRST_YEAR_ID), "First year no."),
              E.input(firstValue, type='text', size='3', maxlength='3',
                      name=regform.FIRST_YEAR_ENTRY,
                      id=regform.FIRST_YEAR_ID)),
            E.td(
              E.label(lib.FOR(regform.LAST_YEAR_ID), "Last year no."),
              E.input(lastValue, type='text', size='3', maxlength='3',
                      name=regform.LAST_YEAR_ENTRY,
                      id=regform.LAST_YEAR_ID))))))

    ol.append(
      E.li(
        E.p("Select these options that affect the bird nomenclature."),
        E.div(
          E.input(type='checkbox', checked='checked',
                  name=regform.LUMP_SUBSP_CB,
                  id=regform.LUMP_SUBSP_ID),
          E.label(lib.FOR(regform.LUMP_SUBSP_ID),
                  "Combine all subspecific forms into one row for the "
                  "species.")),
        E.div(
          E.input(type='checkbox',
                  name=regform.NM_ALIAS_CB,
                  id=regform.NM_ALIAS_ID),
          E.label(lib.FOR(regform.NM_ALIAS_ID),
                  "Use New Mexico alias rules (e.g., assume all "
                  "Boat-tailed Grackles are Great-tailed)."))))

    ol.append(
      E.li(
        E.p("To generate a history report, either:"),
        E.ul(
          E.li("Click on the name of a circle to get a report of just "
               "that circle."),
          E.li(
            E.p("To get a report combining data from multiple "
                "circles:"),
            E.ol(
              E.li(
                E.p("Select what to do when some of the selected "
                    "circles were worked in the same year."),
                E.div(
                  E.input(type='radio', value='1',
                          name=regform.YEAR_LUMP_RADIOS,
                          id=regform.YEAR_LUMP_ON_ID),
                  E.label(lib.FOR(regform.YEAR_LUMP_ON_ID),
                          "Combine all circles for the same year into "
                          "a single column.")),
                E.div(
                  E.input(type='radio', value='0', checked='checked',
                          name=regform.YEAR_LUMP_RADIOS,
                          id=regform.YEAR_LUMP_OFF_ID),
                  E.label(lib.FOR(regform.YEAR_LUMP_OFF_ID),
                          "Display each circle's data in a separate "
                          "column."))),
              E.li("Select one or more circles by clicking on the"
                   "checkbox by each desired circle's name."),
              E.li(
                E.p("Click this button:"),
                E.input(type='submit', name=regform.ALL,
                        value="Report on selected circles"),
                E.input(type='reset', value='Clear this form')))))))

    ol.append(
      E.li(
        E.div(
          E.input(type='checkbox',
                  name=regform.PDF,
                  id=regform.PDF_ID),
          E.label(lib.FOR(regform.PDF_ID),
                  "Output as a PDF (may take a minute or two)"))))

    form.append(E.hr())

    return form