コード例 #1
0
ファイル: config.py プロジェクト: Timileyin5/eden
    def customise_event_asset_resource(r, tablename):

        table = current.s3db.event_asset
        table.item_id.label = T("Item Type")
        table.asset_id.label = T("Specific Item")
        # DateTime
        from gluon import IS_EMPTY_OR
        from s3 import IS_UTC_DATETIME, S3CalendarWidget, S3DateTime
        for f in (table.start_date, table.end_date):
            f.requires = IS_EMPTY_OR(IS_UTC_DATETIME())
            f.represent = lambda dt: S3DateTime.datetime_represent(dt,
                                                                   utc=True)
            f.widget = S3CalendarWidget(timepicker=True)

        current.response.s3.crud_strings[tablename] = Storage(
            label_create=T("Add Equipment"),
            title_display=T("Equipment Details"),
            title_list=T("Equipment"),
            title_update=T("Edit Equipment"),
            label_list_button=T("List Equipment"),
            label_delete_button=T("Remove Equipment from this incident"),
            msg_record_created=T("Equipment added"),
            msg_record_modified=T("Equipment updated"),
            msg_record_deleted=T("Equipment removed"),
            msg_list_empty=T(
                "No Equipment currently registered for this incident"))
コード例 #2
0
ファイル: config.py プロジェクト: Timileyin5/eden
    def customise_event_human_resource_resource(r, tablename):

        s3db = current.s3db
        table = s3db.event_human_resource
        # DateTime
        from gluon import IS_EMPTY_OR
        from s3 import IS_UTC_DATETIME, S3CalendarWidget, S3DateTime
        for f in (table.start_date, table.end_date):
            f.requires = IS_EMPTY_OR(IS_UTC_DATETIME())
            f.represent = lambda dt: S3DateTime.datetime_represent(dt,
                                                                   utc=True)
            f.widget = S3CalendarWidget(timepicker=True)

        current.response.s3.crud_strings[tablename] = Storage(
            label_create=T("Add Person"),
            title_display=T("Person Details"),
            title_list=T("Personnel"),
            title_update=T("Edit Person"),
            label_list_button=T("List Personnel"),
            label_delete_button=T("Remove Person from this incident"),
            msg_record_created=T("Person added"),
            msg_record_modified=T("Person updated"),
            msg_record_deleted=T("Person removed"),
            msg_list_empty=T(
                "No Persons currently registered for this incident"))

        s3db.configure(
            tablename,
            # Deliberately over-rides
            create_onaccept=event_human_resource_onaccept,
            update_onaccept=lambda form: event_human_resource_onaccept(
                form, create=False),
        )
コード例 #3
0
ファイル: controllers.py プロジェクト: nursix/eden
    def last_update(cls):
        """
            Get last update time of homepage stats

            @returns: a date/time string in local format and timezone
        """

        import datetime, os
        from s3 import S3DateTime

        # Probe file (probing one is good enough since update_data
        # writes them all at the same time)
        filename = os.path.join(current.request.folder,
                                "static", "themes", "SHARE", "data",
                                "people_affected.json",
                                )
        try:
            mtime = os.path.getmtime(filename)
        except OSError:
            last_update = None
        else:
            dt = datetime.datetime.utcfromtimestamp(mtime)
            last_update = S3DateTime.datetime_represent(dt, utc=True)

        return last_update
コード例 #4
0
    def last_update(cls):
        """
            Get last update time of homepage stats

            @returns: a date/time string in local format and timezone
        """

        import datetime, os
        from s3 import S3DateTime

        # Probe file (probing one is good enough since update_data
        # writes them all at the same time)
        filename = os.path.join(
            current.request.folder,
            "static",
            "themes",
            "SHARE",
            "data",
            "people_affected.json",
        )
        try:
            mtime = os.path.getmtime(filename)
        except OSError:
            last_update = None
        else:
            dt = datetime.datetime.utcfromtimestamp(mtime)
            last_update = S3DateTime.datetime_represent(dt, utc=True)

        return last_update
コード例 #5
0
ファイル: config.py プロジェクト: waidyanatha/eden
    def customise_event_human_resource_resource(r, tablename):

        s3db = current.s3db
        table = s3db.event_human_resource
        # DateTime
        from gluon import IS_EMPTY_OR
        from s3 import IS_UTC_DATETIME, S3CalendarWidget, S3DateTime
        for f in (table.start_date, table.end_date):
            f.requires = IS_EMPTY_OR(IS_UTC_DATETIME())
            f.represent = lambda dt: S3DateTime.datetime_represent(dt, utc=True)
            f.widget = S3CalendarWidget(timepicker = True)

        current.response.s3.crud_strings[tablename] = Storage(
            label_create = T("Add Person"),
            title_display = T("Person Details"),
            title_list = T("Personnel"),
            title_update = T("Edit Person"),
            label_list_button = T("List Personnel"),
            label_delete_button = T("Remove Person from this incident"),
            msg_record_created = T("Person added"),
            msg_record_modified = T("Person updated"),
            msg_record_deleted = T("Person removed"),
            msg_list_empty = T("No Persons currently registered for this incident"))

        s3db.configure(tablename,
                       # Deliberately over-rides
                       create_onaccept = event_human_resource_onaccept,
                       update_onaccept = lambda form:
                            event_human_resource_onaccept(form, create=False),
                       )
