Skip to content

Commit

Permalink
Nepal Template Customisation
Browse files Browse the repository at this point in the history
Inv
* Fix Beneficiary Column on Release Report (=To not From)
* Distribution Report
* Locations in Filters
* Add Staff to Nepal Menu
* Use clusters
General
* If the site is only configed for one country, use the hierarchy for that country
* Setting for get_supply_autocomplete
* Fix in creating hrm
* Fix bug in Inv_send filter
* Menu implemented usng S3NavigationItem
* Font Awesome 4 added
* Remove duplicate "Resource Inventory" menu item
* "Resource Inventory" -> "Resources" (KISS)
* Fix error in vol
* Always add comments field to Excel output
* Increase org_organisation.acronym.length to import SBTF Data ("USAID, OFDA, US DoD" = 19)
  • Loading branch information
michaelhowden committed Jun 2, 2015
1 parent 877d098 commit 8a28bad
Show file tree
Hide file tree
Showing 33 changed files with 2,958 additions and 350 deletions.
2 changes: 1 addition & 1 deletion controllers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def register_validation(form):
# =============================================================================
def index():
""" Main Home Page """

auth.settings.register_onvalidation = register_validation
auth.configure_user_fields()

Expand Down
29 changes: 28 additions & 1 deletion controllers/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ def track_item():
#"send_id",
#"req_item_id",
(T("Date Released"), "send_id$date"),
(T("Beneficiary"), "send_id$site_id"),
(T("Beneficiary"), "send_id$to_site_id"),
(settings.get_inv_send_shortname(), "send_id$send_ref"),
(settings.get_req_shortname(), "send_id$req_ref"),
(T("Items/Description"), "item_id"),
Expand Down Expand Up @@ -1460,6 +1460,33 @@ def track_item():
]
)
s3.filter = (FS("expiry_date") != None)
elif report == "dist":
# Summary of Releases
s3.crud_strings["inv_track_item"] = Storage(title_list = T("Distribution Report"))

level_fields = ["send_id$to_site_id$location_id$%s" % level for
level in current.gis.get_relevant_hierarchy_levels()]

s3db.configure("inv_track_item",
list_fields = ["id",
#"send_id",
#"req_item_id",
(T("Date Sent"), "send_id$date"),
(s3db.inv_send.to_site_id.label, "send_id$to_site_id")] +
level_fields +
[(settings.get_inv_send_shortname(), "send_id$send_ref"),
(settings.get_req_shortname(), "send_id$req_ref"),
(T("Items"), "item_id"),
(T("Source"), "supply_org_id"),
(T("Unit"), "item_pack_id"),
(T("Quantity"), "quantity"),
(T("Unit Cost"), "pack_value"),
(T("Total Cost"), "total_value"),
],
orderby = "inv_send.date dsc",
sort = True
)
s3.filter = (FS("send_id$type") == 21)

output = s3_rest_controller(rheader = s3db.inv_rheader)
return output
Expand Down
3 changes: 3 additions & 0 deletions modules/s3/s3codecs/xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def encode(self, data_source, **attr):
list_fields = attr.get("list_fields")
if not list_fields:
list_fields = data_source.list_fields()
# Always export comments field
if "comments" in data_source.fields and "comments" not in list_fields:
list_fields.append("comments")
group = attr.get("dt_group")
use_colour = attr.get("use_colour", False)

Expand Down
11 changes: 10 additions & 1 deletion modules/s3/s3gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ def get_location_hierarchy(self, level=None, location=None):
db = current.db
s3db = current.s3db
table = s3db.gis_hierarchy
ltable = s3db.gis_location

fields = (table.uuid,
table.L1,
Expand All @@ -1536,7 +1537,15 @@ def get_location_hierarchy(self, level=None, location=None):
table.L5,
)

query = (table.uuid == "SITE_DEFAULT")
countries = current.deployment_settings.get_gis_countries()
if len(countries) == 1:
#If the site is only configed for one country, use the hierarchy for that country
query = (table.location_id == ltable.id) & \
(ltable.level == "L0") & \
(ltable.name == self.get_country(countries[0],key_type="code"))
else:
query = (table.uuid == "SITE_DEFAULT")

