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
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
  • Loading branch information
michaelhowden committed May 26, 2015
1 parent d470d19 commit f5500c4
Show file tree
Hide file tree
Showing 30 changed files with 3,005 additions and 337 deletions.
9 changes: 7 additions & 2 deletions controllers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ def register_validation(form):

# =============================================================================
def index():
""" Main Home Page """

""" Customized Main Home Page (in modules/<TEMPLATE>/config.py) """
index_function = settings.get("customise_default_home",index_default)
return index_function()
# -----------------------------------------------------------------------------
def index_default():
""" Default 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
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
152 changes: 83 additions & 69 deletions modules/s3/s3widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7911,75 +7911,89 @@ 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",
"ambulance": "fa-ambulance",
"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",
"create":"fa-plus",
"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",
"hospital":"fa-hospital-o",
"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",
"receive": "fa-sign-in",
"recv_shipments": "fa-indent",
"remove": "fa-remove",
"request": "fa-flag",
"resource": "fa-cube",
"responsibility": "fa-briefcase",
"rss": "fa-rss",
"sent": "fa-check",
"send": "fa-sign-out",
"sent_shipments": "fa-outdent",
"shelter": "fa-home",
"site": "fa-home",
"site-current": "fa-square",
"sites-all": "fa-th",
"skype": "fa-skype",
"star": "fa-star",
"stock": "fa-cubes",
"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",
"volunteer": "fa-user",
"volunteers": "fa-users",
"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 @@ -3499,6 +3499,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
25 changes: 22 additions & 3 deletions modules/s3db/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,9 @@ def model(self):
#send_type_opts.update(self.inv_item_status_opts)
send_type_opts.update(settings.get_inv_send_types())

self.org_facility # Load model + crud_strings
ADD_FACILITY = crud_strings.org_facility.label_create

site_types = auth.org_site_types
tablename = "inv_send"
define_table(tablename,
Expand Down Expand Up @@ -1094,6 +1097,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 +1190,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 +1203,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 +1213,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 +1887,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 +2160,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 +2553,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: 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
2 changes: 2 additions & 0 deletions modules/s3db/vol.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ def prep(r):
list_fields.append((T("Trainings"),"person_id$training.course_id"))
if settings.get_hrm_use_certificates():
list_fields.append((T("Certificates"),"person_id$certification.certificate_id"))
if r.representation == "xls":
list_fields.append("person_id$comments")

# Volunteer Programme and Active-status
report_options = get_config("report_options")
Expand Down
Loading

0 comments on commit f5500c4

Please sign in to comment.