Ejemplo n.º 1
0
Archivo: hms.py Proyecto: nursix/eden
    def rheader(r):
        if r.representation != "html":
            # RHeaders only used in interactive views
            return None
        record = r.record
        if record is None:
            # List or Create form: rheader makes no sense here
            return None

        tabs = [
            (T("Person Details"), None),
            (T("Contacts"), "contacts"),
        ]
        rheader_tabs = s3_rheader_tabs(r, tabs)

        from s3 import s3_fullname

        #hospital_field = r.table.hospital_id

        rheader = DIV(
            TABLE(
                TR(
                    TH("%s: " % T("Name")),
                    s3_fullname(record),
                ),
                #TR(TH("%s: " % hospital_field.label),
                #   hospital_field.represent(record.hospital_id),
                #   ),
            ),
            rheader_tabs,
        )
        return rheader
Ejemplo n.º 2
0
Archivo: hrm.py Proyecto: sahana/eden
def staff_for_site():
    """
        Used by the Req/Req/Create page
        - note that this returns Person IDs
    """

    try:
        site_id = request.args[0]
    except:
        result = current.xml.json_message(False, 400, "No Site provided!")
    else:
        table = s3db.hrm_human_resource
        ptable = db.pr_person
        query = (table.site_id == site_id) & \
                (table.deleted == False) & \
                (table.status == 1) & \
                ((table.end_date == None) | \
                 (table.end_date > request.utcnow)) & \
                (ptable.id == table.person_id)
        rows = db(query).select(ptable.id,
                                ptable.first_name,
                                ptable.middle_name,
                                ptable.last_name,
                                orderby=ptable.first_name)
        result = []
        append = result.append
        from s3 import s3_fullname
        for row in rows:
            append({"id": row.id, "name": s3_fullname(row)})
        result = json.dumps(result)

    response.headers["Content-Type"] = "application/json"
    return result
Ejemplo n.º 3
0
    def represent_row(self, row, prefix=None):
        """
            Represent a row

            @param row: the Row
        """

        if self.coordinator or \
           row.id in current.response.s3.rlp_deployed_with_org:
            repr_str = "[%s] %s" % (row.pe_label, s3_fullname(row))
        else:
            repr_str = "[%s] %s" % (row.pe_label, row.alias)

        return repr_str
Ejemplo n.º 4
0
def patient_rheader(r, tabs=[]):
    """ Resource Page Header """

    if r.representation == "html":

        if r.record is None:
            # List or Create form: rheader makes no sense here
            return None

        table = db.patient_patient

        from s3 import s3_rheader_tabs
        rheader_tabs = s3_rheader_tabs(r, tabs)

        patient = r.record
        if patient.person_id:
            from s3 import s3_fullname
            name = s3_fullname(patient.person_id)
        else:
            name = None

        if patient.country:
            country = table.country.represent(patient.country)
        else:
            country = None

        if patient.hospital_id:
            hospital = table.hospital_id.represent(patient.hospital_id)
        else:
            hospital = None

        rheader = DIV(
            TABLE(
                TR(TH("%s: " % T("Patient")), name, TH("%s: " % COUNTRY),
                   country),
                TR(
                    TH(),
                    TH(),
                    TH("%s: " % T("Hospital")),
                    hospital,
                )), rheader_tabs)

        return rheader

    return None
Ejemplo n.º 5
0
def nzseel2_rheader(r, tabs=[]):
    """ Resource Headers """

    if r.representation == "html":
        if r.name == "nzseel2":
            assess = r.record
            if assess:
                table = r.table
                from s3 import s3_rheader_tabs
                rheader_tabs = s3_rheader_tabs(r, tabs)
                location = assess.location_id
                if location:
                    location = table.location_id.represent(location)
                person = assess.person_id
                if person:
                    query = (db.pr_person.id == person)
                    pe_id = db(query).select(db.pr_person.pe_id,
                                             limitby=(0, 1)).first().pe_id
                    query = (db.pr_contact.pe_id == pe_id) & \
                            (db.pr_contact.contact_method == "SMS")
                    mobile = db(query).select(db.pr_contact.value,
                                              limitby=(0, 1)).first()
                    if mobile:
                        mobile = mobile.value
                    from s3 import s3_fullname
                    person = s3_fullname(person)
                rheader = DIV(TABLE(
                                TR(
                                    TH("%s: " % T("Person")), person,
                                    TH("%s: " % T("Mobile")), mobile,
                                  ),
                                TR(
                                    TH("%s: " % T("Location")), location,
                                    TH("%s: " % T("Date")), table.date.represent(assess.date)
                                  ),
                                TR(
                                    TH(""), "",
                                    TH("%s: " % T("Ticket ID")),
                                        r.table.ticket_id.represent(assess.ticket_id),
                                  ),
                                ),
                              rheader_tabs)

                return rheader
    return None
Ejemplo n.º 6
0
    def setUp(self):

        db = current.db
        s3db = current.s3db

        # Look up IDs for test records
        table = s3db.pr_person
        query = table.uuid.belongs(("REPRTEST1", "REPRTEST2"))
        rows = db(query).select(
            table.id,
            table.uuid,
            table.first_name,
            table.middle_name,
            table.last_name,
            limitby=(0, 2),
        )
        person = {}
        names = {}
        for row in rows:
            person[row.uuid] = row.id
            names[row.id] = s3_fullname(row)
        self.person = person
        self.names = names