if not location:
config = GIS.get_config()
location = config.region_location_id
Expand Down
2 changes: 1 addition & 1 deletion modules/s3/s3query.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def __init__(self, resource, selector, label=None):
# Fall back to the field label
if label is None:
fname = self.fname
if fname in ["L1", "L2", "L3", "L3", "L4", "L5"]:
if fname in ("L1", "L2", "L3", "L3", "L4", "L5"):
try:
label = current.gis.get_location_hierarchy(fname)
except:
Expand Down
137 changes: 68 additions & 69 deletions modules/s3/s3widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7911,75 +7911,74 @@ class ICON(I):
"zoomin": "icon-zoomin",
"zoomout": "icon-zoomout",
},
# @todo: integrate
#"font-awesome4": {
#"_base": "fa",
#"active": "fa-check",
#"activity": "fa-tag",
#"add": "fa-plus",
#"arrow-down": "fa-arrow-down",
#"attachment": "fa-paper-clip",
#"bar-chart": "fa-bar-chart",
#"book": "fa-book",
#"bookmark": "fa-bookmark",
#"bookmark-empty": "fa-bookmark-empty",
#"briefcase": "fa-briefcase",
#"calendar": "fa-calendar",
#"certificate": "fa-certificate",
#"comment-alt": "fa-comment-o",
#"commit": "fa-truck",
#"delete": "fa-trash",
#"deploy": "fa-plus",
#"deployed": "fa-check",
#"down": "fa-caret-down",
#"edit": "fa-edit",
#"exclamation": "fa-exclamation",
#"facebook": "fa-facebook",
#"facility": "fa-home",
#"file": "fa-file",
#"file-alt": "fa-file-alt",
#"folder-open-alt": "fa-folder-open-o",
#"fullscreen": "fa-fullscreen",
#"globe": "fa-globe",
#"group": "fa-group",
#"home": "fa-home",
#"inactive": "fa-check-empty",
#"link": "fa-external-link",
#"list": "fa-list",
#"location": "fa-globe",
#"mail": "fa-envelope-o",
#"map-marker": "fa-map-marker",
#"offer": "fa-truck",
#"organisation": "fa-institution",
#"org-network": "fa-umbrella",
#"other": "fa-circle",
#"paper-clip": "fa-paper-clip",
#"phone": "fa-phone",
#"plus": "fa-plus",
#"plus-sign": "fa-plus-sign",
#"radio": "fa-microphone",
#"remove": "fa-remove",
#"request": "fa-flag",
#"responsibility": "fa-briefcase",
#"rss": "fa-rss",
#"sent": "fa-check",
#"site": "fa-home",
#"skype": "fa-skype",
#"star": "fa-star",
#"table": "fa-table",
#"tag": "fa-tag",
#"tags": "fa-tags",
#"tasks": "fa-tasks",
#"time": "fa-time",
#"truck": "fa-truck",
#"twitter": "fa-twitter",
#"unsent": "fa-times",
#"up": "fa-caret-up",
#"upload": "fa-upload",
#"user": "fa-user",
#"zoomin": "fa-zoomin",
#"zoomout": "fa-zoomout",
#},
"font-awesome4": {
"_base": "fa",
"active": "fa-check",
"activity": "fa-tag",
"add": "fa-plus",
"arrow-down": "fa-arrow-down",
"attachment": "fa-paper-clip",
"bar-chart": "fa-bar-chart",
"book": "fa-book",
"bookmark": "fa-bookmark",
"bookmark-empty": "fa-bookmark-empty",
"briefcase": "fa-briefcase",
"calendar": "fa-calendar",
"certificate": "fa-certificate",
"comment-alt": "fa-comment-o",
"commit": "fa-truck",
"delete": "fa-trash",
"deploy": "fa-plus",
"deployed": "fa-check",
"down": "fa-caret-down",
"edit": "fa-edit",
"exclamation": "fa-exclamation",
"facebook": "fa-facebook",
"facility": "fa-home",
"file": "fa-file",
"file-alt": "fa-file-alt",
"folder-open-alt": "fa-folder-open-o",
"fullscreen": "fa-fullscreen",
"globe": "fa-globe",
"group": "fa-group",
"home": "fa-home",
"inactive": "fa-check-empty",
"link": "fa-external-link",
"list": "fa-list",
"location": "fa-globe",
"mail": "fa-envelope-o",
"map-marker": "fa-map-marker",
"offer": "fa-truck",
"organisation": "fa-sitemap",
"org-network": "fa-umbrella",
"other": "fa-circle",
"paper-clip": "fa-paper-clip",
"phone": "fa-phone",
"plus": "fa-plus",
"plus-sign": "fa-plus-sign",
"radio": "fa-microphone",
"remove": "fa-remove",
"request": "fa-flag",
"responsibility": "fa-briefcase",
"rss": "fa-rss",
"sent": "fa-check",
"site": "fa-home",
"skype": "fa-skype",
"star": "fa-star",
"table": "fa-table",
"tag": "fa-tag",
"tags": "fa-tags",
"tasks": "fa-tasks",
"time": "fa-time",
"truck": "fa-truck",
"twitter": "fa-twitter",
"unsent": "fa-times",
"up": "fa-caret-up",
"upload": "fa-upload",
"warehouse":"fa-th",
"zoomin": "fa-zoomin",
"zoomout": "fa-zoomout",
},
"foundation": {
"active": "fi-check",
"activity": "fi-price-tag",
Expand Down
5 changes: 5 additions & 0 deletions modules/s3cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3511,6 +3511,11 @@ def get_req_restrict_on_complete(self):
# -------------------------------------------------------------------------
# Supply
#
def get_supply_autocomplete(self):
"""
Whether supply fields should use an Autocomplete instead of a dropdown
"""
return self.supply.get("autocomplete", False)
def get_supply_catalog_default(self):
return self.inv.get("catalog_default", "Default")

Expand Down
2 changes: 1 addition & 1 deletion modules/s3db/hrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ def hrm_human_resource_onaccept(form):
ltable.insert(human_resource_id=id,
job_title_id=job_title_id,
main=True,
start_date=request.utcnow,
date=request.utcnow,
)

data = Storage()
Expand Down
24 changes: 21 additions & 3 deletions modules/s3db/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,8 @@ def model(self):
#send_type_opts.update(self.inv_item_status_opts)
send_type_opts.update(settings.get_inv_send_types())

ADD_FACILITY = T("Create Facility")

site_types = auth.org_site_types
tablename = "inv_send"
define_table(tablename,
Expand Down Expand Up @@ -1094,6 +1096,10 @@ def model(self):
not_filterby = "obsolete",
not_filter_opts = (True,),
)),
comment = S3AddResourceLink(c="org",
f="facility",
label=ADD_FACILITY,
title=ADD_FACILITY)
),
organisation_id(
label = T("To Organization"),
Expand Down Expand Up @@ -1183,6 +1189,8 @@ def model(self):
s3_comments(),
*s3_meta_fields())

