def survey_template_rheader(r, tabs=[]):

    if r.representation == "html":

        tablename, record = s3_rheader_resource(r)
        if tablename == "survey_template" and record:

            T = current.T
            s3db = current.s3db

            # Tabs
            tabs = [(T("Basic Details"), "read"),
                    (T("Question Details"), "template_read/"),
                    (T("Question Summary"), "template_summary/"),
                    #(T("Sections"), "section"),
                    ]
            if current.auth.s3_has_permission("create", "survey_translate"):
                tabs.append((T("Translate"), "translate"))

            rheader_tabs = s3_rheader_tabs(r, tabs)

            stable = s3db.survey_section
            qltable = s3db.survey_question_list
            viewing = current.request.get_vars.get("viewing", None)
            if viewing:
                dummy, template_id = viewing.split(".")
            else:
                template_id = r.id

            query = (qltable.template_id == template_id) & \
                    (qltable.section_id == stable.id)
            rows = current.db(query).select(stable.id,
                                            stable.name,
                                            orderby = qltable.posn)
            tsection = TABLE(_class="survey-section-list")
            label_section = SPAN(T("Sections that are part of this template"),
                                 _style="font-weight:bold;")
            if (rows.__len__() == 0):
                rsection = SPAN(T("As of yet, no sections have been added to this template."))
            else:
                rsection = TR()
                count = 0
                last_section = ""
                for section in rows:
                    if section.name == last_section:
                        continue
                    rsection.append(TD(section.name))
                    # Comment out the following until templates can be built online
                    #rsection.append(TD(A(section.name,
                    #                     _href=URL(c="survey",
                    #                               f="section",
                    #                               args="%s" % section.id))))
                    last_section = section.name
                    count += 1
                    if count % 4 == 0:
                        tsection.append(rsection)
                        rsection = TR()
            tsection.append(rsection)

            rheader = DIV(TABLE(TR(TH("%s: " % T("Name")),
                                   record.name,
                                   TH("%s: " % T("Status")),
                                   s3db.survey_template_status[record.status],
                                   ),
                                ),
                          label_section,
                          tsection,
                          rheader_tabs,
                          )
            return rheader

# =============================================================================
The template rheader
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/survey_template_rheader