示例#1
0
    def customise_org_facility_resource(r, tablename):

        from s3 import S3LocationFilter, S3OptionsFilter, S3TextFilter

        filter_widgets = [
            S3TextFilter(
                ["name"],
                label=T("Search"),
                comment=T(
                    "Search by facility name. You can use * as wildcard."),
            ),
            S3OptionsFilter("site_facility_type.facility_type_id", ),
            S3OptionsFilter("organisation_id", ),
            S3LocationFilter("location_id", ),
        ]

        s3db = current.s3db

        s3db.configure(
            tablename,
            filter_widgets=filter_widgets,
        )

        # Customize fields
        table = s3db.org_facility

        # Main facility flag visible and in custom crud form
        field = table.main_facility
        field.readable = field.writable = True
        crud_form = s3db.get_config(tablename, "crud_form")
        crud_form.insert(-2, "main_facility")

        # "Obsolete" labeled as "inactive"
        field = table.obsolete
        field.label = T("Inactive")
示例#2
0
    def customise_org_facility_resource(r, tablename):

        s3db = current.s3db

        # Custom filter widgets
        from s3 import S3LocationFilter, S3OptionsFilter, S3TextFilter
        filter_widgets = [
            S3TextFilter(
                ["name"],
                label=T("Search"),
                comment=T(
                    "Search by facility name. You can use * as wildcard."),
            ),
            S3OptionsFilter("site_facility_type.facility_type_id", ),
            S3OptionsFilter("organisation_id", ),
            S3LocationFilter("location_id", ),
        ]

        # Custom list fields
        list_fields = [
            "name",
            "site_facility_type.facility_type_id",
            "organisation_id",
            "location_id",
            "opening_times",
            "contact",
            "phone1",
            "phone2",
            "email",
            #"website",
            "obsolete",
            #"comments",
        ]

        s3db.configure(
            tablename,
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )

        # Customise fields
        table = s3db.org_facility

        # Main facility flag visible and in custom crud form
        field = table.main_facility
        field.readable = field.writable = True
        crud_form = s3db.get_config(tablename, "crud_form")
        crud_form.insert(-2, "main_facility")

        # "Obsolete" labeled as "inactive"
        field = table.obsolete
        field.label = T("Inactive")
        field.represent = lambda opt: T("Inactive") \
                                      if opt else current.messages["NONE"]
        field.readable = field.writable = True

        # Not using facility code
        field = table.code
        field.readable = field.writable = False
示例#3
0
    def __call__(self):
        """ Main entry point, configuration """

        T = current.T
        s3db = current.s3db
        settings = current.deployment_settings
        gis = current.gis

        # Must be logged in
        auth = current.auth
        if not auth.s3_logged_in():
            auth.permission.fail()

        # Available resources
        resources = [
            dict(resource="cap_alert", url="cap/alert", label=T("Updates")),
        ]

        # Filter widgets
        # @note: subscription manager has no resource context, so
        #        must configure fixed options or lookup resources
        #        for filter widgets which need it.
        filters = [
            S3OptionsFilter(
                "category",
                label=T("Category"),
                options=s3db.cap_info_category_opts,
                represent="%(name)s",
                resource="cap_info",
                _name="category-filter",
            ),
            S3LocationFilter(
                "location_id",
                label=T("Location(s)"),
                levels=("L0", ),
                resource="cap_area_location",
                options=gis.get_countries().keys(),
                _name="location-filter",
            ),
            S3OptionsFilter(
                "language",
                label=T("Language"),
                options=settings.get_cap_languages(),
                represent="%(name)s",
                resource="cap_info",
                _name="language-filter",
            ),
        ]

        # Title and view
        title = T("Notification Settings")
        self._view(THEME, "subscriptions.html")

        # Form
        form = self._manage_subscriptions(resources, filters)

        return dict(title=title, form=form)
示例#4
0
    def __call__(self):
        """ Main entry point, configuration """

        T = current.T

        # Must be logged in
        auth = current.auth
        if not auth.s3_logged_in():
            auth.permission.fail()

        # Available resources
        resources = [
            dict(resource="cms_post",
                 url="default/index/newsfeed",
                 label=T("Updates")),
        ]

        # Filter widgets
        # @note: subscription manager has no resource context, so
        #        must configure fixed options or lookup resources
        #        for filter widgets which need it.
        filters = [
            S3OptionsFilter(
                "series_id",
                label=T("Subscribe to"),
                represent="%(name)s",
                cols=2,
                resource="cms_post",
                _name="type-filter",
            ),
            S3LocationFilter(
                "location_id",
                label=T("Location(s)"),
                levels=("L1", ),
                resource="cms_post",
                _name="location-filter",
            ),
            #S3OptionsFilter("created_by$organisation_id",
            #                label = T("Filter by Organization"),
            #                represent = s3db.org_organisation_represent,
            #                #represent = "%(name)s",
            #                resource = "cms_post",
            #                _name = "organisation-filter",
            #                ),
        ]

        # Title and view
        title = T("Notification Settings")
        self._view(THEME, "subscriptions.html")

        # Form
        form = self._manage_subscriptions(resources, filters)

        return dict(title=title, form=form)
示例#5
0
    def customise_org_organisation_resource(r, tablename):

        s3db = current.s3db

        # Simplify form
        table = s3db.org_organisation
        field = table.year
        field.readable = field.writable = False
        field = table.country
        field.readable = field.writable = False

        if not current.auth.is_logged_in():
            field = table.logo
            field.readable = field.writable = False
            # User can create records since we need this during registration,
            # but we don't want to let the user do this from the list view
            s3db.configure(
                "org_organisation",
                listadd=False,
            )

        # Custom filters to match the information provided
        from s3 import S3LocationFilter, S3OptionsFilter, S3TextFilter
        filter_widgets = [
            S3TextFilter(
                [
                    "name",
                    "acronym",
                    #"website",
                    #"comments",
                ],
                label=T("Search"),
                comment=
                T("Search by organization name or acronym. You can use * as wildcard."
                  ),
            ),
            S3OptionsFilter("sector_organisation.sector_id", ),
            S3OptionsFilter(
                "organisation_organisation_type.organisation_type_id",
                label=T("Type"),
            ),
            S3LocationFilter(
                "organisation_location.location_id",
                label=T("Areas Served"),
                levels=("L1", "L2", "L3", "L4"),
                #hidden = True,
            ),
        ]

        s3db.configure(
            "org_organisation",
            filter_widgets=filter_widgets,
        )
示例#6
0
文件: config.py 项目: thuyxd/Turkey
        def custom_prep(r):
            # Call standard prep
            if callable(standard_prep):
                result = standard_prep(r)
            else:
                result = True
            if r.controller == "vol":
                s3db = current.s3db
                list_fields = ["course_id$code"]
                list_fields.append("course_id")
                list_fields.append("person_id")

                from s3 import S3TextFilter, S3OptionsFilter, S3LocationFilter
                filter_widgets = [
                    S3TextFilter(
                        [
                            "course_id$code",
                            "course_id$name",
                            "person_id$first_name",
                            "person_id$middle_name",
                            "person_id$last_name",
                        ],
                        label=T("Search"),
                    ),
                ]
                if is_admin:
                    filter_widgets.append(
                        S3OptionsFilter("course_id$organisation_id"))
                filter_widgets.append(
                    S3LocationFilter(
                        "person_id$location_id",
                        levels=("L1", "L2", "L3", "L4"),
                        label=T("Location"),
                        #hidden = True,
                    ), )
                filter_widgets.append(S3OptionsFilter("course_id"))

                s3db.configure("hrm_training",
                               list_fields=list_fields,
                               filter_widgets=filter_widgets)

            return result
示例#7
0
文件: config.py 项目: Neetuj/eden
def customise_stats_demographic_data_resource(r, tablename):

    s3db = current.s3db
    table = s3db.stats_demographic_data

    # Add a Timeplot tab to summary page
    # @ToDo: Widget version of timeplot
    #settings.ui.summary = list(settings.ui.summary) + {"name": "timeplot",
    #                                                   "label": "TimePlot",
    #                                                   "widgets": [{"method": "timeplot", "ajax_init": True}],
    #                                                   }

    from s3 import S3OptionsFilter, S3LocationFilter
    filter_widgets = [S3OptionsFilter("parameter_id",
                                      label = T("Type"),
                                      multiple = False,
                                      # Not translateable
                                      #represent = "%(name)s",
                                      ),
                      # @ToDo: 'Month' &/or Week VF
                      #S3OptionsFilter("month",
                      #                #multiple = False,
                      #                operator = "anyof",
                      #                options = lambda: \
                      #                  stats_month_options("stats_demographic_data"),
                      #                ),
                      ]
    
    if r.method != "timeplot":
        # This is critical for the Map, but breaks aggregated Report data
        filter_widgets.append(S3OptionsFilter("location_id$level",
                                              label = T("Level"),
                                              multiple = False,
                                              # Not translateable
                                              #represent = "%(name)s",
                                              ))
    filter_widgets.append(S3LocationFilter("location_id"))
