Skip to content
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

Minor Homepage enhancements for Nepal #1084

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
137 changes: 68 additions & 69 deletions modules/s3/s3widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7925,75 +7925,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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you changed/added some keys here. If you do that, please make sure the same keys are available in every icon set - or, if that is not possible, move the additional keys into settings.ui.custom_icons (same dict structure).

All icon sets should have a consistent set of default icons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to settings.ui.custom_icons

"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 @@ -5174,7 +5174,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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this seems like we're hardcoding somethign which is configurable? Always nasty, but can be mitigated with lots of warnings in code about other locations this is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - this is nothing new...
However we were hard coding it wrong - so this has been fixed.
No time to go through and change all of these now.

)

# 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 @@ -323,7 +323,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 @@ -2119,11 +2119,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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a deployment_setting.
We have similar already, such as:
https://github.com/flavour/eden/blob/master/modules/s3cfg.py#L2803

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

f="item",
label=ADD_ITEM,
Expand Down
4 changes: 3 additions & 1 deletion 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 Expand Up @@ -1148,7 +1150,7 @@ def prep(r):

resource = r.resource
if mode is not None:
r.resource.build_query(id=s3_logged_in_person())
r.resource.build_query(id=current.auth.s3_logged_in_person())
elif r.method not in ("deduplicate", "search_ac"):
if not r.id and not hr_id:
# pre-action redirect => must retain prior errors
Expand Down
Loading