diff --git a/modules/s3cfg.py b/modules/s3cfg.py index 6661c269e8..1ef5c76c13 100644 --- a/modules/s3cfg.py +++ b/modules/s3cfg.py @@ -2683,6 +2683,27 @@ def get_cap_area_default(self): return self.cap.get("area_default", ["geocode", "polygon"]) + def get_cap_bulletin_method(self): + """ + Name of the method that is used to generate the bulletin for this deployment + """ + + return self.cap.get("bulletin_method") + + def get_cap_bulletin_officer(self): + """ + Name of the officer who is responsible to issue the bulletin + """ + + return self.cap.get("bulletin_officer", "Name of Officer") + + def get_cap_bulltin_officer_designation(self): + """ + Designation of the officer who is responsible to issue the bulletin + """ + + return self.cap.get("bulletin_officer_designation", "Designation") + # ------------------------------------------------------------------------- # CMS: Content Management System # diff --git a/modules/s3db/cap.py b/modules/s3db/cap.py index 9da7e6e313..942cd927ee 100644 --- a/modules/s3db/cap.py +++ b/modules/s3db/cap.py @@ -3358,6 +3358,7 @@ def cap_rheader(r): db = current.db s3db = current.s3db tablename = r.tablename + settings = current.deployment_settings if tablename == "cap_alert": alert_id = record.id itable = s3db.cap_info @@ -3411,6 +3412,7 @@ def cap_rheader(r): else: action_btn = None msg_type_buttons = None + bulletin_btns = [] if not row: error = DIV(T("You need to create at least one alert information item in order to be able to broadcast this alert!"), _class="error") @@ -3424,26 +3426,50 @@ def cap_rheader(r): has_permission = current.auth.s3_has_permission # Display 'Submit for Approval', 'Publish Alert' or - # 'Review Alert' based on permission and deployment settings + # 'Review Alert' and Bulletin Form print button based + # on permission and deployment settings if not current.request.get_vars.get("_next") and \ - current.deployment_settings.get_cap_authorisation() and \ + settings.get_cap_authorisation() and \ record.approved_by is None: # Show these buttons only if there is atleast one area segment area_table = s3db.cap_area area_row = db(area_table.alert_id == alert_id).\ select(area_table.id, limitby=(0, 1)).first() - if area_row and has_permission("update", "cap_alert", + if area_row: + # Show these buttons only if there is at least one area segment + cap_bulletin_method = settings.get_cap_bulletin_method() + if cap_bulletin_method: + irows = db(itable.alert_id == alert_id).select(\ + itable.language) + for irow in irows: + language = irow.language + btn = A(T("%s Form" % (itable.language.represent(language))), + _href = URL(c = "default", + f = "index", + args = [cap_bulletin_method], + vars = {"lan": language, + "alert_id": alert_id, + } + ), + _class = "action-btn button tiny", + _target = "_blank", + ) + bulletin_btns.append(btn) + + # Display 'Submit for Approval', 'Publish Alert' or + # 'Review Alert' based on permission and deployment settings + if has_permission("update", "cap_alert", record_id=alert_id): - action_btn = A(T("Submit for Approval"), - _href = URL(f = "notify_approver", - vars = {"cap_alert.id": alert_id, - }, - ), - _class = "action-btn confirm-btn button tiny" - ) - current.response.s3.jquery_ready.append( -'''S3.confirmClick('.confirm-btn','%s')''' % T("Do you want to submit the alert for approval?")) + action_btn = A(T("Submit for Approval"), + _href = URL(f = "notify_approver", + vars = {"cap_alert.id": alert_id, + }, + ), + _class = "action-btn confirm-btn button tiny" + ) + current.response.s3.jquery_ready.append( + '''S3.confirmClick('.confirm-btn','%s')''' % T("Do you want to submit the alert for approval?")) # For Alert Approver if has_permission("approve", "cap_alert"): @@ -3555,6 +3581,10 @@ def cap_rheader(r): if msg_type_buttons is not None: rheader.insert(1, msg_type_buttons) + if len(bulletin_btns): + for bulletin_btn in bulletin_btns: + rheader.insert(1, bulletin_btn) + elif tablename == "cap_area": # Used only for Area Templates tabs = [(T("Area"), None), diff --git a/modules/templates/SAMBRO/Demo/organisation.csv b/modules/templates/SAMBRO/Demo/organisation.csv index ed195f3a11..ce889358cc 100644 --- a/modules/templates/SAMBRO/Demo/organisation.csv +++ b/modules/templates/SAMBRO/Demo/organisation.csv @@ -1,5 +1,4 @@ Organisation,KV:cap_oid,Acronym,Type,Country,Website,Twitter,Comments -Abteilung Wasserhaushal,2.49.0.0.40.1,Acronym,Type,Country,Website,Twitter,Comments Department of Hydrology and Meteorology,2.49.0.0.524.0,DHM,Government,NP,www.dhm.gov.np,, Department of Meteorology and Hydrology,2.49.0.0.428.0,DMH,Government,MM,www.dmh.gov.mm,, National Disaster Management Center,2.49.0.0.462.1,NDMC,Government,MV,ndmc.gov.mv,, diff --git a/modules/templates/SAMBRO/PH/config.py b/modules/templates/SAMBRO/PH/config.py index 1fc2cac902..7d02b7a45b 100644 --- a/modules/templates/SAMBRO/PH/config.py +++ b/modules/templates/SAMBRO/PH/config.py @@ -44,4 +44,8 @@ def config(settings): args = ["SAMBRO", "PH", "img", "pagasa.png"], ) + # Name of Method used to create bulletin + # This may vary according to organization implementing it + settings.cap.bulletin_method = "bulletin_ocd" + # END ========================================================================= diff --git a/modules/templates/SAMBRO/PH/controllers.py b/modules/templates/SAMBRO/PH/controllers.py index 7ad11a0b1e..fb31f64991 100644 --- a/modules/templates/SAMBRO/PH/controllers.py +++ b/modules/templates/SAMBRO/PH/controllers.py @@ -1,9 +1,86 @@ # -*- coding: utf-8 -*- +from gluon import current +from gluon.html import * + +from s3 import S3CustomController, s3_str + from templates.SAMBRO.controllers import index, subscriptions, user_info, alert_hub_cop +# ----------------------------------------------------------------------------- class alert_map(index): pass +# ----------------------------------------------------------------------------- class index(alert_hub_cop): pass + +# ----------------------------------------------------------------------------- +class bulletin_ocd(S3CustomController): + """ Generate the Bulletin for OCD """ + + def __call__(self): + """ Main entry point, configuration """ + + r = current.request + + alert_id = r.vars.get("alert_id") + if not alert_id: + return "alert id is required to generate report" + + language = r.vars.get("lan", "en-US") + current.response.view = "../modules/templates/SAMBRO/PH/views/bulletin_ocd.html" + s3db = current.s3db + table = s3db.cap_alert + itable = s3db.cap_info + atable = s3db.cap_area + ptable = s3db.cap_info_parameter + query = (table.id == alert_id) & \ + (table.deleted != True) & \ + (itable.alert_id == table.id) & \ + (itable.deleted != True) & \ + (itable.language == language) & \ + (atable.alert_id == table.id) & \ + (atable.deleted != True) & \ + (ptable.info_id == itable.id) & \ + (ptable.deleted != True) + + arows = current.db(query).select(table.status, + table.source, + itable.description, + itable.instruction, + itable.headline, + itable.contact, + ptable.name, + ptable.value) + parameter_table = TABLE(_style="width: 90%; margin:0 auto") + if len(arows): + settings = current.deployment_settings + parameters = {} + row_info = arows.first().cap_info + row_alert = arows.first().cap_alert + for arow in arows: + name = arow.cap_info_parameter.name + if "sahana:bulletin" in name: + parameter_table_row = TR(TD(B(name.split("sahana:bulletin:", 1)[1]), + _style="border: 1px solid grey", + ), + TD(arow.cap_info_parameter.value, + _style="border: 1px solid grey", + )) + parameter_table.append(parameter_table_row) + + output = dict(instruction=s3_str(row_info.instruction), + description=s3_str(row_info.description), + headline=s3_str(row_info.headline), + status=s3_str(row_alert.status), + time=s3_str(r.utcnow.strftime("%d %B %Y, %I:%M %p")), + source=s3_str(row_alert.source), + parameter_table=parameter_table, + contact=s3_str(row_info.contact), + releasing_officer=settings.get_cap_bulletin_officer(), + releasing_officer_designation=settings.get_cap_bulltin_officer_designation(), + ) + + return output + return "No parameter with sahana:bulletin:" diff --git a/modules/templates/SAMBRO/PH/views/bulletin_ocd.html b/modules/templates/SAMBRO/PH/views/bulletin_ocd.html new file mode 100644 index 0000000000..fa0ebebb3a --- /dev/null +++ b/modules/templates/SAMBRO/PH/views/bulletin_ocd.html @@ -0,0 +1,89 @@ + + + + + + Office of Civil Defense Bulletin + + + + + +
+
+
+ +
+
+ Republic of the Philippines +
+
+

National Disaster Risk Reduction and Management Council

+
+
+
+
National Disaster Risk Reduction and Management Center, Camp Aguinaldo, Quezon City, Philippines
+
+
+
+
+
+

NDRRMC {{=XML(status)}}

+
+
+ {{=XML(headline)}} +
+
+ Releasing Officer:


+ {{=XML(releasing_officer)}}
{{=XML(releasing_officer_designation)}} +
+
+
+
+
+
+ DATE: {{=XML(time)}} +
+
+
+ Source: {{=XML(source)}} +
+
+
+
+ I. Situational Overview

+
+ {{=XML(parameter_table)}} +
+ Description: {{=XML(description)}} +
+
+
+
+ II. Action/s Taken +
+ {{=XML(instruction)}} +
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/static/img/ndrrmc_logo.jpg b/static/img/ndrrmc_logo.jpg new file mode 100644 index 0000000000..79cecf2f0d Binary files /dev/null and b/static/img/ndrrmc_logo.jpg differ