示例#8
0
文件: config.py 项目: anurag-ks/eden
    def customise_req_site_needs_resource(r, tablename):

        if r.tablename == "req_site_needs":
            table = r.table
            field = table.site_id
            field.label = current.T("Facility")
            field.readable = field.writable = True

            # @todo: allow only facilities which do not have a req_site_needs yet
            # @todo: if there aren't any, set insertable=False

        # Filters
        from s3 import S3LocationFilter, S3TextFilter
        filter_widgets = [S3TextFilter(["site_id$name",
                                        "vol_details",
                                        "goods_details",
                                        ],
                                        label = T("Search"),
                                       ),
                          S3LocationFilter("site_id$location_id",
                                           ),
                          ]

        # List fields
        list_fields = [(T("Facility"), "site_id$name"),
                       "site_id$location_id",
                       ("%s?" % T("Volunteers"), "vol"),
                       (T("Help Wanted"), "vol_details"),
                       ("%s?" % T("Donations"), "goods"),
                       (T("Donations Needed"), "goods_details"),
                       "modified_on",
                       ]

        current.s3db.configure("req_site_needs",
                               filter_widgets = filter_widgets,
                               list_fields = list_fields,
                               )
示例#9
0
文件: requests.py 项目: sahana/eden
def req_filter_widgets():
    """
        Filter widgets for requests

        @returns: list of filter widgets
    """

    T = current.T

    from s3 import S3DateFilter, \
                   S3LocationFilter, \
                   S3OptionsFilter, \
                   S3TextFilter, \
                   s3_get_filter_opts

    from s3db.req import req_status_opts

    req_status_opts = OrderedDict(
        sorted(
            req_status_opts().items(),
            key=lambda i: i[0],
        ))

    filter_widgets = [
        S3TextFilter(
            ["req_ref"],
            label=T("Order No."),
        ),
        S3DateFilter("date"),
        S3OptionsFilter(
            "transit_status",
            cols=3,
            options=req_status_opts,
            sort=False,
        ),
        S3OptionsFilter(
            "fulfil_status",
            cols=3,
            hidden=True,
            options=req_status_opts,
            sort=False,
        ),
        S3OptionsFilter(
            "req_item.item_id",
            hidden=True,
            options=lambda: s3_get_filter_opts("supply_item"),
        ),
    ]

    if current.auth.s3_has_role("SUPPLY_COORDINATOR"):

        coordinator_filters = [
            S3LocationFilter(
                "site_id$location_id",
                levels=["L3", "L4"],
            ),
            S3TextFilter(
                "site_id$location_id$addr_postcode",
                label=T("Postcode"),
            ),
            S3OptionsFilter("site_id", hidden=True),
            S3OptionsFilter(
                "site_id$organisation_id$delivery.value",
                label=T("Delivery##supplying"),
                options=delivery_tag_opts(),
            ),
        ]
        filter_widgets[2:2] = coordinator_filters

    return filter_widgets
