-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulletin Form for OCD PH #1470
base: master
Are you sure you want to change the base?
Bulletin Form for OCD PH #1470
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This stuff seems too dynamic to want to put into settings...although that is about to become more accessible via WebSetup. |
||
|
||
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 | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If using the S3Method & DB configuration, the cap_bulletin table could be queried & if there is an undeleted row then proceed to add the buttons |
||
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), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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:" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html lang="{{=T.accepted_language or "en"}}"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | ||
<title>Office of Civil Defense Bulletin</title> | ||
<meta name="application-name" content="{{=appname}}" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> | ||
<link rel="shortcut icon" href="/{{=appname}}/static/favicon.ico" type="image/x-icon" /> | ||
</head> | ||
<body> | ||
<div id='ocd-wrapper' style='font-family: sans-serif'> | ||
<div id='ocd-header'> | ||
<div id='ocd-header-top' style='clear:both'> | ||
<div id='ocd-header-logo'> | ||
<img src='/{{=appname}}/static/img/ndrrmc_logo.jpg' style='height: 6em; float: left' /> | ||
</div> | ||
<div id='ocd-header-heading' style='display: block; | ||
text-transform: uppercase; | ||
text-align: center; | ||
margin-left: 7em; | ||
word-spacing: 0; | ||
letter-spacing: 0; | ||
margin-top: 1em;'> | ||
<div id='ocd-header-heading-1' style='line-height:0'> | ||
<b>Republic of the Philippines</b> | ||
</div> | ||
<div id='ocd-header-heading-2' style='line-height:0'> | ||
<h4><b>National Disaster Risk Reduction and Management Council</b></h4> | ||
</div> | ||
<hr style='border: 1px solid blue' /> | ||
<div id='ocd-header-heading-3' style='text-transform:none; line-height: 0'> | ||
<h6>National Disaster Risk Reduction and Management Center, Camp Aguinaldo, Quezon City, Philippines</h6> | ||
</div> | ||
</div> | ||
</div> | ||
<div id='ocd-header-bottom'> | ||
<div id='ocd-header-subject' style='text-transform: uppercase; | ||
text-decoration: underline; | ||
text-align: center; | ||
margin-bottom: 1em;'> | ||
<h2><b>NDRRMC {{=XML(status)}}</b></h2> | ||
</div> | ||
<div id='ocd-header-subject-description' style='text-align: center'> | ||
{{=XML(headline)}} | ||
</div> | ||
<div id='ocd-header-signature' style='margin-left: 60%; | ||
margin-top: 2em; | ||
text-align: center;'> | ||
Releasing Officer: <br /><br /><br /> | ||
<b>{{=XML(releasing_officer)}}</b> <br />{{=XML(releasing_officer_designation)}} | ||
</div> | ||
</div> | ||
</div> | ||
<div id='ocd-body'> | ||
<div id='ocd-body-top'> | ||
<div id='ocd-body-top-date' style='line-height: 0'> | ||
DATE: {{=XML(time)}} | ||
</div> | ||
<hr /> | ||
<div id='ocd-body-top-source' style='line-height: 0; margin-bottom: 2em'> | ||
Source: {{=XML(source)}} | ||
</div> | ||
</div> | ||
<div id='ocd-body-main'> | ||
<div id='ocd-situational-overview'> | ||
<b style='text-transform: uppercase'>I. Situational Overview</b> <br /><br /> | ||
<div id='ocd-parameter-body'> | ||
{{=XML(parameter_table)}} | ||
<div id='ocd-body-description' style='margin-top: 1em'> | ||
<b>Description: </b>{{=XML(description)}} | ||
</div> | ||
</div> | ||
</div> | ||
<div id='ocd-instruction' style='margin-top: 1em;'> | ||
<b style='text-transform: uppercase'>II. Action/s Taken</b> | ||
<div id='ocd-body-description'> | ||
{{=XML(instruction)}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div id='ocd-footer' style='margin-top: 10em; text-align: center;'> | ||
<hr style='border: 2px solid blue'>{{=XML(contact)}} | ||
</div> | ||
</div> | ||
<script>window.print();</script> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to have this be configurable via settings like this?
What I would propose would be an S3Method for cap/alert/[id]/bulletin
This would still allow the template to define a custom function in config.py