コード例 #6
0
    def rheader(self, r):
        """
            Show the current date in the output

            @param r: the S3Request
            @returns: the page header (rheader)
        """

        from s3 import S3DateTime
        today = S3DateTime.datetime_represent(r.utcnow, utc=True)

        return P("%s: %s" % (current.T("Date"), today))
コード例 #7
0
ファイル: controllers.py プロジェクト: nursix/eden
    def rheader(self, r):
        """
            Show the current date in the output

            @param r: the S3Request
            @returns: the page header (rheader)
        """

        from s3 import S3DateTime
        today = S3DateTime.datetime_represent(r.utcnow, utc=True)

        return P("%s: %s" % (current.T("Date"), today))
コード例 #8
0
ファイル: config.py プロジェクト: flavour/aidiq
    def customise_event_asset_resource(r, tablename):

        table = current.s3db.event_asset
        table.item_id.label = T("Item Type")
        table.asset_id.label = T("Specific Item")
        # DateTime
        from gluon import IS_EMPTY_OR
        from s3 import IS_UTC_DATETIME, S3CalendarWidget, S3DateTime
        for f in (table.start_date, table.end_date):
            f.requires = IS_EMPTY_OR(IS_UTC_DATETIME())
            f.represent = lambda dt: S3DateTime.datetime_represent(dt, utc=True)
            f.widget = S3CalendarWidget(timepicker = True)

        current.response.s3.crud_strings[tablename] = Storage(
            label_create = T("Add Equipment"),
            title_display = T("Equipment Details"),
            title_list = T("Equipment"),
            title_update = T("Edit Equipment"),
            label_list_button = T("List Equipment"),
            label_delete_button = T("Remove Equipment from this incident"),
            msg_record_created = T("Equipment added"),
            msg_record_modified = T("Equipment updated"),
            msg_record_deleted = T("Equipment removed"),
            msg_list_empty = T("No Equipment currently registered for this incident"))
コード例 #9
0
ファイル: deploy.py プロジェクト: sahana/eden
    def prep(r):
        # Configure created_on field in deploy_mission
        #created_on = r.table.created_on
        #created_on.readable = True
        #created_on.label = T("Date Created")
        #from s3 import S3DateTime
        #created_on.represent = lambda d: \
        #                       S3DateTime.date_represent(d, utc=True)
        if r.id:
            # Mission-specific workflows return to the profile page
            tablename = r.tablename if not r.component else r.component.tablename
            next_url = r.url(component="", method="profile", vars={})
            if r.component_name == "alert":
                alert_create_script()
                if settings.get_deploy_manual_recipients():
                    create_next = URL(f="alert", args=["[id]", "select"])
                else:
                    create_next = next_url
                s3db.configure(tablename,
                               create_next = create_next,
                               delete_next = next_url,
                               update_next = next_url,
                               )
            else:
                s3db.configure(tablename,
                               create_next = next_url,
                               delete_next = next_url,
                               update_next = next_url,
                               )
            s3.cancel = next_url
            if r.component_name == "assignment":
                member_id = r.get_vars.get("member_id", None)
                if member_id and str(member_id).isdigit():
                    # Deploy-this-member action
                    htable = s3db.hrm_human_resource
                    query = (htable.id == member_id) & \
                            (htable.deleted != True)
                    row = db(query).select(htable.id,
                                           limitby = (0, 1)
                                           ).first()
                    if row:
                        field = s3db.deploy_assignment.human_resource_id
                        field.default = row.id
                        field.writable = False
                        field.comment = None
                elif r.method == "create":
                    atable = s3db.deploy_assignment
                    atable.end_date.writable = atable.end_date.readable = False
            if not r.component and r.method == "profile":
                from s3 import s3_trunk8, S3DateTime
                represent = lambda d: \
                            S3DateTime.datetime_represent(d, utc=True)
                s3db.deploy_alert.modified_on.represent = represent
                s3db.deploy_response.created_on.represent = represent
                s3_trunk8(lines=1)
        else:
            # All other workflows return to the summary page
            s3.cancel = r.url(method="summary", component=None, id=0)
            if not r.component:
                status = r.get_vars.get("~.status__belongs")
                if status == "2":
                    s3.crud_strings[r.tablename]["title_list"] = T("Active Missions")
                elif status == "1":
                    s3.crud_strings[r.tablename]["title_list"] = T("Closed Missions")

        return True