Ejemplo n.º 7
0
    def rdrt_member_profile_header(r):
        """ Custom profile header to allow update of RDRT roster status """

        record = r.record
        if not record:
            return ""

        person_id = record.person_id
        from s3 import s3_fullname, s3_avatar_represent
        name = s3_fullname(person_id)

        table = r.table

        # Organisation
        comments = table.organisation_id.represent(record.organisation_id)

        from s3 import s3_unicode
        from gluon.html import A, DIV, H2, LABEL, P, SPAN

        # Add job title if present
        job_title_id = record.job_title_id
        if job_title_id:
            comments = (SPAN("%s, " % \
                             s3_unicode(table.job_title_id.represent(job_title_id))),
                             comments)

        # Determine the current roster membership status (active/inactive)
        atable = current.s3db.deploy_application
        status = atable.active
        query = atable.human_resource_id == r.id
        row = current.db(query).select(atable.id,
                                       atable.active,
                                       limitby=(0, 1)).first()
        if row:
            active = 1 if row.active else 0
            status_id = row.id
            roster_status = status.represent(row.active)
        else:
            active = None
            status_id = None
            roster_status = current.messages.UNKNOWN_OPT

        if status_id and \
           current.auth.s3_has_permission("update",
                                          "deploy_application",
                                          record_id=status_id):
            # Make inline-editable
            roster_status = A(roster_status,
                              data = {"status": active},
                              _id = "rdrt-roster-status",
                              _title = T("Click to edit"),
                              )
            s3 = current.response.s3
            script = "/%s/static/themes/IFRC/js/rdrt.js" % r.application
            if script not in s3.scripts:
                s3.scripts.append(script)
            script = '''$.rdrtStatus('%(url)s','%(active)s','%(inactive)s','%(submit)s')'''
            from gluon import URL
            options = {"url": URL(c="deploy", f="application",
                                  args=["%s.s3json" % status_id]),
                       "active": status.represent(True),
                       "inactive": status.represent(False),
                       "submit": T("Save"),
                       }
            s3.jquery_ready.append(script % options)
        else:
            # Read-only
            roster_status = SPAN(roster_status)

        # Render profile header
        return DIV(A(s3_avatar_represent(person_id,
                                         tablename="pr_person",
                                         _class="media-object",
                                         ),
                     _class="pull-left",
                     ),
                   H2(name),
                   P(comments),
                   DIV(LABEL(status.label + ": "), roster_status),
                   _class="profile-header",
                   )
Ejemplo n.º 8
0
    def data(self):
        """
            Lookup data to pass into template

            @returns: the data as dict
        """

        db = current.db
        s3db = current.s3db

        dtable = s3db.hrm_delegation
        ptable = s3db.pr_person

        delegation_id = self.delegation_id
        if delegation_id:
            # Lookup delegation
            dtable = s3db.hrm_delegation
            ptable = s3db.pr_person
            join = ptable.on(ptable.id == dtable.person_id)
            query = (dtable.id == self.delegation_id)
            row = db(query).select(
                dtable.organisation_id,
                dtable.date,
                dtable.end_date,
                dtable.comments,
                ptable.id,
                ptable.pe_id,
                ptable.pe_label,
                ptable.first_name,
                ptable.middle_name,
                ptable.last_name,
                join=join,
                limitby=(0, 1),
            ).first()
            if not row:
                return None
            person = row.pr_person
            person_id = person.id
            if not person_id:
                return None
            delegation = row.hrm_delegation

        else:
            # Use defaults
            person_id = dtable.person_id.default
            if not person_id:
                return None

            query = (ptable.id == person_id)
            person = db(query).select(
                ptable.id,
                ptable.pe_id,
                ptable.pe_label,
                ptable.first_name,
                ptable.middle_name,
                ptable.last_name,
                limitby=(0, 1),
            ).first()
            if not person:
                return None

            fields = ("organisation_id", "date", "end_date", "comments")
            from gluon.storage import Storage
            delegation = Storage({fn: dtable[fn].default for fn in fields})

        lookup_contact = self.lookup_contact

        data = {
            "system":
            current.deployment_settings.get_system_name_short(),
            "start":
            dtable.date.represent(delegation.date),
            "end":
            dtable.end_date.represent(delegation.end_date),
            "comments":
            delegation.comments,
            "volunteer_id":
            person.pe_label,
            "volunteer_name":
            s3_fullname(person),
            "volunteer_first_name":
            person.first_name,
            "volunteer_last_name":
            person.last_name,
            "volunteer_email":
            lookup_contact(person.pe_id, "EMAIL"),
            "volunteer_phone":
            lookup_contact(person.pe_id, "SMS"),
            "volunteer_uri":
            URL(
                c="vol",
                f="person",
                args=[person_id],
                host=True,
            ),
        }
        if delegation_id:
            data["deployment_uri"] = URL(
                c="hrm",
                f="delegation",
                args=[delegation_id],
                host=True,
            )

        # Lookup volunteer office
        htable = s3db.hrm_human_resource
        stable = s3db.org_office
        left = stable.on((stable.site_id == htable.site_id) & \
                         (stable.deleted == False))
        query = (htable.person_id == person_id) & \
                (htable.type == 2) & \
                (htable.deleted == False)
        row = db(query).select(
            stable.name,
            stable.email,
            stable.phone1,
            left=left,
            limitby=(0, 1),
            orderby=~htable.created_on,
        ).first()
        if row and row.name:
            data.update({
                "volunteer_office": row.name,
                "volunteer_office_email": row.email,
                "volunteer_office_phone": row.phone1,
            })

        # Lookup requesting org and office
        otable = s3db.org_organisation
        ftable = s3db.org_facility
        organisation_id = delegation.organisation_id

        query = (otable.id == organisation_id)
        organisation = db(query).select(
            otable.name,
            otable.pe_id,
            limitby=(0, 1),
        ).first()
        if organisation:
            data["organisation"] = organisation.name
            org_email = lookup_contact(organisation.pe_id, "EMAIL")

            site_email = None
            site_phone = None
            location_id = None

            # Lookup facility for address and phone number
            query = (ftable.organisation_id == organisation_id) & \
                    (ftable.obsolete == False) & \
                    (ftable.deleted == False)
            row = db(query).select(
                ftable.email,
                ftable.phone1,
                ftable.location_id,
                limitby=(0, 1),
                orderby=ftable.created_on,
            ).first()
            if not row:
                # Fall back to office
                query = (stable.organisation_id == organisation_id) & \
                        (stable.obsolete == False) & \
                        (stable.deleted == False)
                row = db(query).select(
                    stable.email,
                    stable.phone1,
                    stable.location_id,
                    limitby=(0, 1),
                    orderby=stable.created_on,
                ).first()
            if row:
                site_email = row.email
                site_phone = row.phone1
                location_id = row.location_id

            data.update({
                "organisation_email": org_email if org_email else site_email,
                "organisation_phone": site_phone,
            })

            if location_id:
                # Lookup address details
                ltable = s3db.gis_location
                query = (ltable.id == location_id) & \
                        (ltable.deleted == False)
                location = db(query).select(
                    ltable.addr_street,
                    ltable.addr_postcode,
                    ltable.L3,
                    ltable.L4,
                    limitby=(0, 1),
                ).first()
                if location:
                    place = location.L4 or location.L3  # L4 is optional
                    if place:
                        data["organisation_place"] = place
                    if location.addr_postcode:
                        data["organisation_postcode"] = location.addr_postcode
                    if location.addr_street:
                        data["organisation_street"] = location.addr_street

        # Lookup current user (=coordinator)
        user = current.auth.user
        if user and user.pe_id:
            user_pe_id = user.pe_id
            data.update({
                "coordinator":
                s3_fullname(pe_id=user_pe_id),
                "coordinator_email":
                lookup_contact(user_pe_id, "EMAIL"),
                "coordinator_phone":
                lookup_contact(user_pe_id, "SMS"),
            })

        return data