示例#10
0
    def customise_project_project_resource(r, tablename):

        from s3 import S3LocationSelector, S3Represent, S3TextFilter, S3OptionsFilter, S3LocationFilter

        s3db = current.s3db
        table = s3db.project_project

        table.code.label = "SOF"

        s3db.project_location.location_id.widget = S3LocationSelector(
            levels=("L1", "L2", "L3"),
            show_map=False,
        )

        # Always SC
        otable = s3db.org_organisation
        org = current.db(otable.name == SAVE).select(otable.id,
                                                     cache=s3db.cache,
                                                     limitby=(0, 1)).first()
        try:
            SCI = org.id
        except:
            current.log.error("Cannot find org %s - prepop not done?" % SAVE)
        else:
            f = table.organisation_id
            f.default = SCI

        org_represent = s3db.org_OrganisationRepresent(acronym=False,
                                                       show_link=True)
        s3db.project_organisation.organisation_id.represent = org_represent
        try:
            s3db.project_donor_organisation.organisation_id.represent = org_represent
        except:
            # Table not present on Activities tab
            pass

        from s3 import S3SQLCustomForm, S3SQLInlineComponent, S3SQLInlineLink

        # @ToDo: Inherit Locations from Disaster?

        crud_form = S3SQLCustomForm(
            S3SQLInlineLink(
                "programme",
                label=T("Program"),
                field="programme_id",
                multiple=False,
            ),
            "name",
            "code",
            "status_id",
            "start_date",
            "end_date",
            "budget",
            "currency",
            S3SQLInlineComponent(
                "location",
                label=T("Locations"),
                fields=["location_id"],
            ),
            S3SQLInlineComponent(
                "organisation",
                name="donor",
                label=T("Donor(s)"),
                fields=["organisation_id"],
            ),
            # @ToDo: Set Metadata on File: Org, Location, Disaster, Date
            S3SQLInlineComponent(
                "document",
                name="concept_note",
                label=T("Concept Note"),
                fields=["file"],
                multiple=False,
            ),
            # @ToDo: Be able to retrieve the correct document
            #S3SQLInlineComponent("document",
            #                     name = "log_frame",
            #                     label = T("Log Frame"),
            #                     fields = ["file"],
            #                     multiple = False,
            #                     ),
            "comments",
        )

        filter_widgets = [
            S3TextFilter(
                [
                    "name",
                    "code",
                    #"description",
                ],
                label=T("Search"),
                comment=T("Search for a Project by name or code"),
            ),
            S3OptionsFilter(
                "status_id",
                label=T("Status"),
                cols=3,
            ),
            S3OptionsFilter(
                "donor.organisation_id",
                label=T("Donor"),
                hidden=True,
            ),
            S3LocationFilter(
                "location.location_id",
                levels=("L1", "L2", "L3"),
                hidden=True,
            ),
            S3OptionsFilter(
                "programme_project.programme_id",
                label=T("Program"),
                hidden=True,
            ),
            #S3OptionsFilter("sector_project.sector_id",
            #                label = T("Sector"),
            #                location_filter = True,
            #                none = True,
            #                hidden = True,
            #                ),
        ]

        list_fields = [
            "status_id",
            "code",
            "name",
            (T("Donors"), "donor.organisation_id"),
            (T("Locations"), "location.location_id"),
            "start_date",
            "end_date",
            "budget",
            "currency",
            (T("Program"), "programme.name"),
        ]

        s3db.configure(
            "project_project",
            crud_form=crud_form,
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#11
0
文件: requests.py 项目: sahana/eden
def send_filter_widgets():
    """
        Filter widgets for outgoing shipments

        @returns: list of filter widgets
    """

    T = current.T

    from s3 import S3DateFilter, \
                   S3LocationFilter, \
                   S3OptionsFilter, \
                   S3TextFilter, \
                   s3_get_filter_opts
    from s3db.inv import SHIP_STATUS_CANCEL, \
                         SHIP_STATUS_RETURNING, \
                         inv_shipment_status_labels

    send_status_opts = OrderedDict(inv_shipment_status_labels())

    # We don't currently use these statuses
    del send_status_opts[SHIP_STATUS_CANCEL]
    del send_status_opts[SHIP_STATUS_RETURNING]

    filter_widgets = [
        S3TextFilter(
            [
                "req_ref",
                #"send_ref",
            ],
            label=T("Search"),
        ),
        S3DateFilter("date"),
        S3OptionsFilter(
            "status",
            cols=3,
            options=send_status_opts,
            sort=False,
        ),
        S3OptionsFilter(
            "track_item.item_id",
            hidden=True,
            options=lambda: s3_get_filter_opts("supply_item"),
        ),
    ]

    if current.auth.s3_has_role("SUPPLY_COORDINATOR"):

        coordinator_filters = [
            S3OptionsFilter(
                "to_site_id$organisation_id$delivery.value",
                label=T("Delivery##supplying"),
                options=delivery_tag_opts(),
            ),
            S3OptionsFilter(
                "site_id",
                label=T("Distribution Center"),
            ),
            S3OptionsFilter(
                "to_site_id",
                hidden=True,
            ),
            S3LocationFilter("to_site_id$location_id",
                             levels=["L3", "L4"],
                             hidden=True),
            S3TextFilter("to_site_id$location_id$addr_postcode",
                         label=T("Postcode"),
                         hidden=True),
        ]
        filter_widgets[3:3] = coordinator_filters

    return filter_widgets
示例#12
0
    def customise_req_site_needs_resource(r, tablename):

        if r.tablename == "req_site_needs":
            table = r.table
            field = table.site_id
            field.label = current.T("Facility")
            field.readable = field.writable = True

            # Allow only facilities which do not have a req_site_needs
            # yet (single component), and filter out obsolete facilities
            from s3 import IS_ONE_OF, FS
            dbset = current.db(table.id == None)
            left = table.on(table.site_id == current.s3db.org_site.id)
            field.requires = IS_ONE_OF(
                dbset,
                "org_site.site_id",
                field.represent,
                left=left,
                not_filterby="obsolete",
                not_filter_opts=(True, ),
                orderby="org_site.name",
                sort=True,
            )
            if not r.record:
                query = FS("site_id$obsolete") != True
                r.resource.add_filter(query)

            # Allow adding of facilities in popup
            from s3layouts import S3PopupLink
            field.comment = S3PopupLink(
                c="org",
                f="facility",
                vars={
                    "child": "site_id",
                    "parent": "site_needs",
                },
                title=T("Add New Facility"),
            )

        # Filters
        from s3 import S3LocationFilter, S3TextFilter
        filter_widgets = [
            S3TextFilter(
                [
                    "site_id$name",
                    "vol_details",
                    "goods_details",
                ],
                label=T("Search"),
            ),
            S3LocationFilter("site_id$location_id", ),
        ]

        # List fields
        list_fields = [
            (T("Facility"), "site_id$name"),
            "site_id$location_id",
            ("%s?" % T("Volunteers"), "vol"),
            (T("Help Wanted"), "vol_details"),
            ("%s?" % T("Donations"), "goods"),
            (T("Donations Needed"), "goods_details"),
            "modified_on",
        ]

        current.s3db.configure(
            "req_site_needs",
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#13
0
    def customise_doc_image_resource(r, tablename):

        from s3 import S3LocationSelector, S3SQLCustomForm  #, S3SQLInlineComponent

        s3db = current.s3db
        table = s3db.doc_image
        table.location_id.widget = S3LocationSelector()  # No Street Address

        s3db.add_components(
            "doc_image",
            event_event="doc_id",
        )

        crud_form = S3SQLCustomForm(
            "file",
            "name",
            "url",
            "date",
            # @ToDo: Have this as an event_id dropdown...defaulting to currently-open Event
            #S3SQLInlineComponent("event"),
            "organisation_id",
            "location_id",
            "comments",
        )

        # Custom filters
        from s3 import S3DateFilter, \
                       S3LocationFilter, \
                       S3OptionsFilter, \
                       S3TextFilter

        filter_widgets = [
            S3TextFilter(
                [
                    "name",
                    "comments",
                ],
                label=T("Search"),
                comment=
                T("Search by disaster name or comments. You can use * as wildcard."
                  ),
            ),
            S3OptionsFilter(
                "event.name",
                label=T("Disaster"),
            ),
            S3LocationFilter("location_id"),
            S3OptionsFilter("organisation_id"),
            S3DateFilter("date"),
        ]

        list_fields = [
            "location_id$L1",
            "location_id$L2",
            "location_id$L3",
            "location_id$L4",
        ]
        if r.controller != "event":
            list_fields.append((T("Disaster"), "event.name"))
        list_fields += [
            "organisation_id",
            "date",
            "name",
        ]

        s3db.configure(
            "doc_image",
            crud_form=crud_form,
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#14
0
    def __call__(self):

        T = current.T
        output = {}
        s3db = current.s3db
        request = current.request

        #------------------------
        # Map to display needs
        map_id = "default_map"

        ftable = s3db.gis_layer_feature
        query = (ftable.controller == "req") & \
                (ftable.function == "need_line")
        layer = current.db(query).select(ftable.layer_id,
                                         limitby=(0, 1)).first()
        try:
            layer_id = layer.layer_id
        except AttributeError:
            current.log.error("Cannot find Layer for Map")
            layer_id = None

        feature_resources = [{
            "name": T("Needs"),
            "id": "search_results",
            "layer_id": layer_id,
            "active": False,
        }]

        _map = current.gis.show_map(
            callback='''S3.search.s3map()''',
            catalogue_layers=True,
            collapsed=True,
            feature_resources=feature_resources,
            save=False,
            search=True,
            toolbar=True,
        )
        output["_map"] = _map

        # ---------------------------------------------------------------------
        # Display needs list
        resource = s3db.resource("req_need_line")
        #resource.table.commit_status.represent = None
        #list_id = "req_datalist"
        #list_fields = [#"purpose",
        #               "location_id",
        #               #"priority",
        #               #"req_ref",
        #               #"site_id",
        #               "date",
        #               ]
        # Order with most recent request first
        #orderby = "req_need.date"
        #datalist, numrows = resource.datalist(fields = list_fields,
        #                                      limit = None,
        #                                      list_id = list_id,
        #                                      orderby = orderby,
        #                                      )
        #if numrows == 0:
        #    current.response.s3.crud_strings["req_need"].msg_no_match = T("No needs at present.")

        #ajax_url = URL(c="req", f="need", args="datalist.dl",
        #               vars={"list_id": list_id})
        #@ToDo: Implement pagination properly
        #output[list_id] = datalist.html(ajaxurl = ajax_url,
        #                                pagesize = 0,
        #                                )

        # ----------------------------
        # Filter Form
        # - can we have a single form for both Activities & Needs?
        #
        filter_widgets = [
            S3TextFilter(
                [  #"need_id$req_number.value",
                    "item_id$name",
                    # These levels are for SHARE/LK
                    #"location_id$L1",
                    "location_id$L2",
                    #"location_id$L3",
                    #"location_id$L4",
                    "need_id$name",
                    "need_id$comments",
                ],
                label=T("Search"),
                comment=
                T("Search for a Need by Request Number, Item, Location, Summary or Comments"
                  ),
            ),
            S3LocationFilter(
                "location_id",
                # These levels are for SHARE/LK
                levels=("L2", "L3", "L4"),
            ),
            S3OptionsFilter("item_id"),
            S3OptionsFilter(
                "status",
                cols=3,
                label=T("Status"),
            ),
            S3OptionsFilter(
                "need_id$event.event_type_id",
                hidden=True,
            ),
            # @ToDo: Filter this list dynamically based on Event Type:
            S3OptionsFilter("need_id$event__link.event_id"),
            S3OptionsFilter(
                "sector_id",
                hidden=True,
            ),
            S3OptionsFilter(
                "need_id$organisation__link.organisation_id",
                hidden=True,
            ),
            S3OptionsFilter(
                "need_id$verified.value",
                cols=2,
                label=T("Verified"),
                hidden=True,
            ),
        ]
        filter_form = S3FilterForm(
            filter_widgets,
            ajax=True,
            submit=True,
            #url = ajax_url,
        )
        output["req_filter_form"] = filter_form.html(
            resource,
            request.get_vars,
            #target = "%s %s" % list_id, map_id
            target=map_id)

        # View title
        output["title"] = current.deployment_settings.get_system_name()

        self._view(THEME, "dashboard.html")

        # Custom JS
        current.response.s3.scripts.append(
            "/%s/static/themes/SHARE/js/homepage.js" % request.application)

        return output
示例#15
0
    def customise_req_need_resource(r, tablename):

        s3db = current.s3db
        tablename = "req_need"

        # Custom Filtered Components
        s3db.add_components(
            tablename,
            req_need_tag=(  # Verified
                {
                    "name": "verified",
                    "joinby": "need_id",
                    "filterby": {
                        "tag": "verified",
                    },
                    "multiple": False,
                }, ))

        # Individual settings for specific tag components
        from gluon import IS_EMPTY_OR, IS_IN_SET
        components_get = r.resource.components.get

        verified = components_get("verified")
        f = verified.table.value
        f.requires = IS_EMPTY_OR(IS_IN_SET((True, False)))
        auth = current.auth
        if auth.s3_has_role("ADMIN"):
            f.default = True
        else:
            user = auth.user
            if user and user.organisation_id:
                f.default = True
            else:
                f.default = False
                f.writable = False

        from s3 import S3LocationFilter, S3OptionsFilter, S3SQLCustomForm, S3SQLInlineComponent, S3SQLInlineLink
        crud_form = S3SQLCustomForm(
            S3SQLInlineLink(
                "event",
                field="event_id",
                label=T("Disaster"),
                multiple=False,
                #required = True,
            ),
            "location_id",
            "date",
            "priority",
            S3SQLInlineLink(
                "sector",
                field="sector_id",
                filter=False,
                label=T("Sector"),
                multiple=False,
            ),
            "summary",
            S3SQLInlineComponent(
                "verified",
                name="verified",
                label=T("Verified"),
                fields=[
                    ("", "value"),
                ],
                multiple=False,
            ),
            "status",
            "comments",
        )

        filter_widgets = [
            S3OptionsFilter("event.event_type_id"),
            S3OptionsFilter(
                "event__link.event_id"
            ),  # @ToDo: Filter this list dynamically based on Event Type
            S3OptionsFilter("sector__link.sector_id"),
            S3LocationFilter(
                "location_id",
                # These levels are for SHARE/LK
                levels=("L2", "L3", "L4"),
            ),
            S3OptionsFilter(
                "status",
                cols=3,
                label=T("Status"),
            ),
            S3OptionsFilter(
                "verified.value",
                cols=2,
                label=T("Verified"),
            ),
        ]

        s3db.configure(
            tablename,
            crud_form=crud_form,
            filter_widgets=filter_widgets,
            list_fields=[
                (T("Disaster"), "event__link.event_id"),
                # These levels/Labels are for SHARE/LK
                (T("District"), "location_id$L2"),
                (T("DS"), "location_id$L3"),
                (T("GN"), "location_id$L4"),
                "date",
                "priority",
                "summary",
                "sector__link.sector_id",
                (T("Status"), "status"),
                (T("Verified"), "verified.value"),
            ],
        )
示例#16
0
def customise_stats_demographic_data_resource(r, tablename):

    s3db = current.s3db
    table = s3db.stats_demographic_data

    # Add a Timeplot tab to summary page
    # @ToDo: Widget version of timeplot
    #settings.ui.summary = list(settings.ui.summary) + {"name": "timeplot",
    #                                                   "label": "TimePlot",
    #                                                   "widgets": [{"method": "timeplot", "ajax_init": True}],
    #                                                   }

    from s3 import S3OptionsFilter, S3LocationFilter
    filter_widgets = [
        S3OptionsFilter(
            "parameter_id",
            label=T("Type"),
            multiple=False,
            # Not translateable
            #represent = "%(name)s",
        ),
        # @ToDo: 'Month' &/or Week VF
        #S3OptionsFilter("month",
        #                #multiple = False,
        #                operator = "anyof",
        #                options = lambda: \
        #                  stats_month_options("stats_demographic_data"),
        #                ),
    ]

    if r.method != "timeplot":
        # This is critical for the Map, but breaks aggregated Report data
        filter_widgets.append(
            S3OptionsFilter(
                "location_id$level",
                label=T("Level"),
                multiple=False,
                # Not translateable
                #represent = "%(name)s",
            ))
    filter_widgets.append(S3LocationFilter("location_id"))

    # Sum doesn't make sense for data which is already cumulative
    #report_options = s3db.get_config(tablename, "report_options")
    #report_options.fact = [(T("Value"), "max(value)")]
    #report_options.defaults.fact = "max(value)"

    #report_options = Storage(rows = location_fields + ["month"],
    #                         cols = ["parameter_id"],
    #                         fact = [(T("Value"), "max(value)"),
    #                                 ],
    #                         defaults = Storage(rows = "location_id",
    #                                            cols = "parameter_id",
    #                                            fact = "max(value)",
    #                                            totals = True,
    #                                            chart = "breakdown:rows",
    #                                            table = "collapse",
    #                                            )
    #                         )

    s3db.configure(
        tablename,
        filter_widgets=filter_widgets,
        #report_options = report_options,
        timeplot_options={
            "defaults": {
                # @ToDo: Total Population?
                #"baseline": "budget_id$total_volume",
                "fact": "cumulate(value)",
                "slots": "",
                "start": "",
                #"end": "+1month",
            },
        },
    )
示例#17
0
文件: config.py 项目: thuyxd/Turkey
        def custom_prep(r):
            # Call standard prep
            if callable(standard_prep):
                result = standard_prep(r)
            else:
                result = True
            if r.controller == "vol":
                s3db = current.s3db
                list_fields = [
                    "person_id",
                ]
                if is_admin:
                    list_fields.append("organisation_id")
                list_fields.extend(
                    ((settings.get_ui_label_mobile_phone(), "phone.value"), ))
                list_fields.extend(((T("Email"), "email.value"), ))
                list_fields.append("location_id$L1")
                list_fields.append("location_id$L2")
                list_fields.append("location_id$L3")
                list_fields.append("person_id$pr_group_membership.group_id")
                list_fields.append(
                    "person_id$pr_group_membership.group_number")
                list_fields.append("person_id$hrm_human_resource.job_title_id")

                from s3 import S3TextFilter, S3OptionsFilter, S3LocationFilter
                filter_widgets = [
                    S3TextFilter(
                        [
                            "person_id$first_name",
                            "person_id$middle_name",
                            "person_id$last_name",
                        ],
                        label=T("Search"),
                    ),
                ]
                if is_admin:
                    filter_widgets.append(S3OptionsFilter("organisation_id"))
                filter_widgets.append(
                    S3LocationFilter(
                        "location_id",
                        levels=("L1", "L2", "L3", "L4"),
                        label=T("Location"),
                        #hidden = True,
                    ), )
                filter_widgets.append(S3OptionsFilter("person_id$gender"))
                filter_widgets.append(
                    S3OptionsFilter("person_id$pr_group_membership.group_id",
                                    label=T("Team"),
                                    none=True,
                                    hidden=True))
                filter_widgets.append(
                    S3OptionsFilter(
                        "person_id$hrm_human_resource.job_title_id",
                        none=True,
                        hidden=True))

                s3db.configure(
                    "hrm_human_resource",
                    list_fields=list_fields,
                    filter_widgets=filter_widgets,
                )

            return result
示例#18
0
    def prep(r):
        # Function to call for all Site Instance Types
        from s3db.org import org_site_prep
        org_site_prep(r)

        if r.interactive:
            if r.component:
                cname = r.component_name
                if cname == "status":
                    table = db.med_hospital_status
                    table.facility_status.comment = DIV(_class = "tooltip",
                                                        _title = "%s|%s" % (T("Facility Status"),
                                                                            T("Status of the facility."),
                                                                            ),
                                                        )
                    table.facility_operations.comment = DIV(_class = "tooltip",
                                                            _title = "%s|%s" % (T("Facility Operations"),
                                                                                T("Overall status of the facility operations."),
                                                                                ),
                                                            )
                    table.clinical_status.comment = DIV(_class = "tooltip",
                                                        _title = "%s|%s" % (T("Clinical Status"),
                                                                            T("Status of the clinical departments."),
                                                                            ),
                                                        )
                    table.clinical_operations.comment = DIV(_class = "tooltip",
                                                            _title = "%s|%s" % (T("Clinical Operations"),
                                                                                T("Overall status of the clinical operations."),
                                                                                ),
                                                            )
                    table.ems_status.comment = DIV(_class = "tooltip",
                                                   _title = "%s|%s" % (T("Emergency Medical Services"),
                                                                       T("Status of operations/availability of emergency medical services at this facility."),
                                                                       ),
                                                   )
                    table.ems_reason.comment = DIV(_class = "tooltip",
                                                   _title = "%s|%s" % (T("EMS Status Reasons"),
                                                                       T("Report the contributing factors for the current EMS status."),
                                                                       ),
                                                   )
                    table.or_status.comment = DIV(_class = "tooltip",
                                                  _title = "%s|%s" % (T("OR Status"),
                                                                      T("Status of the operating rooms of this facility."),
                                                                      ),
                                                  )
                    table.or_reason.comment = DIV(_class = "tooltip",
                                                  _title = "%s|%s" % (T("OR Status Reason"),
                                                                      T("Report the contributing factors for the current OR status."),
                                                                      ),
                                                  )
                    table.morgue_status.comment = DIV(_class = "tooltip",
                                                      _title = "%s|%s" % (T("Morgue Status"),
                                                                          T("Status of morgue capacity."),
                                                                          ),
                                                      )
                    table.morgue_units.comment = DIV(_class = "tooltip",
                                                     _title = "%s|%s" % (T("Morgue Units Available"),
                                                                         T("Number of vacant/available units to which victims can be transported immediately."),
                                                                         ),
                                                     )
                    table.security_status.comment = DIV(_class = "tooltip",
                                                        _title = "%s|%s" % (T("Security Status"),
                                                                            T("Status of security procedures/access restrictions for the facility."),
                                                                            ),
                                                        )
                    table.staffing.comment = DIV(_class = "tooltip",
                                                 _title = "%s|%s" % (T("Staffing Level"),
                                                                     T("Current staffing level at the facility."),
                                                                     ),
                                                 )
                    table.access_status.comment = DIV(_class = "tooltip",
                                                      _title = "%s|%s" % (T("Road Conditions"),
                                                                          T("Describe the condition of the roads from/to the facility."),
                                                                          ),
                                                      )

                elif cname == "bed_capacity":
                    table = db.med_bed_capacity
                    table.bed_type.comment = DIV(_class = "tooltip",
                                                 _title = "%s|%s" % (T("Bed Type"),
                                                                     T("Specify the bed type of this unit."),
                                                                     ),
                                                 )
                    table.beds_baseline.comment = DIV(_class = "tooltip",
                                                      _title = "%s|%s" % (T("Baseline Number of Beds"),
                                                                          T("Baseline number of beds of that type in this unit."),
                                                                          ),
                                                      )
                    table.beds_available.comment = DIV(_class = "tooltip",
                                                       _title = "%s|%s" % (T("Available Beds"),
                                                                           T("Number of available/vacant beds of that type in this unit at the time of reporting."),
                                                                           ),
                                                       )
                    table.beds_add24.comment = DIV(_class = "tooltip",
                                                   _title = "%s|%s" % (T("Additional Beds / 24hrs"),
                                                                       T("Number of additional beds of that type expected to become available in this unit within the next 24 hours."),
                                                                       ),
                                                   )
                elif cname == "activity":
                    table = db.med_hospital_activity
                    table.date.comment = DIV(_class = "tooltip",
                                             _title = "%s|%s" % (T("Date & Time"),
                                                                 T("Date and time this report relates to."),
                                                                 ),
                                             )
                    table.patients.comment = DIV(_class = "tooltip",
                                                 _title = "%s|%s" % (T("Patients"),
                                                                     T("Number of in-patients at the time of reporting."),
                                                                     ),
                                                 )
                    table.admissions24.comment = DIV(_class = "tooltip",
                                                     _title = "%s|%s" % (T("Admissions/24hrs"),
                                                                         T("Number of newly admitted patients during the past 24 hours."),
                                                                         ),
                                                     )

                    table.discharges24.comment = DIV(_class = "tooltip",
                                                     _title = "%s|%s" % (T("Discharges/24hrs"),
                                                                         T("Number of discharged patients during the past 24 hours."),
                                                                         ),
                                                     )
                    table.deaths24.comment = DIV(_class = "tooltip",
                                                 _title = "%s|%s" % (T("Deaths/24hrs"),
                                                                     T("Number of deaths during the past 24 hours."),
                                                                     ),
                                                 )

                elif cname == "image":
                    table = s3db.doc_image
                    table.location_id.readable = table.location_id.writable = False
                    table.organisation_id.readable = table.organisation_id.writable = False
                    table.person_id.readable = table.person_id.writable = False

                elif cname == "ctc":
                    table = db.med_ctc
                    table.ctc.comment = DIV(_class = "tooltip",
                                            _title = "%s|%s" % (T("Cholera Treatment Center"),
                                                                T("Does this facility provide a cholera treatment center?"),
                                                                ),
                                            )
                    table.number_of_patients.comment = DIV(_class = "tooltip",
                                                           _title = "%s|%s" % (T("Current number of patients"),
                                                                               T("How many patients with the disease are currently hospitalized at this facility?"),
                                                                               ),
                                                           )
                    table.cases_24.comment = DIV(_class = "tooltip",
                                                 _title = "%s|%s" % (T("New cases in the past 24h"),
                                                                     T("How many new cases have been admitted to this facility in the past 24h?"),
                                                                     ),
                                                 )
                    table.deaths_24.comment = DIV(_class = "tooltip",
                                                  _title = "%s|%s" % (T("Deaths in the past 24h"),
                                                                      T("How many of the patients with the disease died in the past 24h at this facility?"),
                                                                      ),
                                                  )
                    table.icaths_available.comment = DIV(_class = "tooltip",
                                                         _title = "%s|%s" % (T("Infusion catheters available"),
                                                                             T("Specify the number of available sets"),
                                                                             ),
                                                         )

                    table.icaths_needed_24.comment = DIV(_class = "tooltip",
                                                         _title = "%s|%s" % (T("Infusion catheters need per 24h"),
                                                                             T("Specify the number of sets needed per 24h"),
                                                                             ),
                                                         )

                    table.infusions_available.comment = DIV(_class = "tooltip",
                                                            _title = "%s|%s" % (T("Infusions available"),
                                                                                T("Specify the number of available units (litres) of Ringer-Lactate or equivalent solutions"),
                                                                                ),
                                                            )
                    table.infusions_needed_24.comment = DIV(_class = "tooltip",
                                                            _title = "%s|%s" % (T("Infusions needed per 24h"),
                                                                                T("Specify the number of units (litres) of Ringer-Lactate or equivalent solutions needed per 24h"),
                                                                                ),
                                                            )
                    table.antibiotics_available.comment = DIV(_class = "tooltip",
                                                              _title = "%s|%s" % (T("Antibiotics available"),
                                                                                  T("Specify the number of available units (adult doses)"),
                                                                                  ),
                                                              )
                    table.antibiotics_needed_24.comment = DIV(_class = "tooltip",
                                                              _title = "%s|%s" % (T("Antibiotics needed per 24h"),
                                                                                  T("Specify the number of units (adult doses) needed per 24h"),
                                                                                  ),
                                                              )
                    table.problem_types.comment = DIV(_class = "tooltip",
                                                      _title = "%s|%s" % (T("Current problems, categories"),
                                                                          T("Select all that apply"),
                                                                          ),
                                                      )
                    table.problem_details.comment = DIV(_class = "tooltip",
                                                        _title = "%s|%s" % (T("Current problems, details"),
                                                                            T("Please specify any problems and obstacles with the proper handling of the disease, in detail (in numbers, where appropriate). You may also add suggestions the situation could be improved."),
                                                                            ),
                                                        )
            else:
                # No Component
                table = r.table

                if settings.get_med_have():
                    # HAVE compliance
                    table.town.label = T("Town")

                    components_get = s3db.resource("med_hospital").components.get

                    # UID assigned by Local Government
                    gov_uuid = components_get("gov_uuid")
                    f = gov_uuid.table.value
                    f.requires = IS_EMPTY_OR([IS_LENGTH(128),
                                              IS_NOT_ONE_OF(db, "org_site_tag.value"),
                                              ])
                    f.comment = DIV(_class = "tooltip",
                                    _title = "%s|%s" % (T("Government UID"),
                                                        T("The Unique Identifier (UUID) as assigned to this facility by the government."),
                                                        ),
                                    )

                from s3 import S3LocationFilter, S3OptionsFilter, S3RangeFilter, S3TextFilter
                stable = s3db.med_hospital_status
                filter_widgets = [
                        S3TextFilter(["name",
                                      "code",
                                      "comments",
                                      "organisation_id$name",
                                      "organisation_id$acronym",
                                      "location_id$name",
                                      "location_id$L1",
                                      "location_id$L2",
                                      ],
                                     label = T("Name"),
                                     _class = "filter-search",
                                     ),
                        S3OptionsFilter("facility_type",
                                        label = T("Type"),
                                        #hidden = True,
                                        ),
                        S3LocationFilter("location_id",
                                         label = T("Location"),
                                         levels = ("L0", "L1", "L2"),
                                         #hidden = True,
                                         ),
                        S3OptionsFilter("status.facility_status",
                                        label = T("Status"),
                                        options = stable.facility_status.represent.options,
                                        #represent = "%(name)s",
                                        #hidden = True,
                                        ),
                        S3OptionsFilter("status.power_supply_type",
                                        label = T("Power"),
                                        options = stable.power_supply_type.represent.options,
                                        #represent = "%(name)s",
                                        #hidden = True,
                                        ),
                        S3OptionsFilter("bed_capacity.bed_type",
                                        label = T("Bed Type"),
                                        options = s3db.med_bed_capacity.bed_type.represent.options,
                                        #represent = "%(name)s",
                                        #hidden = True,
                                        ),
                        S3RangeFilter("total_beds",
                                      label = T("Total Beds"),
                                      #represent = "%(name)s",
                                      #hidden = True,
                                      ),
                        ]

                s3db.configure("med_hospital",
                               filter_widgets = filter_widgets,
                               )

                s3.formats["have"] = r.url() # .have added by JS
                # Add comments
                table.total_beds.comment = DIV(_class = "tooltip",
                                               _title = "%s|%s" % (T("Total Beds"),
                                                                   T("Total number of beds in this facility. Automatically updated from daily reports."),
                                                                   ),
                                               )
                table.available_beds.comment = DIV(_class = "tooltip",
                                                   _title = "%s|%s" % (T("Available Beds"),
                                                                       T("Number of vacant/available beds in this facility. Automatically updated from daily reports."),
                                                                       ),
                                                   )

        elif r.representation == "plain":
            # Duplicates info in the other fields
            r.table.location_id.readable = False

        return True
示例#19
0
    def customise_org_facility_resource(r, tablename):

        from s3 import S3SQLCustomForm, S3SQLInlineLink, \
                       S3LocationSelector, S3LocationFilter, S3TextFilter

        s3db = current.s3db

        s3db.org_facility.location_id.widget = S3LocationSelector(
            levels=("L1", "L2", "L3", "L4"),
            required_levels=("L1", "L2", "L3"),
            show_address=True,
            show_postcode=True,
            show_map=True,
        )

        # Geocoder
        current.response.s3.scripts.append(
            "/%s/static/themes/RLP/js/geocoderPlugin.js" % r.application)

        text_fields = [
            "name",
            #"code",
            "comments",
            "organisation_id$name",
            "organisation_id$acronym",
            "location_id$L1",
            "location_id$L2",
            "location_id$L3",
            "location_id$L4",
        ]

        filter_widgets = [
            S3TextFilter(
                text_fields,
                label=T("Search"),
                #_class = "filter-search",
            ),
            S3LocationFilter(
                "location_id",
                #label = T("Location"),
                levels=("L1", "L2", "L3", "L4"),
            ),
        ]

        crud_fields = [
            "name",
            S3SQLInlineLink(
                "facility_type",
                label=T("Facility Type"),
                field="facility_type_id",
                widget="groupedopts",
                cols=3,
            ),
            "organisation_id",
            "location_id",
            (T("Telephone"), "phone1"),
            (T("Opening Hours"), "opening_times"),
            "obsolete",
            "comments",
        ]

        list_fields = [
            "name",
            #"site_facility_type.facility_type_id",
            "location_id$L1",
            "location_id$L2",
            "location_id$L3",
            "location_id$L4",
            "location_id$addr_street",
            "location_id$addr_postcode",
            (T("Telephone"), "phone1"),
            (T("Opening Hours"), "opening_times"),
            "organisation_id",
            #"obsolete",
            #"comments",
        ]

        s3db.configure(
            tablename,
            crud_form=S3SQLCustomForm(*crud_fields),
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#20
0
    def __call__(self):
        """ Main entry point, configuration """

        T = current.T

        # Must be logged in
        auth = current.auth
        if not auth.s3_logged_in():
            auth.permission.fail()

        # Available resources
        resources = [dict(resource="cap_alert",
                          url="cap/alert",
                          label=T("Updates")),
                     ]

        # Filter widgets
        # @note: subscription manager has no resource context, so
        #        must configure fixed options or lookup resources
        #        for filter widgets which need it.
        filters = [S3OptionsFilter("event_type_id",
                                   label = T("Event Type"),
                                   options=self._options("event_type_id"),
                                   widget="multiselect",
                                   resource = "cap_info",
                                   _name = "event-filter",
                                   ),
                   S3OptionsFilter("priority",
                                   label = T("Priority"),
                                   options=self._options("priority"),
                                   widget="multiselect",
                                   resource = "cap_info",
                                   _name = "priority-filter",
                                   ),
                   S3LocationFilter("location_id",
                                    label = T("Location(s)"),
                                    resource = "cap_area_location",
                                    options = self._options("location_id"),
                                    _name = "location-filter",
                                    ),
                   S3OptionsFilter("language",
                                   label = T("Language"),
                                   options = current.deployment_settings.get_cap_languages(),
                                   represent = "%(name)s",
                                   resource = "cap_info",
                                   _name = "language-filter",
                                   ),
                   ]

        filter_script = '''$.filterOptionsS3({
                             'trigger':'event-filter',
                             'target':'priority-filter',
                             'lookupPrefix': 'cap',
                             'lookupResource': 'warning_priority',
                             'lookupKey': 'event_type_id',
                             'showEmptyField': 'false'
                             })'''
        current.response.s3.jquery_ready.append(filter_script)
        
        # Title and view
        title = T("Subscriptions")
        self._view(THEME, "subscriptions.html")

        # Form
        form = self._manage_subscriptions(resources, filters)

        return dict(title = title,
                    form = form,
                    )
示例#21
0
    def customise_project_project_resource(r, tablename):

        s3db = current.s3db

        table = s3db.project_project

        # Make project description mandatory
        field = table.description
        from gluon import IS_NOT_EMPTY
        field.requires = IS_NOT_EMPTY(
            error_message=T("Enter a project description"), )

        if r.interactive:

            # Custom filter widgets
            LEAD_ROLE = settings.get_project_organisation_lead_role()
            org_label = settings.get_project_organisation_roles()[LEAD_ROLE]
            from s3 import S3DateFilter, \
                           S3LocationFilter, \
                           S3OptionsFilter, \
                           S3TextFilter
            filter_widgets = [
                S3TextFilter(
                    [
                        "name",
                        "description",
                    ],
                    label=T("Search"),
                    comment=T("Search for a Project by name or description."),
                ),
                S3LocationFilter("location.location_id", ),
                S3OptionsFilter(
                    "sector_project.sector_id",
                    label=T("Sector"),
                    location_filter=True,
                    none=True,
                ),
                S3OptionsFilter(
                    "hazard_project.hazard_id",
                    label=T("Hazard"),
                    help_field=s3db.project_hazard_help_fields,
                    cols=4,
                    hidden=True,
                ),
                S3OptionsFilter(
                    "status_id",
                    label=T("Status"),
                    cols=4,
                    hidden=True,
                ),
                S3DateFilter(
                    "start_date",
                    hidden=True,
                ),
                S3DateFilter(
                    "end_date",
                    hidden=True,
                ),
                S3OptionsFilter(
                    "organisation_id",
                    label=org_label,
                    hidden=True,
                ),
            ]

            # Custom CRUD form
            from s3 import S3SQLCustomForm, \
                           S3SQLInlineComponent, \
                           S3SQLInlineLink
            crud_form = S3SQLCustomForm(
                "organisation_id",
                "name",
                "description",
                "status_id",
                "start_date",
                "end_date",
                "budget",
                "currency",
                S3SQLInlineLink(
                    "hazard",
                    label=T("Hazards"),
                    field="hazard_id",
                    help_field=s3db.project_hazard_help_fields,
                    cols=4,
                    translate=True,
                ),
                S3SQLInlineLink(
                    "sector",
                    label=T("Sectors"),
                    field="sector_id",
                    cols=4,
                    translate=True,
                ),
                "objectives",
                "human_resource_id",
                S3SQLInlineComponent(
                    "document",
                    fields=[
                        (T("Title"), "name"),
                        "file",
                    ],
                    filterby={
                        "field": "file",
                        "options": "",
                        "invert": True,
                    },
                    label=T("Files"),
                    name="file",
                ),
                S3SQLInlineComponent(
                    "document",
                    fields=[
                        (T("Title"), "name"),
                        "url",
                    ],
                    filterby={
                        "field": "url",
                        "options": None,
                        "invert": True,
                    },
                    label=T("Links"),
                    name="url",
                ),
                "comments",
            )

            s3db.configure(
                "project_project",
                crud_form=crud_form,
                filter_widgets=filter_widgets,
            )

        # Custom list fields
        list_fields = [
            "name",
            "location.location_id",
            "organisation_id",
            (T("Sectors"), "sector_project.sector_id"),
            (T("Hazards"), "hazard_project.hazard_id"),
            "status_id",
            "start_date",
            "end_date",
        ]

        s3db.configure(
            "project_project",
            list_fields=list_fields,
        )
示例#22
0
    def customise_req_req_resource(r, tablename):

        from gluon import IS_EMPTY_OR, IS_IN_SET, SPAN
        from s3 import S3DateFilter, S3LocationFilter, S3OptionsFilter, S3Represent, S3TextFilter

        s3db = current.s3db

        req_status_opts = {
            0: SPAN(
                T("None"),
                _class="req_status_none",
            ),
            1: SPAN(
                T("Partial"),
                _class="req_status_partial",
            ),
            2: SPAN(
                T("Complete"),
                _class="req_status_complete",
            ),
        }

        f = s3db.req_req.req_status
        f.readable = f.writable = True
        f.represent = S3Represent(options=req_status_opts)
        f.requires = IS_EMPTY_OR(IS_IN_SET(req_status_opts))

        f = s3db.req_req.security_req
        f.readable = f.writable = True
        f.label = T("Needs Financing?")

        filter_widgets = [
            S3TextFilter(
                [  #"committer_id$first_name",
                    #"committer_id$middle_name",
                    #"committer_id$last_name",
                    "req_item.item_id",
                    "site_id$name",
                    "comments",
                    #"req_id$name",
                    #"organisation_id$name"
                ],
                label=T("Search"),
                #comment = T("Search for a commitment by Committer name, Request ID, Site or Organization."),
                comment=T("Search for a request by Item, Site or Comments"),
            ),
            S3LocationFilter(
                "site_id$location_id",
                levels=("L1", "L2"),
            ),
            S3OptionsFilter("req_item.item_id", ),
            S3OptionsFilter(
                "req_status",
                cols=3,
                options=req_status_opts,
            ),
            S3OptionsFilter(
                "security_req",
                cols=2,
            ),
            #S3OptionsFilter("commit_status",
            #                cols = 3,
            #                hidden = True,
            #                ),
            #S3OptionsFilter("transit_status",
            #                cols = 3,
            #                hidden = True,
            #                ),
            #S3OptionsFilter("fulfil_status",
            #                cols = 3,
            #                hidden = True,
            #                ),
            S3OptionsFilter(
                "site_id",
                hidden=True,
            ),
            S3OptionsFilter(
                "created_by",
                label=T("Logged By"),
                hidden=True,
            ),
            S3DateFilter(
                "date",
                # Better to default (easier to customise/consistency)
                #label = T("Date Requested"),
                hide_time=True,
                input_labels={
                    "ge": "From",
                    "le": "To"
                },
                comment=T("Search for requests made between these dates."),
                hidden=True,
            ),
            #S3DateFilter("date_required",
            #             # Better to default (easier to customise/consistency)
            #             #label = T("Date Needed By"),
            #             hide_time = True,
            #             input_labels = {"ge": "From", "le": "To"},
            #             comment = T("Search for requests required between these dates."),
            #             hidden = True,
            #             ),
        ]

        list_fields = [
            "date",
            "site_id",
            "req_status",
            "req_item.item_id",
            "security_req",
        ]

        s3db.configure(
            "req_req",
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#23
0
def _newsfeed():
    """
        Custom Page
        - Filterable DataList of CMS Posts & a DataList of Events
    """

    #if not current.auth.is_logged_in():
    #    current.auth.permission.fail()

    T = current.T
    s3db = current.s3db
    request = current.request
    response = current.response
    s3 = response.s3

    # Ensure that filtered views translate into options which update the Widget
    get_vars = request.get_vars
    if "~.series_id$name" in get_vars:
        series_name = get_vars["~.series_id$name"]
        table = s3db.cms_series
        series = current.db(table.name == series_name).select(table.id,
                                                              limitby=(0, 1)).first()
        if series:
            series_id = str(series.id)
            get_vars.pop("~.series_id$name")
            get_vars["~.series_id__belongs"] = series_id

    current.deployment_settings.customise_controller("cms_post")

    list_layout = s3.render_posts

    filter_widgets = [S3TextFilter(["body"],
                                   label="",
                                   _class="filter-search",
                                   #_placeholder=T("Search").upper(),
                                   ),
                      S3OptionsFilter("series_id",
                                      label=T("Filter by Type"),
                                      represent="%(name)s",
                                      widget="multiselect",
                                      hidden=True,
                                      ),
                      S3LocationFilter("location_id",
                                       label=T("Filter by Location"),
                                       levels=("L1", "L2", "L3"),
                                       widget="multiselect",
                                       hidden=True,
                                       ),
                      S3OptionsFilter("created_by$organisation_id",
                                      label=T("Filter by Organization"),
                                      # Can't use this for integers, use field.represent instead
                                      #represent="%(name)s",
                                      widget="multiselect",
                                      hidden=True,
                                      ),
                      S3DateFilter("created_on",
                                   label=T("Filter by Date"),
                                   hide_time=True,
                                   hidden=True,
                                   ),
                      ]

    s3db.configure("cms_post",
                   # We use a custom Advanced widget
                   filter_advanced = False,
                   filter_formstyle = filter_formstyle,
                   filter_submit = (T("SEARCH"), "btn btn-primary"),
                   filter_widgets = filter_widgets,
                   list_layout = list_layout,
                   # Create form comes via AJAX in a Modal
                   insertable = False,
                   notify_fields = [(T("Type"), "series_id"),
                                    (T("Date"), "date"),
                                    (T("Location"), "location_id"),
                                    (T("Description"), "body"),
                                    ],
                   notify_template = "notify_post",
                   )

    s3.dl_pagelength = 6  # 5 forces an AJAX call

    old_args = request.args
    if "datalist_dl_post" in old_args:
        # DataList pagination or Ajax-deletion request
        request.args = ["datalist_f"]
        ajax = "list"
    elif "datalist_dl_filter" in old_args:
        # FilterForm options update request
        request.args = ["filter"]
        ajax = "filter"
    elif "validate.json" in old_args:
        # Inline component validation request
        request.args = []
        ajax = True
    elif current.auth.permission.format == "msg":
        # Subscription lookup request
        request.args = []
        ajax = True
    else:
        # Default
        request.args = ["datalist_f"]
        ajax = None

    def prep(r):
        if ajax == "list":
            r.representation = "dl"
        elif ajax == "filter":
            r.representation = "json"
        return True
    s3.prep = prep

    output = current.rest_controller("cms", "post",
                                     list_ajaxurl = URL(f="index",
                                                        args="datalist_dl_post"),
                                     filter_ajax_url = URL(f="index",
                                                           args="datalist_dl_filter",
                                                           vars={}),
                                     )

    request.args = old_args

    if ajax == "list":
        # Don't override view if this is an Ajax-deletion request
        if not "delete" in request.get_vars:
            response.view = "plain.html"
    elif not ajax:
        # Set Title & View after REST Controller, in order to override
        output["title"] = T("News Feed")
        view = path.join(request.folder, "modules", "templates",
                         THEME, "views", "newsfeed.html")
        try:
            # Pass view as file not str to work in compiled mode
            response.view = open(view, "rb")
        except IOError:
            from gluon.http import HTTP
            raise HTTP(404, "Unable to open Custom View: %s" % view)

        s3.js_global.append('''i18n.adv_search="%s"''' % T("Advanced Search"))
        s3.scripts.append("/%s/static/themes/%s/js/newsfeed.js" % (request.application, THEME))

        # Latest 5 Disasters
        resource = s3db.resource("event_event")
        layout = render_events
        list_id = "event_datalist"
        limit = 5
        orderby = "start_date desc"
        list_fields = ["name",
                       "event_type_id$name",
                       "start_date",
                       "closed",
                       ]
        output["disasters"] = latest_records(resource, layout, list_id, limit, list_fields, orderby)

    return output
示例#24
0
    def customise_org_organisation_resource(r, tablename):

        from gluon.html import DIV, INPUT
        from s3 import s3_comments_widget, \
                       S3LocationSelector, \
                       S3MultiSelectWidget, \
                       S3SQLCustomForm, \
                       S3SQLInlineComponent, \
                       S3SQLVerticalSubFormLayout

        s3db = current.s3db

        # Filtered component to access phone number and email
        s3db.add_components(
            tablename,
            org_facility={
                "name": "main_facility",
                "joinby": "organisation_id",
                "filterby": {
                    "main_facility": True,
                },
            },
        )

        s3db.org_organisation_location.location_id.widget = S3LocationSelector(
            levels=("L2", "L3"),
            show_map=False,
            labels=False,
        )

        crud_fields = [
            "name",
            "acronym",
            S3SQLInlineLink(
                "organisation_type",
                field="organisation_type_id",
                label=T("Type"),
                multiple=False,
            ),
            S3SQLInlineLink(
                "service",
                label=T("Services"),
                field="service_id",
            ),
            S3SQLInlineComponent(
                "facility",
                label=T("Main Facility"),
                fields=[
                    "name",
                    "phone1",
                    "phone2",
                    "email",
                    "location_id",
                ],
                layout=S3SQLVerticalSubFormLayout,
                filterby={
                    "field": "main_facility",
                    "options": True,
                },
                multiple=False,
            ),
            "website",
            S3SQLInlineComponent(
                "contact",
                name="twitter",
                label=T("Twitter"),
                multiple=False,
                fields=[("", "value")],
                filterby=dict(
                    field="contact_method",
                    options="TWITTER",
                ),
            ),
            S3SQLInlineComponent(
                "contact",
                name="facebook",
                label=T("Facebook"),
                multiple=False,
                fields=[("", "value")],
                filterby=dict(
                    field="contact_method",
                    options="FACEBOOK",
                ),
            ),
            "comments",
        ]

        crud_form = S3SQLCustomForm(*crud_fields)

        from s3 import S3LocationFilter, S3OptionsFilter, S3TextFilter  #, S3HierarchyFilter
        filter_widgets = [
            S3TextFilter(
                ["name", "acronym"],
                label=T("Search"),
                comment=
                T("Search by organization name or acronym. You can use * as wildcard."
                  ),
                _class="filter-search",
            ),
            S3LocationFilter(
                "org_facility.location_id",
                label=T("Location"),
                #hidden = True,
            ),
            S3OptionsFilter(
                "organisation_organisation_type.organisation_type_id",
                label=T("Type"),
                #hidden = True,
            ),
            S3OptionsFilter("service_organisation.service_id",
                            #hidden = True,
                            ),
        ]

        list_fields = [
            "name",
            (T("Type"), "organisation_organisation_type.organisation_type_id"),
            (T("Services"), "service.name"),
            (T("Adresse"), "main_facility.location_id"),
            (T("Phone #"), "main_facility.phone1"),
            (T("Email"), "main_facility.email"),
            (T("Facebook"), "facebook.value"),
            "website",
            (T("Last Updated"), "modified_on"),
        ]

        s3db.configure(
            tablename,
            crud_form=crud_form,
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#25
0
文件: evr.py 项目: rullmanmike/eden
    def prep(r):

        fiscal_code = s3db.evr_case.fiscal_code
        levels = current.gis.get_relevant_hierarchy_levels()

        if r.method == "update":
            fiscal_code.requires = None
        else:
            fiscal_code.requires = \
                    IS_EMPTY_OR(IS_NOT_IN_DB(db(db.evr_case.deleted != True),
                                             fiscal_code),
                                null=""
                                )

        report_fields = [
            "id",
            "last_name",
            "case.organisation_id",
            "gender",
            "date_of_birth",
            "person_details.nationality",
            "person_details.marital_status",
            "shelter_registration.shelter_id",
            "shelter_registration.check_in_date",
            "shelter_registration.check_out_date",
        ]
        if settings.get_cr_shelter_housing_unit_management():
            report_fields.append("shelter_registration.shelter_unit_id")

        for level in levels:
            lfield = "location_id$%s" % level
            report_fields.append(lfield)

        report_options = Storage(
            rows=report_fields,
            cols=report_fields,
            fact=report_fields,
            defaults=Storage(
                rows="shelter_registration.shelter_id",
                cols="gender",
                #totals=True,
            ))
        list_fields = [
            "id",
            "first_name",
            #"middle_name",
            "last_name",
            "gender",
            "date_of_birth",
        ]
        if settings.get_evr_link_to_organisation():
            list_fields.append("case.organisation_id")
        list_fields.append("shelter_registration.shelter_id")
        if settings.get_cr_shelter_housing_unit_management():
            list_fields.append("shelter_registration.shelter_unit_id")
        list_fields.append("shelter_registration.check_in_date")
        list_fields.append("shelter_registration.check_out_date")

        r.resource.configure(list_fields=list_fields,
                             report_options=report_options)

        if r.interactive and not r.component:

            resource = r.resource

            # Filter widgets
            from s3 import S3OptionsFilter, S3TextFilter, S3LocationFilter, S3DateFilter
            filter_widgets = [
                S3TextFilter(
                    [
                        "first_name",
                        #"middle_name",
                        "last_name",
                        #"local_name",
                        "identity.value",
                        "case.fiscal_code",
                    ],
                    label=T("Name and/or ID"),
                    comment=T("To search for a person, enter any of the "
                              "first, middle or last names and/or an ID "
                              "number of a person, separated by spaces. "
                              "You may use % as wildcard."),
                ),
                S3LocationFilter(
                    "address.location_id",
                    label=T("Current Residence"),
                    levels=levels,
                ),
                S3DateFilter("date_of_birth", label=T("Date Of Birth")),
                S3OptionsFilter(
                    "person_details.nationality",
                    label=T("Nationality"),
                ),
                S3OptionsFilter(
                    "case.organisation_id",
                    label=T("Organisation"),
                ),
                S3OptionsFilter(
                    "shelter_registration.shelter_id",
                    label=T("Shelter"),
                ),
                S3OptionsFilter(
                    "shelter_registration.registration_status",
                    label=T("Registration Status"),
                ),
            ]

            # Custom Form for Persons
            from s3 import S3SQLCustomForm, S3SQLInlineComponent
            crud_form = S3SQLCustomForm(
                "case.organisation_id",
                "first_name",
                #"middle_name",
                "last_name",
                "date_of_birth",
                "location_id",
                "person_details.place_of_birth",
                "case.fiscal_code",
                S3SQLInlineComponent(
                    "identity",
                    label=T("Identity Documents"),
                    fields=[
                        "type",
                        "value",
                    ],
                ),
                "person_details.nationality",
                "gender",
                "person_details.marital_status",
                "person_details.religion",
                "person_details.occupation",
                #"person_details.company",
                "comments",
            )
            resource.configure(
                crud_form=crud_form,
                filter_widgets=filter_widgets,
            )

        elif r.representation in ("pdf", "xls"):
            # List fields
            list_fields = [
                "id",
                "first_name",
                #"middle_name",
                "last_name",
                "gender",
                #"date_of_birth",
                (T("Age"), "age"),
                "person_details.nationality",
                "person_details.religion",
                (T("Contact"), "contact.value"),
                (T("Shelter"), "shelter_registration.shelter_id$name")
            ]
            r.resource.configure(list_fields=list_fields)
        return True
示例#26
0
    def customise_req_organisation_needs_resource(r, tablename):

        s3db = current.s3db
        table = current.s3db.req_organisation_needs

        CASH = T("Cash Donations needed")

        if r.tablename == "req_organisation_needs":

            from s3 import IS_ONE_OF, S3DateTime

            # Allow only organisations which do not have a needs record
            # yet (single component):
            field = table.organisation_id
            dbset = current.db(table.id == None)
            left = table.on(
                table.organisation_id == current.s3db.org_organisation.id)
            field.requires = IS_ONE_OF(
                dbset,
                "org_organisation.id",
                field.represent,
                left=left,
                orderby="org_organisation.name",
                sort=True,
            )

            # Format modified_on as date
            field = table.modified_on
            field.represent = lambda d: S3DateTime.date_represent(d, utc=True)

        if r.representation in ("html", "aadata", "iframe"):

            # Structured lists for interactive views
            from gluon import Field
            table.needs_skills = Field.Method(lambda row: \
                                    organisation_needs(row, need_type="skills"))
            table.needs_items = Field.Method(lambda row: \
                                    organisation_needs(row, need_type="items"))
            current.response.s3.stylesheets.append("../themes/RW/needs.css")

            needs_skills = (T("Volunteers needed"), "needs_skills")
            needs_items = (T("Supplies needed"), "needs_items")

            # Filter widgets
            from s3 import S3LocationFilter, S3OptionsFilter, S3TextFilter
            filter_widgets = [  #S3TextFilter(["organisation_id$name",
                #              ],
                #              label = T("Search"),
                #             ),
                S3OptionsFilter("organisation_id"),
                S3OptionsFilter(
                    "organisation_needs_skill.skill_id",
                    label=T("Skills sought"),
                ),
                S3OptionsFilter(
                    "organisation_needs_item.item_id",
                    label=T("Supplies sought"),
                ),
                S3LocationFilter(
                    "organisation_id$active_service_location.site_id$location_id",
                ),
            ]

            # CRUD form
            from s3 import S3SQLCustomForm, S3SQLInlineComponent
            crud_form = S3SQLCustomForm(
                "organisation_id",
                S3SQLInlineComponent(
                    "organisation_needs_skill",
                    label=T("Volunteers needed"),
                    fields=[
                        "skill_id",
                        "demand",
                        "comments",
                    ],
                ),
                S3SQLInlineComponent(
                    "organisation_needs_item",
                    label=T("Supplies needed"),
                    fields=[
                        "item_id",
                        "demand",
                        "comments",
                    ],
                ),
                (CASH, "money"),
                "money_details",
                #"vol",
                #"vol_details",
            )

            next_page = r.url(method="") \
                        if r.tablename == "req_organisation_needs" else None

            s3db.configure(
                "req_organisation_needs",
                crud_form=crud_form,
                filter_widgets=filter_widgets,
                create_next=next_page,
                update_next=next_page,
            )
        else:
            # Simple fields for exports
            needs_skills = (T("Volunteers needed"),
                            "organisation_needs_skill.skill_id")
            needs_items = (T("Supplies needed"),
                           "organisation_needs_item.item_id")

        # List fields (all formats)
        list_fields = [
            "organisation_id",
            needs_skills,
            needs_items,
            (CASH, "money"),
            (T("Cash Donation Details"), "money_details"),
            (T("Last Update"), "modified_on"),
        ]

        s3db.configure(
            "req_organisation_needs",
            list_fields=list_fields,
        )
示例#27
0
    def customise_dc_target_resource(r, tablename):

        if r.controller in (
                "event",
                "hrm",  # Training Event Evaluations
        ):
            return

        s3db = current.s3db

        template_name = r.get_vars.get("~.template_id$name")
        if template_name:
            ttable = s3db.dc_template
            template = current.db(ttable.name == template_name).select(
                ttable.id,
                limitby=(0, 1),
            ).first()
            if template:
                f = s3db.dc_target.template_id
                f.default = template.id
                f.readable = f.writable = False

            current.response.s3.crud_strings[tablename] = Storage(
                label_create=T("Create %s") % template_name,
                title_display=T("%s Details") % template_name,
                title_list=T("%ss") % template_name,
                title_update=T("Edit %s") % template_name,
                #title_upload = T("Import %ss") % template_name,
                label_list_button=T("List %ss") % template_name,
                label_delete_button=T("Delete %s") % template_name,
                msg_record_created=T("%s added") % template_name,
                msg_record_modified=T("%s updated") % template_name,
                msg_record_deleted=T("%s deleted") % template_name,
                msg_list_empty=T("No %ss currently registered") %
                template_name)

        from s3 import S3DateFilter, S3LocationFilter, S3OptionsFilter, S3SQLCustomForm, S3SQLInlineLink

        crud_form = S3SQLCustomForm(
            S3SQLInlineLink(
                "event",
                field="event_id",
                #label = type_label,
                multiple=False,
            ),
            "template_id",
            "date",
            "location_id",
            "comments",
        )

        filter_widgets = [
            S3OptionsFilter("event__link.event_id"),
            S3LocationFilter(),
            S3DateFilter("date"),
        ]

        list_fields = [
            "event__link.event_id",
            "location_id$L1",
            "location_id$L2",
            (T("Hazard Type"), "name"),
            (T("Reporting Date"), "date"),
            (T("Reported by"), "created_by"),
        ]

        s3db.configure(
            tablename,
            crud_form=crud_form,
            filter_widgets=filter_widgets,
            list_fields=list_fields,
        )
示例#28
0
    def customise_project_activity_resource(r, tablename):

        s3db = current.s3db
        tablename = "project_activity"

        # Custom Filtered Components
        s3db.add_components(
            tablename,
            project_activity_organisation=(  # Agency
                {
                    "name": "agency",
                    "joinby": "activity_id",
                    "filterby": {
                        "role": 1,
                    },
                    #"multiple": False,
                },
                # Partners
                {
                    "name": "partner",
                    "joinby": "activity_id",
                    "filterby": {
                        "role": 2,
                    },
                    #"multiple": False,
                },
                # Donors
                {
                    "name": "donor",
                    "joinby": "activity_id",
                    "filterby": {
                        "role": 3,
                    },
                    #"multiple": False,
                },
            ),
            project_activity_tag=(  # Modality
                {
                    "name": "modality",
                    "joinby": "activity_id",
                    "filterby": {
                        "tag": "modality",
                    },
                    "multiple": False,
                },
                # Number
                {
                    "name": "number",
                    "joinby": "activity_id",
                    "filterby": {
                        "tag": "number",
                    },
                    "multiple": False,
                },
            ))

        # Individual settings for specific tag components
        from gluon import IS_EMPTY_OR, IS_IN_SET, IS_INT_IN_RANGE
        components_get = r.resource.components.get

        donor = components_get("donor")
        donor.table.organisation_id.default = None

        partner = components_get("partner")
        partner.table.organisation_id.default = None

        modality = components_get("modality")
        modality.table.value.requires = IS_EMPTY_OR(
            IS_IN_SET(("Cash", "In-kind")))

        number = components_get("number")
        number.table.value.requires = IS_EMPTY_OR(IS_INT_IN_RANGE())

        s3db.project_activity_data.unit.requires = IS_EMPTY_OR(
            IS_IN_SET(("People", "Households")))

        from s3 import S3LocationFilter, S3OptionsFilter, S3SQLCustomForm, S3SQLInlineComponent, S3SQLInlineLink
        crud_form = S3SQLCustomForm(
            S3SQLInlineLink(
                "event",
                field="event_id",
                label=T("Disaster"),
                multiple=False,
                #required = True,
            ),
            S3SQLInlineComponent(
                "agency",
                name="agency",
                label=T("Agency"),
                fields=[
                    ("", "organisation_id"),
                ],
                #multiple = False,
                required=True,
            ),
            # @ToDo: MultiSelectWidget is nicer UI but S3SQLInlineLink
            #        requires the link*ed* table as component (not the
            #        link table as applied here) and linked components
            #        cannot currently be filtered by link table fields
            #        (=> should solve the latter rather than the former)
            # @ToDo: Fix Create Popups
            S3SQLInlineComponent(
                "partner",
                name="partner",
                label=T("Implementing Partner"),
                fields=[
                    ("", "organisation_id"),
                ],
            ),
            S3SQLInlineComponent(
                "donor",
                name="donor",
                label=T("Donor"),
                fields=[
                    ("", "organisation_id"),
                ],
            ),
            "location_id",
            S3SQLInlineLink(
                "sector",
                field="sector_id",
                filter=False,
                label=T("Sector"),
                multiple=False,
            ),
            (T("Relief Items/Activity"), "name"),
            S3SQLInlineComponent(
                "modality",
                name="modality",
                label=T("Modality"),
                fields=[
                    ("", "value"),
                ],
                multiple=False,
            ),
            S3SQLInlineComponent(
                "number",
                name="number",
                label=T("Number of Items/Kits/Activities"),
                fields=[
                    ("", "value"),
                ],
                multiple=False,
            ),
            (T("Activity Date (Planned/Start Date)"), "date"),
            (T("Activity Date (Completion Date)"), "end_date"),
            S3SQLInlineComponent(
                "activity_data",
                label="",
                fields=[
                    (T("People / Households"), "unit"),
                    (T("Total Number People/HH Targeted"), "target_value"),
                    (T("Total Number Of People/HH Reache"), "value"),
                ],
                multiple=False,
            ),
            (T("Activity Status"), "status_id"),
            "comments",
        )

        filter_widgets = [
            S3OptionsFilter("event.event_type_id"),
            S3OptionsFilter(
                "event__link.event_id"
            ),  # @ToDo: Filter this list dynamically based on Event Type
            S3OptionsFilter("sector_activity.sector_id"),
            S3LocationFilter(
                "location_id",
                # These levels are for SHARE/LK
                levels=("L2", "L3", "L4"),
            ),
            S3OptionsFilter(
                "status_id",
                cols=4,
                label=T("Status"),
            ),
        ]

        s3db.configure(
            tablename,
            crud_form=crud_form,
            filter_widgets=filter_widgets,
            list_fields=[
                (T("Disaster"), "event__link.event_id"),
                (T("Agency"), "agency.organisation_id"),
                (T("Implementing Partner"), "partner.organisation_id"),
                (T("Donor"), "donor.organisation_id"),
                (T("District"), "location_id$L1"),
                (T("DS Division"), "location_id$L2"),
                (T("GN Division"), "location_id$L3"),
                (T("Sector"), "sector_activity.sector_id"),
                (T("Relief Items/Activity"), "name"),
                (T("Modality"), "modality.value"),
                (T("Number of Items/Kits/Activities"), "number.value"),
                (T("Activity Date (Planned/Start Date)"), "date"),
                (T("Activity Date (Completion Date)"), "end_date"),
                (T("People / Households"), "activity_data.unit"),
                (T("Total Number People/HH Targeted"),
                 "activity_data.target_value"),
                (T("Total Number Of People/HH Reached"),
                 "activity_data.value"),
                (T("Activity Status"), "status_id"),
                "comments",
            ],
        )