@staticmethod
    def irs_timeline(r, **attr):

        if r.representation == "html" and r.name == "ireport":

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

            itable = s3db.doc_image
            dtable = s3db.doc_document

            # Add core Simile Code
            s3.scripts.append("/%s/static/scripts/simile/timeline/timeline-api.js" % request.application)

            # Add our control script
            if s3.debug:
                s3.scripts.append("/%s/static/scripts/S3/s3.timeline.js" % request.application)
            else:
                s3.scripts.append("/%s/static/scripts/S3/s3.timeline.min.js" % request.application)

            # Add our data
            # @ToDo: Make this the initial data & then collect extra via REST with a stylesheet
            # add in JS using S3.timeline.eventSource.addMany(events) where events is a []
            if r.record:
                # Single record
                rows = [r.record]
            else:
                # Multiple records
                # @ToDo: Load all records & sort to closest in time
                # http://stackoverflow.com/questions/7327689/how-to-generate-a-sequence-of-future-datetimes-in-python-and-determine-nearest-d
                r.resource.load(limit=2000)
                rows = r.resource._rows

            data = {"dateTimeFormat": "iso8601",
                    }

            now = request.utcnow
            tl_start = tl_end = now
            events = []
            for row in rows:
                # Dates
                start = row.datetime or ""
                if start:
                    if start < tl_start:
                        tl_start = start
                    if start > tl_end:
                        tl_end = start
                    start = start.isoformat()
                end = row.expiry or ""
                if end:
                    if end > tl_end:
                        tl_end = end
                    end = end.isoformat()
                # Image
                # Just grab the first one for now
                query = (itable.deleted == False) & \
                        (itable.doc_id == row.doc_id)
                image = db(query).select(itable.url,
                                         limitby=(0, 1)).first()
                if image:
                    image = image.url or ""
                # URL
                link = URL(args=[row.id])
                events.append({"start": start,
                               "end": end,
                               "title": row.name,
                               "caption": row.message or "",
                               "description": row.message or "",
                               "image": image or "",
                               "link": link or "",
                               # @ToDo: Colour based on Category (More generically: Resource or Resource Type)
                               #"color" : "blue',
                            })
            data["events"] = events
            data = json.dumps(data, separators=SEPARATORS)

            code = "".join((
'''S3.timeline.data=''', data, '''
S3.timeline.tl_start="''', tl_start.isoformat(), '''"
S3.timeline.tl_end="''', tl_end.isoformat(), '''"
S3.timeline.now="''', now.isoformat(), '''"
'''))

            # Control our code in static/scripts/S3/s3.timeline.js
            s3.js_global.append(code)

            # Create the DIV
            item = DIV(_id="s3timeline", _class="s3-timeline")

            output = dict(item = item)

            # Maintain RHeader for consistency
            if attr.get("rheader"):
                rheader = attr["rheader"](r)
                if rheader:
                    output["rheader"] = rheader

            output["title"] = T("Incident Timeline")
            response.view = "timeline.html"
            return output

        else:
            raise HTTP(405, current.ERROR.BAD_METHOD)

    # -------------------------------------------------------------------------
Convert dotted keys in :params: dictset to a nested dictset.
dataset/ETHPy150Open sahana/eden/modules/s3db/irs.py/S3IRSModel.irs_timeline--crossover with--dataset/ETHPy150Open ramses-tech/nefertari/nefertari/view.py/BaseView.convert_dotted