Ejemplo n.º 9
0
    def get_family_members(self, person, include_ids=False):
        """
            Get infos for all family members of person

            @param person: the person (Row)
            @param include_ids: include the person record IDs

            @returns: array with family member infos, format:
                            [{i: the person record ID (if requested)
                              l: pe_label,
                              n: fullname,
                              d: dob_formatted,
                              p: picture_URL,
                              r: {
                                event_code: {
                                    m: message,
                                    e: earliest_date_ISO
                                }
                              }, ...
                             ]
        """

        db = current.db
        s3db = current.s3db

        ptable = s3db.pr_person
        itable = s3db.pr_image
        gtable = s3db.pr_group
        mtable = s3db.pr_group_membership
        ctable = s3db.dvr_case
        stable = s3db.dvr_case_status

        # Get all case groups this person belongs to
        person_id = person.id
        query = ((mtable.person_id == person_id) & \
                 (mtable.deleted != True) & \
                 (gtable.id == mtable.group_id) & \
                 (gtable.group_type == 7))
        rows = db(query).select(gtable.id)
        group_ids = set(row.id for row in rows)

        members = {}

        if group_ids:
            join = [ptable.on(ptable.id == mtable.person_id),
                    ctable.on((ctable.person_id == ptable.id) & \
                              (ctable.archived == False) & \
                              (ctable.deleted == False)),
                    ]

            left = [stable.on(stable.id == ctable.status_id),
                    itable.on((itable.pe_id == ptable.pe_id) & \
                              (itable.profile == True) & \
                              (itable.deleted == False)),
                    ]

            query = (mtable.group_id.belongs(group_ids)) & \
                    (mtable.deleted != True) & \
                    (stable.is_closed != True)
            rows = db(query).select(ptable.id,
                                    ptable.pe_label,
                                    ptable.first_name,
                                    ptable.last_name,
                                    ptable.date_of_birth,
                                    itable.image,
                                    join = join,
                                    left = left,
                                    )

            for row in rows:
                member_id = row.pr_person.id
                if member_id not in members:
                    members[member_id] = row

        output = []

        if members:

            # All event types and blocking rules
            event_types = self.get_event_types()
            intervals = self.get_interval_rules(set(members.keys()))

            for member_id, data in members.items():

                member = data.pr_person
                picture = data.pr_image

                # Person data
                data = {"l": member.pe_label,
                        "n": s3_fullname(member),
                        "d": S3DateTime.date_represent(member.date_of_birth),
                        }

                # Record ID?
                if include_ids:
                    data["id"] = member_id

                # Profile picture URL
                if picture.image:
                    data["p"] = URL(c = "default",
                                    f = "download",
                                    args = picture.image,
                                    )

                # Blocking rules
                event_rules = intervals.get(member_id)
                if event_rules:
                    rules = {}
                    for event_type_id, rule in event_rules.items():
                        code = event_types.get(event_type_id).code
                        rules[code] = (s3_str(rule[0]),
                                       "%sZ" % s3_encode_iso_datetime(rule[1]),
                                       )
                    data["r"] = rules

                # Add info to output
                output.append(data)

        return output
Ejemplo n.º 10
0
def mavc_rheader(r, tabs=None):
    """ Custom rheaders """

    if r.representation != "html":
        return None

    from s3 import s3_rheader_resource, s3_rheader_tabs
    from gluon import A, DIV, H1, H2, TAG

    tablename, record = s3_rheader_resource(r)
    if record is None:
        return None

    T = current.T
    s3db = current.s3db

    if tablename != r.tablename:
        resource = s3db.resource(
            tablename,
            id=record.id if record else None,
        )
    else:
        resource = r.resource

    rheader = ""

    if tablename == "org_organisation":

        # Tabs
        if not tabs:
            INDIVIDUALS = current.deployment_settings.get_hrm_staff_label()

            tabs = [
                (T("About"), None),
                (INDIVIDUALS, "human_resource"),
                (T("Services"), "service_location"),
                (T("Facilities"), "facility"),
                (T("Projects"), "project"),
                (T("Attachments"), "document"),
            ]

        # Use OrganisationRepresent for title to get L10n name if available
        represent = s3db.org_OrganisationRepresent(
            acronym=False,
            parent=False,
        )
        title = represent(record.id)

        # Retrieve details for the rheader
        data = resource.select(
            [
                "organisation_organisation_type.organisation_type_id",
                "country",
                "website",
            ],
            raw_data=True,
            represent=True,
        )
        row = data.rows[0]
        raw = row["_row"]

        # Construct subtitle
        subtitle_fields = (
            "org_organisation_organisation_type.organisation_type_id",
            "org_organisation.country",
        )
        items = []
        for fname in subtitle_fields:
            if raw[fname]:
                items.append(s3_unicode(row[fname]))
        subtitle = ", ".join(items)

        # Website
        website = row["org_organisation.website"]

        # Compose the rheader
        rheader = DIV(
            DIV(
                H1(title),
                H2(subtitle),
                website if record.website else "",
                _class="rheader-details",
            ), )

    elif tablename == "project_project":

        if not tabs:
            tabs = [
                (T("About"), None),
                (T("Locations"), "location"),
                (T("Attachments"), "document"),
            ]

        # Retrieve details for the rheader
        data = resource.select(
            [
                "name",
                "organisation_id",
            ],
            represent=True,
        )
        row = data.rows[0]

        # Title and Subtitle
        title = row["project_project.name"]
        subtitle = row["project_project.organisation_id"]

        # Compose the rheader
        rheader = DIV(DIV(
            H1(title),
            H2(subtitle),
            _class="rheader-details",
        ), )

    elif tablename == "pr_person":

        if not tabs:
            tabs = [
                (T("Person Details"), None),
            ]

        from s3 import s3_fullname
        title = s3_fullname(record)

        # Link organisation_id representation to staff tab
        linkto = URL(
            c="org",
            f="organisation",
            args=["[id]", "human_resource"],
        )
        htable = s3db.hrm_human_resource
        field = htable.organisation_id
        field.represent = s3db.org_OrganisationRepresent(
            show_link=True,
            linkto=linkto,
        )

        # Retrieve details for the rheader
        data = resource.select(
            [
                "human_resource.job_title_id",
                "human_resource.organisation_id",
            ],
            raw_data=True,
            represent=True,
        )
        row = data.rows[0]
        raw = row["_row"]

        # Construct subtitle
        organisation_id = raw["hrm_human_resource.organisation_id"]
        if organisation_id:
            subtitle = row["hrm_human_resource.organisation_id"]
            job_title_id = raw["hrm_human_resource.job_title_id"]
            if job_title_id:
                subtitle = TAG[""](
                    "%s, " % row["hrm_human_resource.job_title_id"],
                    subtitle,
                )

        # Compose the rheader
        rheader = DIV(DIV(
            H1(title),
            H2(subtitle),
            _class="rheader-details",
        ), )

    if tabs:
        rheader_tabs = s3_rheader_tabs(r, tabs)
        rheader.append(rheader_tabs)

    return rheader
