def model(self):

        T = current.T
        db = current.db

        crud_strings = current.response.s3.crud_strings

        define_table = self.define_table
        add_components = self.add_components

        # =====================================================================
        # Data Collection Template
        #
        tablename = "dc_template"
        define_table(tablename,
                     Field("name",
                           requires = IS_NOT_EMPTY(),
                           ),
                     # Whether to show this template in the form list
                     # (required since form list can't use authorization)
                     Field("public", "boolean",
                           default = False,
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        self.configure(tablename,
                       xform = {"collection": "dc_collection",
                                "questions": "question",
                                "answers": "answer",
                                },
                       )
        # Represent
        represent = S3Represent(lookup=tablename)

        # Reusable field
        template_id = S3ReusableField("template_id", tablename % "reference %s",
                                      label = T("Template"),
                                      represent = represent,
                                      requires = IS_ONE_OF(db, "dc_template.id",
                                                           represent,
                                                           ),
                                      sortby = "name",
                                      comment = S3PopupLink(f="template",
                                                            tooltip=T("Add a new data collection template"),
                                                            ),
                                      )

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Create Template"),
            title_display = T("Template Details"),
            title_list = T("Templates"),
            title_update = T("Edit Template"),
            title_upload = T("Import Templates"),
            label_list_button = T("List Templates"),
            label_delete_button = T("Delete Template"),
            msg_record_created = T("Template added"),
            msg_record_modified = T("Template updated"),
            msg_record_deleted = T("Template deleted"),
            msg_list_empty = T("No Templates currently registered"))

        # Components
        add_components(tablename,
                       dc_question = {"link": "dc_template_question",
                                      "joinby": "template_id",
                                      "key": "question_id",
                                      "actuate": "hide",
                                      "autodelete": False,
                                      },
                       )

        # =====================================================================
        # Data Collection Question
        #
        tablename = "dc_question"
        define_table(tablename,
                     Field("question",
                           requires = IS_NOT_EMPTY(),
                           ),
                     Field("model", "json",
                           requires = IS_EMPTY_OR(IS_JSON(native_json=True)),
                           # @todo: representation?
                           widget = S3QuestionWidget(),
                           ),
                     *s3_meta_fields())

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Create Question"),
            title_display = T("Question Details"),
            title_list = T("Questions"),
            title_update = T("Edit Question"),
            title_upload = T("Import Questions"),
            label_list_button = T("List Questions"),
            label_delete_button = T("Delete Question"),
            msg_record_created = T("Question added"),
            msg_record_modified = T("Question updated"),
            msg_record_deleted = T("Question deleted"),
            msg_list_empty = T("No Questions currently registered"))

        # Represent
        represent = S3Represent(lookup=tablename,
                                fields=["question"],
                                show_link=True,
                                )

        # Reusable field
        question_id = S3ReusableField("question_id", "reference %s" % tablename,
                                      label = T("Question"),
                                      represent = represent,
                                      requires = IS_ONE_OF(db, "dc_question.id",
                                                           represent,
                                                           ),
                                      sortby = "name",
                                      comment = S3PopupLink(f="question",
                                                            tooltip=T("Add a new data collection question"),
                                                            ),
                                      )

        # Components
        add_components(tablename,
                       dc_question_l10n = "question_id",
                       )

        # =====================================================================
        # Template <=> Question link table
        #
        tablename = "dc_template_question"
        define_table(tablename,
                     template_id(),
                     question_id(),
                     *s3_meta_fields())

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Add Question"),
            label_delete_button = T("Remove Question"),
            msg_record_created = T("Question added"),
            msg_record_deleted = T("Question remove"),
            msg_list_empty = T("No Questions currently registered"))

        # =====================================================================
        # Questions l10n
        #
        tablename = "dc_question_l10n"
        define_table(tablename,
                     question_id(ondelete = "CASCADE",
                                 ),
                     Field("language",
                           label = T("Language"),
                           represent = IS_ISO639_2_LANGUAGE_CODE.represent,
                           requires = IS_ISO639_2_LANGUAGE_CODE(sort=True),
                           ),
                     Field("question",
                           requires = IS_NOT_EMPTY(),
                           ),
                     Field("model", "json",
                           requires = IS_EMPTY_OR(IS_JSON()),
                           # @todo: representation?
                           # @todo: widget?
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Create Translation"),
            title_display = T("Translation"),
            title_list = T("Translations"),
            title_update = T("Edit Translation"),
            title_upload = T("Import Translations"),
            label_list_button = T("List Translations"),
            label_delete_button = T("Delete Translation"),
            msg_record_created = T("Translation added"),
            msg_record_modified = T("Translation updated"),
            msg_record_deleted = T("Translation deleted"),
            msg_list_empty = T("No Translations currently available"))

        # =====================================================================
        # Pass names back to global scope (s3.*)
        return dict(dc_template_id = template_id,
                    dc_question_id = question_id,
                    )

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3db/dc.py/DataCollectionTemplateModel.model/swapped operands of `%`