From 79343ed253cb2b30fc2f653305ba4444914218d2 Mon Sep 17 00:00:00 2001 From: trendspotter Date: Fri, 29 Sep 2017 12:35:39 +0200 Subject: [PATCH] Fire module refresh - Remove/comment dependencies on IRS (index, vehicle_reports) - Fix error while adding fire station without a code - Allow import and display map of fire zones - Add title to Zone Types popup --- controllers/fire.py | 56 +++++++++----------------------------------- modules/s3db/fire.py | 13 +++++----- modules/s3menus.py | 7 +++--- 3 files changed, 21 insertions(+), 55 deletions(-) diff --git a/controllers/fire.py b/controllers/fire.py index e28e726eb2..085a9787a3 100644 --- a/controllers/fire.py +++ b/controllers/fire.py @@ -10,50 +10,16 @@ def index(): """ Module Homepage """ - module_name = settings.modules[module].name_nice - response.title = module_name - - htable = s3db.fire_shift_staff - stable = s3db.fire_station - station_id = None - station_name = None - - human_resource_id = auth.s3_logged_in_human_resource() - query = htable.human_resource_id == human_resource_id - - left = htable.on(htable.station_id == stable.id) - - row = db(query).select(htable.station_id, - stable.name, - left = left, - limitby = (0, 1), - ).first() - if row: - station_id = row.fire_shift_staff.station_id - station_name = row.fire_station.name - - # Note that this requires setting the Porto Incident Types in modules/s3db/irs.py - incidents = DIV(A(DIV(T("Fire"), - _style="background-color:red;", - _class="question-container fleft"), - _href=URL(c="irs", f="ireport", args=["create"], - vars={"type":"fire"})), - A(DIV(T("Rescue"), - _style="background-color:green;", - _class="question-container fleft"), - _href=URL(c="irs", f="ireport", args=["create"], - vars={"type":"rescue"})), - A(DIV(T("Hazmat"), - _style="background-color:yellow;", - _class="question-container fleft"), - _href=URL(c="irs", f="ireport", args=["create"], - vars={"type":"hazmat"}))) - - return dict(incidents = incidents, - station_id = station_id, - station_name = station_name, - module_name = module_name, - ) + return s3db.cms_index(module, alt_function="index_alt") + +# ----------------------------------------------------------------------------- +def index_alt(): + """ + Module homepage for non-Admin users when no CMS content found + """ + + # Just redirect to the list of Fire stations + s3_redirect_default(URL(f="station")) # ----------------------------------------------------------------------------- def zone(): @@ -155,7 +121,7 @@ def fire_rheader(r, tabs=[]): (T("Staff"), "human_resource"), #(T("Shifts"), "shift"), (T("Roster"), "shift_staff"), - (T("Vehicle Deployments"), "vehicle_report"), + #(T("Vehicle Deployments"), "vehicle_report"), ] rheader_tabs = s3_rheader_tabs(r, tabs) diff --git a/modules/s3db/fire.py b/modules/s3db/fire.py index c6e01aef8f..8e0a8ae764 100644 --- a/modules/s3db/fire.py +++ b/modules/s3db/fire.py @@ -108,6 +108,7 @@ def model(self): comment = S3PopupLink(c = "fire", f = "zone_type", label = ADD_ZONE_TYPE, + title = T("Zone Type"), tooltip = T("Select a Zone Type from the list or click 'Add Zone Type'"), ), label=T("Type")), @@ -194,7 +195,7 @@ def model(self): ), Field("code", length=10, # Mayon compatibility label = T("Code"), - represent = lambda v: v or NONE, + represent = lambda v: v or current.messages["NONE"], requires = code_requires, ), Field("facility_type", "integer", @@ -361,10 +362,10 @@ def model(self): msg_no_match = T("No Vehicles could be found"), msg_list_empty = T("No Vehicles currently registered")) - self.set_method("fire", "station", - method = "vehicle_report", - action = self.vehicle_report, - ) + #self.set_method("fire", "station", + # method = "vehicle_report", + # action = self.vehicle_report, + # ) # ===================================================================== # Water Sources @@ -569,7 +570,7 @@ def fire_staff_on_duty(station_id=None): def vehicle_report(r, **attr): """ Custom method to provide a report on Vehicle Deployment Times - - this is one of the main tools currently used to manage an Incident + @ToDo: Currently unused, requires deprecated irs module. Reimplement based on event module. """ rheader = attr.get("rheader", None) diff --git a/modules/s3menus.py b/modules/s3menus.py index 82137be003..dc87a90a41 100644 --- a/modules/s3menus.py +++ b/modules/s3menus.py @@ -937,13 +937,12 @@ def fire(): ), M("Fire Zones", f="zone")( M("Create", m="create"), - #M("Map", m="map"), - #M("Import", m="import"), + M("Map", m="map"), + M("Import", m="import"), ), M("Zone Types", f="zone_type")( M("Create", m="create"), - #M("Map", m="map"), - #M("Import", m="import"), + M("Import", m="import"), ), M("Water Sources", f="water_source")( M("Create", m="create"),