Ejemplo n.º 11
0
    def get_family_members(self, person, include_ids=False):
        """
            Get infos for all family members of person

            @param person: the person (Row)
            @param include_ids: include the person record IDs

            @returns: array with family member infos, format:
                            [{i: the person record ID (if requested)
                              l: pe_label,
                              n: fullname,
                              d: dob_formatted,
                              p: picture_URL,
                              r: {
                                event_code: {
                                    m: message,
                                    e: earliest_date_ISO
                                }
                              }, ...
                             ]
        """

        db = current.db
        s3db = current.s3db

        ptable = s3db.pr_person
        itable = s3db.pr_image
        gtable = s3db.pr_group
        mtable = s3db.pr_group_membership
        ctable = s3db.dvr_case
        stable = s3db.dvr_case_status

        # Get all case groups this person belongs to
        person_id = person.id
        query = ((mtable.person_id == person_id) & \
                 (mtable.deleted != True) & \
                 (gtable.id == mtable.group_id) & \
                 (gtable.group_type == 7))
        rows = db(query).select(gtable.id)
        group_ids = set(row.id for row in rows)

        members = {}

        if group_ids:
            join = [ptable.on(ptable.id == mtable.person_id),
                    ctable.on((ctable.person_id == ptable.id) & \
                              (ctable.archived == False) & \
                              (ctable.deleted == False)),
                    ]

            left = [stable.on(stable.id == ctable.status_id),
                    itable.on((itable.pe_id == ptable.pe_id) & \
                              (itable.profile == True) & \
                              (itable.deleted == False)),
                    ]

            query = (mtable.group_id.belongs(group_ids)) & \
                    (mtable.deleted != True) & \
                    (stable.is_closed != True)
            rows = db(query).select(
                ptable.id,
                ptable.pe_label,
                ptable.first_name,
                ptable.last_name,
                ptable.date_of_birth,
                itable.image,
                join=join,
                left=left,
            )

            for row in rows:
                member_id = row.pr_person.id
                if member_id not in members:
                    members[member_id] = row

        output = []

        if members:

            # All event types and blocking rules
            event_types = self.get_event_types()
            intervals = self.get_interval_rules(set(members.keys()))

            for member_id, data in members.items():

                member = data.pr_person
                picture = data.pr_image

                # Person data
                data = {
                    "l": member.pe_label,
                    "n": s3_fullname(member),
                    "d": S3DateTime.date_represent(member.date_of_birth),
                }

                # Record ID?
                if include_ids:
                    data["id"] = member_id

                # Profile picture URL
                if picture.image:
                    data["p"] = URL(
                        c="default",
                        f="download",
                        args=picture.image,
                    )

                # Blocking rules
                event_rules = intervals.get(member_id)
                if event_rules:
                    rules = {}
                    for event_type_id, rule in event_rules.items():
                        code = event_types.get(event_type_id).code
                        rules[code] = (
                            s3_str(rule[0]),
                            "%sZ" % s3_encode_iso_datetime(rule[1]),
                        )
                    data["r"] = rules

                # Add info to output
                output.append(data)

        return output
Ejemplo n.º 12
0
    def data(self):
        """
            Lookup data to pass into template

            @returns: the data as dict
        """

        db = current.db
        s3db = current.s3db

        # Lookup delegation
        dtable = s3db.hrm_delegation
        ptable = s3db.pr_person
        join = ptable.on(ptable.id == dtable.person_id)
        query = (dtable.id == self.delegation_id)
        row = db(query).select(
            dtable.status,
            dtable.organisation_id,
            #dtable.person_id,
            dtable.date,
            dtable.end_date,
            dtable.comments,
            ptable.id,
            ptable.pe_id,
            ptable.pe_label,
            ptable.first_name,
            ptable.middle_name,
            ptable.last_name,
            join=join,
            limitby=(0, 1),
        ).first()
        if not row:  # or row.status != "APPR":
            return None

        delegation = row.hrm_delegation
        person = row.pr_person
        person_id = person.id
        if not person_id:
            return None

        lookup_contact = self.lookup_contact

        data = {
            "system":
            current.deployment_settings.get_system_name_short(),
            "start":
            dtable.date.represent(delegation.date),
            "end":
            dtable.end_date.represent(delegation.end_date),
            "comments":
            delegation.comments,
            "deployment_uri":
            URL(
                c="hrm",
                f="delegation",
                args=[self.delegation_id],
                host=True,
            ),
            "volunteer_id":
            person.pe_label,
            "volunteer_name":
            s3_fullname(person),
            "volunteer_first_name":
            person.first_name,
            "volunteer_last_name":
            person.last_name,
            "volunteer_email":
            lookup_contact(person.pe_id, "EMAIL"),
            "volunteer_phone":
            lookup_contact(person.pe_id, "SMS"),
            "volunteer_uri":
            URL(
                c="vol",
                f="person",
                args=[person_id],
                host=True,
            ),
        }

        # Lookup volunteer office
        htable = s3db.hrm_human_resource
        stable = s3db.org_office
        left = stable.on((stable.site_id == htable.site_id) & \
                         (stable.deleted == False))
        query = (htable.person_id == person_id) & \
                (htable.type == 2) & \
                (htable.deleted == False)
        row = db(query).select(
            stable.name,
            stable.email,
            stable.phone1,
            left=left,
            limitby=(0, 1),
            orderby=~htable.created_on,
        ).first()
        if row and row.name:
            data.update({
                "volunteer_office": row.name,
                "volunteer_office_email": row.email,
                "volunteer_office_phone": row.phone1,
            })

        # Lookup requesting org and office
        otable = s3db.org_organisation
        left = stable.on((stable.organisation_id == otable.id) & \
                         (stable.deleted == False))
        query = (otable.id == delegation.organisation_id)
        row = db(query).select(
            otable.name,
            stable.email,
            stable.phone1,
            left=left,
            limitby=(0, 1),
            orderby=stable.created_on,
        ).first()
        if row:
            data.update({
                "organisation": row.org_organisation.name,
                "organisation_email": row.org_office.email,
                "organisation_phone": row.org_office.phone1,
            })

        # Lookup current user (=coordinator)
        user = current.auth.user
        if user and user.pe_id:
            user_pe_id = user.pe_id
            data.update({
                "coordinator":
                s3_fullname(pe_id=user_pe_id),
                "coordinator_email":
                lookup_contact(user_pe_id, "EMAIL"),
                "coordinator_phone":
                lookup_contact(user_pe_id, "SMS"),
            })

        return data
