def repository():
    """ Repository Management Controller """

    s3db.set_method("sync", "repository",
                    method = "register",
                    action = current.sync,
                    )

    def prep(r):
        if r.interactive:

            if not r.component:

                # Make the UUID field editable in the form
                field = r.table.uuid
                field.label = "UUID"
                field.readable = True
                field.writable = True
                field.comment = DIV(_class="tooltip",
                                    _title="%s|%s" % (
                                           T("Repository UUID"),
                                           T("Identifier which the remote site uses to authenticate at this site when sending synchronization requests."),
                                           ),
                                    )

                # Inject script to show/hide relevant fields depending
                # on the API type selected:
                script = "s3.sync.js" if s3.debug else "s3.sync.min.js"
                path = (appname, script) % "/%s/static/scripts/S3/%s"
                if path not in s3.scripts:
                    s3.scripts.append(path)

            elif r.id:

                alias = r.component.alias
                if alias == "task":
                    # Configure custom CRUD form
                    apitype = r.record.apitype
                    if apitype == "filesync":
                        component_table = r.component.table
                        for fname in ("infile_pattern",
                                      "outfile_pattern",
                                      "human_readable",
                                      "delete_input_files",
                                      ):
                            field = component_table[fname]
                            field.readable = field.writable = True
                        infile_pattern = "infile_pattern"
                        outfile_pattern = "outfile_pattern"
                        human_readable = "human_readable"
                        delete_input_files = "delete_input_files"
                    else:
                        infile_pattern = None
                        outfile_pattern = None
                        human_readable = None
                        delete_input_files = None

                    crud_form = s3base.S3SQLCustomForm(
                                    "resource_name",
                                    infile_pattern,
                                    delete_input_files,
                                    outfile_pattern,
                                    human_readable,
                                    "last_pull",
                                    "last_push",
                                    "mode",
                                    "strategy",
                                    #"update_method",
                                    "update_policy",
                                    "conflict_policy",
                                    s3base.S3SQLInlineComponent(
                                        "resource_filter",
                                        label = T("Filters"),
                                        fields = ["tablename",
                                                  "filter_string",
                                                  ],
                                        ),
                                    )

                    list_fields = ["resource_name",
                                   "mode",
                                   "last_pull",
                                   "last_push",
                                   "strategy",
                                   "update_policy",
                                   "conflict_policy",
                                   ]

                    s3db.configure("sync_task",
                                   crud_form = crud_form,
                                   list_fields = list_fields,
                                   )

                elif alias == "job":
                    # Configure sync-specific defaults for scheduler_task table
                    s3task.configure_tasktable_crud(
                        function="sync_synchronize",
                        args = [r.id],
                        vars = {"user_id": auth.user.id if auth.user else 0},
                        period = 600, # seconds, so 10 mins
                    )

                elif alias == "log" and r.component_id:
                    table = r.component.table
                    table.message.represent = lambda msg: \
                                                DIV(s3base.s3_strip_markup(msg),
                                                    _class="message-body",
                                                    )
                s3.cancel = URL(c = "sync",
                                f = "repository",
                                args = [str(r.id), alias],
                                )

        return True
    s3.prep = prep

    def postp(r, output):
        if r.interactive and r.id:
            if r.component and r.component.alias == "job":
                s3.actions = [dict(label=str(T("Reset")),
                                   _class="action-btn",
                                   url=URL(c="sync",
                                           f="repository",
                                           args=[str(r.id),
                                                 "job",
                                                 "[id]",
                                                 "reset",
                                                 ],
                                           ),
                                   )
                              ]
        s3_action_buttons(r)
        return output
    s3.postp = postp

    # Rheader tabs for repositories
    tabs = [(T("Configuration"), None),
            (T("Resources"), "task"),
            (T("Schedule"), "job"),
            (T("Log"), "log"),
            ]

    rheader = lambda r: s3db.sync_rheader(r, tabs=tabs)
    return s3_rest_controller("sync", "repository", rheader=rheader)

# -----------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/controllers/sync.py/repository/swapped operands of `%`