levels = current.gis.get_relevant_hierarchy_levels()

# Filter Widgets
filter_widgets = [
S3TextFilter(["sender_id$first_name",
Expand All @@ -1194,7 +1202,7 @@ def model(self):
"recipient_id$first_name",
"recipient_id$middle_name",
"recipient_id$last_name",
],
] + ["to_site_id$location_id$%s" % level for level in levels],
label = T("Search"),
comment = T("Search for an item by text."),
),
Expand All @@ -1204,6 +1212,9 @@ def model(self):
cols = 2,
hidden = True,
),
S3LocationFilter("to_site_id$location_id",
levels=levels,
),
S3TextFilter("type",
label = T("Shipment Type"),
hidden = True,
Expand Down Expand Up @@ -1875,6 +1886,12 @@ def model(self):
label = T("Search"),
#comment = recv_search_comment,
),
S3OptionsFilter("send_id$site_id"),
S3LocationFilter("send_id$to_site_id$location_id",
#hidden=True,
label=T("Sent to Location"),
levels=levels,
),
S3DateFilter("send_id$date",
label = T("Sent date"),
hidden = True,
Expand Down Expand Up @@ -2142,7 +2159,8 @@ def inv_send_controller(cls):
s3 = response.s3

# Limit site_id to sites the user has permissions for
error_msg = T("You do not have permission for any facility to send a shipment.")
error_msg = T("You do not have permission for any %s to send a shipment.") % \
current.deployment_settings.get_inv_facility_label()
current.auth.permitted_facilities(table=sendtable, error_msg=error_msg)

# Set Validator for checking against the number of items in the warehouse
Expand Down Expand Up @@ -2534,7 +2552,7 @@ def inv_send_process():
site_id = send_record.to_site_id,
comments = send_record.comments,
status = SHIP_STATUS_SENT,
type = 1, # 1:"Another Inventory"
type = 11, # 11:"Another Inventory"
)

# Change the status for all track items in this shipment to In transit
Expand Down
6 changes: 3 additions & 3 deletions modules/s3db/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def model(self):
label = T("Name"),
),
# http://hxl.humanitarianresponse.info/#abbreviation
Field("acronym", length=16,
Field("acronym", length=20,
label = T("Acronym"),
represent = lambda val: val or "",
comment = DIV(_class="tooltip",
Expand Down Expand Up @@ -1898,11 +1898,11 @@ def model(self):
crud_strings[tablename] = Storage(
label_create = T("Create Resource"),
title_display = T("Resource Details"),
title_list = T("Resource Inventory"),
title_list = T("Resources"),
title_update = T("Edit Resource"),
title_map = T("Map of Resources"),
title_upload = T("Import Resources"),
label_list_button = T("Resource Inventory"),
label_list_button = T("Resources"),
label_delete_button = T("Delete Resource"),
msg_record_created = T("Resource added"),
msg_record_modified = T("Resource updated"),
Expand Down
6 changes: 5 additions & 1 deletion modules/s3db/supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ def model(self):
supply_item_represent = supply_ItemRepresent(show_link=True)

# Reusable Field
if settings.get_supply_autocomplete():
default_widget = S3AutocompleteWidget("supply", "item")
else:
default_widget = None
supply_item_id = S3ReusableField("item_id",
"reference %s" % tablename, # 'item_id' for backwards-compatibility
label = T("Item"),
Expand All @@ -434,7 +438,7 @@ def model(self):
supply_item_represent,
sort=True),
sortby = "name",
widget = S3AutocompleteWidget("supply", "item"),
widget = default_widget,
comment=S3AddResourceLink(c="supply",
f="item",
label=ADD_ITEM,
Expand Down
Loading

0 comments on commit 8a28bad

Please sign in to comment.