Ejemplo n.º 13
0
def comment_parse(comment, comments, solution_id=None):
    """
        Parse a Comment

        @param: comment - a gluon.sql.Row: the current comment
        @param: comments - a gluon.sql.Rows: full list of comments
        @param: solution_id - a reference ID: optional solution commented on
    """

    author = B(T("Anonymous"))
    if comment.created_by:
        utable = s3db.auth_user
        ptable = s3db.pr_person
        ltable = s3db.pr_person_user
        query = (utable.id == comment.created_by)
        left = [
            ltable.on(ltable.user_id == utable.id),
            ptable.on(ptable.pe_id == ltable.pe_id)
        ]
        row = db(query).select(utable.email,
                               ptable.first_name,
                               ptable.middle_name,
                               ptable.last_name,
                               left=left,
                               limitby=(0, 1)).first()
        if row:
            person = row.pr_person
            user = row[utable._tablename]
            from s3 import s3_fullname
            username = s3_fullname(person)
            email = user.email.strip().lower()
            import hashlib
            hash = hashlib.md5(email).hexdigest()
            url = "http://www.gravatar.com/%s" % hash
            author = B(A(username, _href=url, _target="top"))
    if not solution_id and comment.solution_id:
        solution = "re: %s" % s3db.delphi_solution_represent(
            comment.solution_id)
        header = DIV(author, " ", solution)
        solution_id = comment.solution_id
    else:
        header = author
    from s3 import s3_avatar_represent
    thread = LI(
        DIV(
            s3_avatar_represent(comment.created_by),
            DIV(
                DIV(
                    header,
                    _class="comment-header",
                ),
                DIV(XML(comment.body)),
                _class="comment-text",
            ),
            DIV(
                DIV(
                    comment.created_on,
                    _class="comment-date",
                ),
                DIV(
                    A(
                        T("Reply"),
                        _class="action-btn",
                    ),
                    _onclick="comment_reply(%i);" % comment.id,
                    _class="comment-reply",
                ),
                _class="fright",
            ),
            _id="comment-%i" % comment.id,
            _solution_id=solution_id,
            _class="comment-box",
        ))

    # Add the children of this thread
    children = UL(_class="children")
    id = comment.id
    count = 0
    for comment in comments:
        if comment.parent == id:
            count = 1
            child = comment_parse(comment, comments, solution_id=solution_id)
            children.append(child)
    if count == 1:
        thread.append(children)

    return thread
Ejemplo n.º 14
0
Archivo: cms.py Proyecto: sahana/eden
def posts():
    """
        Function accessed by AJAX to handle a Series of Posts
    """

    try:
        series_id = request.args[0]
    except:
        raise HTTP(400)

    try:
        recent = request.args[1]
    except:
        recent = 5

    table = s3db.cms_post

    # List of Posts in this Series
    posts = db(table.series_id == series_id).select(
        table.name,
        table.body,
        table.avatar,
        table.created_by,
        table.created_on,
        limitby=(0, recent),
    )

    output = UL(_id="comments")
    import hashlib
    from s3 import s3_fullname
    for post in posts:
        author = B(T("Anonymous"))
        if post.created_by:
            utable = s3db.auth_user
            ptable = s3db.pr_person
            ltable = s3db.pr_person_user
            query = (utable.id == post.created_by)
            left = [
                ltable.on(ltable.user_id == utable.id),
                ptable.on(ptable.pe_id == ltable.pe_id)
            ]
            row = db(query).select(
                utable.email,
                ptable.first_name,
                ptable.middle_name,
                ptable.last_name,
                left=left,
                limitby=(0, 1),
            ).first()
            if row:
                person = row.pr_person
                user = row[utable._tablename]
                username = s3_fullname(person)
                email = user.email.strip().lower()
                hash = hashlib.md5(email.encode("utf-8")).hexdigest()
                url = "http://www.gravatar.com/%s" % hash
                author = B(A(
                    username,
                    _href=url,
                    _target="top",
                ))
        header = H4(post.name)
        if post.avatar:
            from s3 import s3_avatar_represent
            avatar = s3_avatar_represent(post.created_by)
        else:
            avatar = ""
        row = LI(
            DIV(
                avatar,
                DIV(DIV(
                    header,
                    _class="comment-header",
                ),
                    DIV(
                        XML(post.body),
                        _class="comment-body",
                    ),
                    _class="comment-text"),
                DIV(DIV(
                    post.created_on,
                    _class="comment-date",
                ),
                    _class="fright"),
                DIV(
                    author,
                    _class="comment-footer",
                ),
                _class="comment-box",
            ))
        output.append(row)

    return XML(output)
Ejemplo n.º 15
0
    def prep(r):

        table = r.table
        resource = r.resource

        get_vars = r.get_vars
        if "viewing" in get_vars:

            try:
                vtablename, record_id = get_vars["viewing"].split(".")
            except ValueError:
                return False

            if vtablename == "pr_person":
                # Get all group_ids with this person_id
                gtable = s3db.pr_group
                join = gtable.on(gtable.id == table.group_id)
                query = (table.person_id == record_id) & \
                        (gtable.group_type == 7) & \
                        (table.deleted != True)
                rows = db(query).select(
                    table.group_id,
                    join=join,
                )
                group_ids = set(row.group_id for row in rows)
                # Hide the link for this person (to prevent changes/deletion)
                if group_ids:
                    # Single group ID?
                    group_id = tuple(group_ids)[0] if len(
                        group_ids) == 1 else None
                elif r.http == "POST":
                    from s3 import s3_fullname
                    name = s3_fullname(record_id)
                    group_id = gtable.insert(
                        name=name,
                        group_type=7,
                    )
                    s3db.update_super(gtable, {"id": group_id})
                    table.insert(
                        group_id=group_id,
                        person_id=record_id,
                        group_head=True,
                    )
                    group_ids = {group_id}
                resource.add_filter(FS("person_id") != record_id)
            else:
                group_ids = set()

            # Show only links for relevant cases
            # NB Filter also prevents showing all links if case_ids is empty
            if not r.id:
                if len(group_ids) == 1:
                    r.resource.add_filter(FS("group_id") == group_id)
                else:
                    r.resource.add_filter(FS("group_id").belongs(group_ids))

            list_fields = [
                "person_id",
                "person_id$gender",
                "person_id$date_of_birth",
            ]

            if len(group_ids) == 0:
                # No case group exists, will be auto-generated on POST,
                # hide the field in the form:
                field = table.group_id
                field.readable = field.writable = False
            elif len(group_ids) == 1:
                field = table.group_id
                field.default = group_id
                # If we have only one relevant case, then hide the group ID:
                field.readable = field.writable = False
            elif len(group_ids) > 1:
                # Show the case ID in list fields if there is more than one
                # relevant case
                list_fields.insert(0, "group_id")
            r.resource.configure(list_fields=list_fields)

        # Do not allow update of person_id
        if r.id:
            field = table.person_id
            field.writable = False
            field.comment = None

        return True
Ejemplo n.º 16
0
def mavc_rheader(r, tabs=None):
    """ Custom rheaders """

    if r.representation != "html":
        return None

    from s3 import s3_rheader_resource, s3_rheader_tabs
    from gluon import A, DIV, H1, H2, TAG

    tablename, record = s3_rheader_resource(r)
    if record is None:
        return None

    T = current.T
    s3db = current.s3db

    if tablename != r.tablename:
        resource = s3db.resource(tablename,
                                 id = record.id if record else None,
                                 )
    else:
        resource = r.resource

    rheader = ""

    if tablename == "org_organisation":

        # Tabs
        if not tabs:
            INDIVIDUALS = current.deployment_settings.get_hrm_staff_label()

            tabs = [(T("About"), None),
                    (INDIVIDUALS, "human_resource"),
                    (T("Services"), "service_location"),
                    (T("Facilities"), "facility"),
                    (T("Projects"), "project"),
                    (T("Attachments"), "document"),
                    ]

        # Use OrganisationRepresent for title to get L10n name if available
        represent = s3db.org_OrganisationRepresent(acronym=False,
                                                   parent=False,
                                                   )
        title = represent(record.id)

        # Retrieve details for the rheader
        data = resource.select(["organisation_organisation_type.organisation_type_id",
                                "country",
                                "website",
                                ],
                               raw_data = True,
                               represent = True,
                               )
        row = data.rows[0]
        raw = row["_row"]

        # Construct subtitle
        subtitle_fields = ("org_organisation_organisation_type.organisation_type_id",
                           "org_organisation.country",
                           )
        items = []
        for fname in subtitle_fields:
            if raw[fname]:
                items.append(s3_unicode(row[fname]))
        subtitle = ", ".join(items)

        # Website
        website = row["org_organisation.website"]

        # Compose the rheader
        rheader = DIV(DIV(H1(title),
                          H2(subtitle),
                          website if record.website else "",
                          _class="rheader-details",
                          ),
                      )

    elif tablename == "project_project":

        if not tabs:
            tabs = [(T("About"), None),
                    (T("Locations"), "location"),
                    (T("Attachments"), "document"),
                    ]

        # Retrieve details for the rheader
        data = resource.select(["name",
                                "organisation_id",
                                ],
                               represent = True,
                               )
        row = data.rows[0]

        # Title and Subtitle
        title = row["project_project.name"]
        subtitle = row["project_project.organisation_id"]

        # Compose the rheader
        rheader = DIV(DIV(H1(title),
                          H2(subtitle),
                          _class="rheader-details",
                          ),
                      )

    elif tablename == "pr_person":

        if not tabs:
            tabs = [(T("Person Details"), None),
                    ]

        from s3 import s3_fullname
        title = s3_fullname(record)

        # Link organisation_id representation to staff tab
        linkto = URL(c = "org",
                     f = "organisation",
                     args = ["[id]", "human_resource"],
                     )
        htable = s3db.hrm_human_resource
        field = htable.organisation_id
        field.represent = s3db.org_OrganisationRepresent(show_link = True,
                                                         linkto = linkto,
                                                         )

        # Retrieve details for the rheader
        data = resource.select(["human_resource.job_title_id",
                                "human_resource.organisation_id",
                                ],
                               raw_data = True,
                               represent = True,
                               )
        row = data.rows[0]
        raw = row["_row"]

        # Construct subtitle
        organisation_id = raw["hrm_human_resource.organisation_id"]
        if organisation_id:
            subtitle = row["hrm_human_resource.organisation_id"]
            job_title_id = raw["hrm_human_resource.job_title_id"]
            if job_title_id:
                subtitle = TAG[""]("%s, " % row["hrm_human_resource.job_title_id"],
                                   subtitle,
                                   )

        # Compose the rheader
        rheader = DIV(DIV(H1(title),
                          H2(subtitle),
                          _class="rheader-details",
                          ),
                      )

    if tabs:
        rheader_tabs = s3_rheader_tabs(r, tabs)
        rheader.append(rheader_tabs)

    return rheader
Ejemplo n.º 17
0
def stl_dvr_rheader(r, tabs=[]):
    """ DVR custom resource headers """

    if r.representation != "html":
        # Resource headers only used in interactive views
        return None

    from s3 import s3_rheader_resource, \
                   S3ResourceHeader, \
                   s3_fullname

    tablename, record = s3_rheader_resource(r)
    if tablename != r.tablename:
        resource = current.s3db.resource(tablename, id=record.id)
    else:
        resource = r.resource

    rheader = None
    rheader_fields = []

    if record:
        T = current.T

        if tablename == "pr_person":

            # "Invalid Case" warning
            hint = lambda record: H3(
                T("Invalid Case"),
                _class="alert label",
            )

            if not tabs:
                tabs = [
                    (T("Basic Details"), None),
                    (T("Contact"), "contacts"),
                    (T("Household"), "household"),
                    (T("Economy"), "economy"),
                    (T("Activities"), "case_activity"),
                ]

                case = resource.select(
                    [
                        "family_id.value",
                        "dvr_case.status_id",
                        "dvr_case.archived",
                        "dvr_case.organisation_id",
                        "dvr_case.disclosure_consent",
                        "dvr_case.project_id",
                    ],
                    represent=True,
                    raw_data=True,
                ).rows

                if not case:
                    return None

                case = case[0]

                case_status = lambda row: case["dvr_case.status_id"]
                archived = case["_row"]["dvr_case.archived"]
                family_id = lambda row: case["pr_family_id_person_tag.value"]
                organisation_id = lambda row: case["dvr_case.organisation_id"]
                project_id = lambda row: case["dvr_case.project_id"]
                name = lambda row: s3_fullname(row)

                raw = case._row

                # Render disclosure consent flag as colored label
                consent = raw["dvr_case.disclosure_consent"]
                labels = {"Y": "success", "N/A": "warning", "N": "alert"}

                def disclosure(row):
                    _class = labels.get(consent, "secondary")
                    return SPAN(
                        case["dvr_case.disclosure_consent"],
                        _class="%s label" % _class,
                    )

                rheader_fields = [
                    [
                        (T("ID"), "pe_label"),
                        (T("Case Status"), case_status),
                        (T("Data Disclosure"), disclosure),
                    ],
                    [
                        (T("Family ID"), family_id),
                        (T("Organisation"), organisation_id),
                    ],
                    [
                        (T("Name"), name),
                        (T("Project Code"), project_id),
                    ],
                    [
                        "date_of_birth",
                    ],
                ]

                if archived:
                    rheader_fields.insert(0, [(None, hint)])

        rheader = S3ResourceHeader(rheader_fields, tabs)(
            r,
            table=resource.table,
            record=record,
        )

    return rheader
Ejemplo n.º 18
0
def drk_dvr_rheader(r, tabs=None):
    """ DVR custom resource headers """

    if r.representation != "html":
        # Resource headers only used in interactive views
        return None

    from s3 import s3_rheader_resource, \
                   S3ResourceHeader, \
                   s3_fullname
    from .uioptions import get_ui_options

    tablename, record = s3_rheader_resource(r)
    if tablename != r.tablename:
        resource = current.s3db.resource(tablename, id=record.id)
    else:
        resource = r.resource

    rheader = None
    rheader_fields = []

    if record:
        T = current.T
        record_id = record.id

        if tablename == "pr_person":

            # UI Options and ability to read cases from multiple orgs
            ui_opts = get_ui_options()
            ui_opts_get = ui_opts.get

            from .helpers import case_read_multiple_orgs
            multiple_orgs = case_read_multiple_orgs()[0]

            if not tabs:
                activity_tab_label = ui_opts_get("activity_tab_label")
                if activity_tab_label:
                    ACTIVITIES = T(activity_tab_label)
                else:
                    ACTIVITIES = T("Counseling Reasons")

                # Basic Case Documentation
                tabs = [(T("Basic Details"), None),
                        (T("Contact Info"), "contacts"),
                        (T("Family Members"), "group_membership/"),
                        (ACTIVITIES, "case_activity"),
                        ]

                # Optional Case Documentation
                if ui_opts_get("case_use_response_tab"):
                    tabs.append((T("Actions"), "response_action"))
                if ui_opts_get("case_use_appointments"):
                    tabs.append((T("Appointments"), "case_appointment"))
                if ui_opts_get("case_use_service_contacts"):
                    tabs.append((T("Service Contacts"), "service_contact"))
                if ui_opts_get("case_use_photos_tab"):
                    tabs.append((T("Photos"), "image"))

                # Uploads
                tabs.append((T("Documents"), "document/"))

                # Notes etc.
                if ui_opts_get("case_use_notes"):
                    tabs.append((T("Notes"), "case_note"))

            # Get the record data
            lodging_opt = ui_opts_get("case_lodging")
            if lodging_opt == "site":
                lodging_sel = "dvr_case.site_id"
                lodging_col = "dvr_case.site_id"
            elif lodging_opt == "text":
                lodging_sel = "case_details.lodging"
                lodging_col = "dvr_case_details.lodging"
            else:
                lodging_sel = None
                lodging_col = None

            if ui_opts_get("case_use_flags"):
                flags_sel = "dvr_case_flag_case.flag_id"
            else:
                flags_sel = None

            if ui_opts_get("case_use_place_of_birth"):
                pob_sel = "person_details.place_of_birth"
            else:
                pob_sel = None

            if ui_opts_get("case_use_bamf"):
                bamf_sel = "bamf.value"
            else:
                bamf_sel = None

            case = resource.select(["first_name",
                                    "last_name",
                                    "dvr_case.status_id",
                                    "dvr_case.archived",
                                    "dvr_case.household_size",
                                    "dvr_case.organisation_id",
                                    "case_details.arrival_date",
                                    bamf_sel,
                                    "person_details.nationality",
                                    pob_sel,
                                    lodging_sel,
                                    flags_sel,
                                    ],
                                    represent = True,
                                    raw_data = True,
                                    ).rows

            if case:
                # Extract case data
                case = case[0]

                name = lambda person: s3_fullname(person, truncate=False)
                raw = case["_row"]

                case_status = lambda row: case["dvr_case.status_id"]
                archived = raw["dvr_case.archived"]
                organisation = lambda row: case["dvr_case.organisation_id"]
                arrival_date = lambda row: case["dvr_case_details.arrival_date"]
                household_size = lambda row: case["dvr_case.household_size"]
                nationality = lambda row: case["pr_person_details.nationality"]

                # Warn if nationality is lacking while mandatory
                if ui_opts_get("case_nationality_mandatory") and \
                   raw["pr_person_details.nationality"] is None:
                    current.response.warning = T("Nationality lacking!")

                bamf = lambda row: case["pr_bamf_person_tag.value"]

                if pob_sel:
                    place_of_birth = lambda row: case["pr_person_details.place_of_birth"]
                else:
                    place_of_birth = None
                if lodging_col:
                    lodging = (T("Lodging"), lambda row: case[lodging_col])
                else:
                    lodging = None
                if flags_sel:
                    flags = lambda row: case["dvr_case_flag_case.flag_id"]
                else:
                    flags = None
            else:
                # Target record exists, but doesn't match filters
                return None

            arrival_date_label = ui_opts_get("case_arrival_date_label")
            arrival_date_label = T(arrival_date_label) \
                                 if arrival_date_label else T("Date of Entry")

            # Adaptive rheader-fields
            rheader_fields = [[None,
                               (T("Nationality"), nationality),
                               (T("Case Status"), case_status)],
                              [None, None, None],
                              [None, None, None],
                              ]

            if ui_opts_get("case_use_pe_label"):
                rheader_fields[0][0] = (T("ID"), "pe_label")
                rheader_fields[1][0] = "date_of_birth"
            else:
                rheader_fields[0][0] = "date_of_birth"

            if pob_sel:
                pob_row = 1 if rheader_fields[1][0] is None else 2
                rheader_fields[pob_row][0] = (T("Place of Birth"), place_of_birth)

            if bamf_sel:
                doe_row = 2
                rheader_fields[1][1] = (T("BAMF-Az"), bamf)
            else:
                doe_row = 1
            rheader_fields[doe_row][1] = (arrival_date_label, arrival_date)

            if lodging:
                rheader_fields[1][2] = lodging

            if ui_opts_get("case_show_total_consultations"):
                from .helpers import get_total_consultations
                total_consultations = (T("Number of Consultations"), get_total_consultations)
                if rheader_fields[1][2] is None:
                    rheader_fields[1][2] = total_consultations
                else:
                    rheader_fields[0].append(total_consultations)

            hhsize = (T("Size of Family"), household_size)
            if rheader_fields[1][0] is None:
                rheader_fields[1][0] = hhsize
            elif rheader_fields[2][0] is None:
                rheader_fields[2][0] = hhsize
            elif rheader_fields[1][2] is None:
                rheader_fields[1][2] = hhsize
            else:
                rheader_fields[2][2] = hhsize

            colspan = 5

            if multiple_orgs:
                # Show organisation if user can see cases from multiple orgs
                rheader_fields.insert(0, [(T("Organisation"), organisation, colspan)])
            if flags_sel:
                rheader_fields.append([(T("Flags"), flags, colspan)])
            if ui_opts_get("case_header_protection_themes"):
                from .helpers import get_protection_themes
                rheader_fields.append([(T("Protection Need"),
                                        get_protection_themes,
                                        colspan,
                                        )])
            if archived:
                # "Case Archived" hint
                hint = lambda record: SPAN(T("Invalid Case"), _class="invalid-case")
                rheader_fields.insert(0, [(None, hint)])

            # Generate rheader XML
            rheader = S3ResourceHeader(rheader_fields, tabs, title=name)(
                            r,
                            table = resource.table,
                            record = record,
                            )

            # Add profile picture
            from s3 import s3_avatar_represent
            rheader.insert(0, A(s3_avatar_represent(record_id,
                                                    "pr_person",
                                                    _class = "rheader-avatar",
                                                    _width = 60,
                                                    _height = 60,
                                                    ),
                                _href=URL(f = "person",
                                          args = [record_id, "image"],
                                          vars = r.get_vars,
                                          ),
                                )
                           )

            return rheader

        elif tablename == "dvr_case":

            if not tabs:
                tabs = [(T("Basic Details"), None),
                        (T("Activities"), "case_activity"),
                        ]

            rheader_fields = [["reference"],
                              ["status_id"],
                              ]

        rheader = S3ResourceHeader(rheader_fields, tabs)(r,
                                                         table=resource.table,
                                                         record=record,
                                                         )
Ejemplo n.º 19
0
    def event_notification_dispatcher(r, **attr):
        """
            Send a Dispatch notice from an Incident Report
                - this will be formatted as an OpenGeoSMS
        """

        if r.representation == "html" and \
            r.id and not r.component:

            T = current.T
            s3db = current.s3db

            itable = s3db.event_incident

            record = r.record
            record_id = record.id
            inc_name = record.name
            zero_hour = itable.date.represent(record.date)
            exercise = record.exercise
            closed = record.closed

            event_id = record.event_id
            if event_id != None:
                etable = s3db.event_event
                event = current.db(etable.id == event_id).select(etable.name,
                                                                 limitby=(0, 1),
                                                                 ).first()
                event_name = event.name
            else:
                event_name = T("Not Defined")

            location_id = record.location_id
            if location_id != None:
                gtable = s3db.gis_location
                loc = current.db(gtable.id == location_id).select(gtable.L1,
                                                                  gtable.addr_street,
                                                                  gtable.addr_postcode,
                                                                  limitby=(0, 1),
                                                                  ).first()
                L1 = loc.L1
                addr_street = loc.addr_street
                postcode = loc.addr_postcode
            else:
                L1 = addr_street = postcode = T("Not Defined")

            person_id = record.person_id
            if person_id != None:
                from s3 import s3_fullname
                commander = s3_fullname(person_id)
            else:
                commander = T("Not Defined")

            message = "************************************************"
            message += "\n%s " % T("Automatic Message")
            message += "\n%s: %s,  " % (T("Incident ID"), record_id)
            message += " %s: %s" % (T("Incident name"), inc_name)
            message += "\n%s: %s " % (T("Related event"), event_name)
            message += "\n%s: %s " % (T("Incident started"), zero_hour)
            message += "\n%s: %s" % (T("Province/Territory"), L1)
            message += "\n%s: %s" % (T("Street Address"), addr_street)
            message += "\n%s: %s" % (T("Postcode"), postcode)
            message += "\n%s: %s" % (T("Incident Commander"), commander)
            message += "\n%s %s, " % (T("Exercise?"), exercise)
            message += "%s %s" % (T("Closed?"), closed)
            message += "\n************************************************\n"

            url = URL(c="event", f="incident", args=r.id)

            # Create the form
            opts = {"type": "EMAIL",
                    "subject": inc_name,
                    "message": message,
                    "url": url,
                    }

            output = current.msg.compose(**opts)

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

            output["title"] = T("Send Event Update")
            current.response.view = "msg/compose.html"
            return output

        else:
            r.error(405, current.messages.BAD_METHOD)