Skip to content

Commit

Permalink
Merge pull request #1082 from michaelhowden/master
Browse files Browse the repository at this point in the history
Misc Changes
  • Loading branch information
flavour committed May 7, 2015
2 parents 829469b + ed4a5a1 commit 41e18bb
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 62 deletions.
7 changes: 0 additions & 7 deletions controllers/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ def supplier():
msg_list_empty = T("No Suppliers currently registered")
)

# Modify filter_widgets
filter_widgets = s3db.get_config("org_organisation", "filter_widgets")
# Remove type (always 'Supplier')
filter_widgets.pop(1)
# Remove sector (not relevant)
filter_widgets.pop(1)

return s3db.org_organisation_controller()

# -----------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions controllers/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,6 @@ def supplier():
msg_list_empty = T("No Suppliers currently registered")
)

# Modify filter_widgets
filter_widgets = s3db.get_config("org_organisation", "filter_widgets")
# Remove type (always 'Supplier')
filter_widgets.pop(1)
# Remove sector (not relevant)
filter_widgets.pop(1)

# Open record in this controller after creation
s3db.configure("org_organisation",
Expand Down
6 changes: 6 additions & 0 deletions modules/s3cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2806,6 +2806,12 @@ def get_org_autocomplete(self):
"""
return self.org.get("autocomplete", False)

def get_org_sector(self):
"""
Whether to use an Organization Sector field
"""
return self.org.get("sector", False)

def get_org_branches(self):
"""
Whether to support Organisation Branches or not
Expand Down
133 changes: 95 additions & 38 deletions modules/s3db/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ def model(self):
"comments",
]

use_sector = settings.get_org_sector()
if use_sector:
form_fields.insert(3, S3SQLInlineLink("sector",
columns = 4,
label = T("Sectors"),
field = "sector_id",
),
)

if settings.get_org_summary():
# Include Summary fields in form
position = form_fields.index("year")
Expand Down Expand Up @@ -437,6 +446,8 @@ def model(self):
"acronym",
"comments",
]
if use_sector:
text_fields += ["sector.name", "sector.abrv"]

if settings.get_L10n_translate_org_organisation():
text_fields.extend(("name.name_l10n",
Expand Down Expand Up @@ -490,26 +501,60 @@ def model(self):
widgets = org_widgets,
)

filter_widgets = [
S3TextFilter(text_fields,
label = T("Search"),
comment = text_comment,
#_class = "filter-search",
),
# NB Order is important here - gets popped in asset & inv controllers & IFRC template
type_filter,
# NB Order is important here - gets popped in asset & inv controllers & IFRC template
S3OptionsFilter("sector_organisation.sector_id",
options = lambda: \
get_s3_filter_opts("org_sector",
location_filter=True,
none=True,
translate=True),
),
S3OptionsFilter("country",
#label = T("Home Country"),
),
]
list_fields = ["id",
"name",
"acronym",
"organisation_organisation_type.organisation_type_id",
"website"
]

if use_sector:
list_fields.insert(4,"sector_organisation.sector_id")

filter_widgets = [S3TextFilter(text_fields,
label = T("Search"),
comment = text_comment,
#_class = "filter-search",
),
]
append = filter_widgets.append

# Don't add Type or Sector Filters for Supplier organizations in the asset and inv controllers
if current.request.function != "supplier":
append(type_filter)
if use_sector:
append(S3OptionsFilter("sector_organisation.sector_id",
options = lambda: \
get_s3_filter_opts("org_sector",
location_filter=True,
none=True,
translate=True),
)
)

append(S3OptionsFilter("country",
#label = T("Home Country"),
),
)

report_fields = ["organisation_organisation_type.organisation_type_id",
"country",
]
if use_sector:
report_fields.insert(1, "sector_organisation.sector_id")
report_options = Storage(rows = report_fields,
cols = report_fields,
fact = ["count(id)",
"list(name)",
],
defaults=Storage(rows = "country",
cols = "organisation_organisation_type.organisation_type_id",
fact = "count(id)",
totals = True,
chart = "spectrum:cols",
#table = "collapse",
),
)

location_context = settings.get_org_organisation_location_context()

Expand All @@ -520,17 +565,13 @@ def model(self):
crud_form = crud_form,
deduplicate = self.organisation_duplicate,
filter_widgets = filter_widgets,
list_fields = ["id",
"name",
"acronym",
"organisation_organisation_type.organisation_type_id",
"website"
],
list_fields = list_fields,
list_layout = org_organisation_list_layout,
list_orderby = "org_organisation.name",
onaccept = self.org_organisation_onaccept,
ondelete = self.org_organisation_ondelete,
referenced_by = [(utablename, "organisation_id")],
report_options = report_options,
super_entity = "pr_pentity",
)

Expand Down Expand Up @@ -3361,9 +3402,6 @@ def model(self):
msg_record_deleted = T("Facility deleted"),
msg_list_empty = T("No Facilities currently registered"))

# Which levels of Hierarchy are we using?
levels = current.gis.get_relevant_hierarchy_levels()

text_fields = ["name",
"code",
"comments",
Expand All @@ -3376,6 +3414,8 @@ def model(self):
"organisation_id",
]

# Which levels of Hierarchy are we using?
levels = current.gis.get_relevant_hierarchy_levels()
for level in levels:
lfield = "location_id$%s" % level
report_fields.append(lfield)
Expand Down Expand Up @@ -3482,6 +3522,7 @@ def model(self):
cols = "site_facility_type.facility_type_id",
fact = "count(id)",
totals = True,
chart = "barchart:rows",
),
)

Expand Down Expand Up @@ -4109,26 +4150,26 @@ def model(self):
#hidden = True,
)

# Which levels of Hierarchy are we using?
levels = current.gis.get_relevant_hierarchy_levels()

text_fields = ["name",
"code",
"comments",
"organisation_id$name",
"organisation_id$acronym",
]

list_fields = ["id",
"name",
"organisation_id", # Filtered in Component views
"office_type_id",
]
report_fields = ["name",
"organisation_id", # Filtered in Component views
"office_type_id",
]

# Which levels of Hierarchy are we using?
levels = current.gis.get_relevant_hierarchy_levels()
for level in levels:
lfield = "location_id$%s" % level
report_fields.append(lfield)
text_fields.append(lfield)

list_fields = list(report_fields)
list_fields += [(T("Address"), "location_id$addr_street"),
"phone1",
"email",
Expand All @@ -4151,6 +4192,21 @@ def model(self):
),
]

report_options = Storage(
rows = report_fields,
cols = report_fields,
fact = ["count(id)",
"list(name)",
],
defaults = Storage(rows = lfield, # Lowest-level of hierarchy
cols = "office_type_id",
fact = "count(id)",
totals = True,
chart = "spectrum:rows",
),
)


configure(tablename,
context = {"location": "location_id",
"organisation": "organisation_id",
Expand All @@ -4177,6 +4233,7 @@ def model(self):
"recv",
"address",
),
report_options = report_options,
super_entity = ("doc_entity", "pr_pentity", "org_site"),
update_realm = True,
)
Expand Down Expand Up @@ -4430,7 +4487,7 @@ def org_organisation_logo(id,
_height=60,
)
return logo
return DIV() # no logo so return an empty div
return ""

# =============================================================================
def org_parents(organisation_id, path=[]):
Expand Down
27 changes: 18 additions & 9 deletions modules/s3menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ def hrm():
# to have them checked only immediately before rendering:
manager_mode = lambda i: s3.hrm.mode is None
personal_mode = lambda i: s3.hrm.mode is not None
skills = lambda i: settings.get_hrm_use_skills()
certificates = lambda i: settings.get_hrm_use_certificates()
is_org_admin = lambda i: s3.hrm.orgs and True or \
ADMIN in s3.roles
settings = current.deployment_settings
Expand All @@ -994,14 +996,15 @@ def hrm():
check=manager_mode)(
M("Create", m="create"),
M("Search by Skills", f="competency"),
M("Search by Skills", f="competency", check=skills),
M("Import", f="person", m="import",
vars={"group":"staff"}, p="create"),
),
M("Staff & Volunteers (Combined)",
c="hrm", f="human_resource", m="summary",
check=[manager_mode, vol_enabled]),
check=(manager_mode, vol_enabled)),
M(teams, f="group",
check=[manager_mode, use_teams])(
check=(manager_mode, use_teams))(
M("Create", m="create"),
M("Search Members", f="group_membership"),
M("Import", f="group_membership", m="import"),
Expand All @@ -1015,7 +1018,7 @@ def hrm():
M("Create", m="create"),
),
M("Skill Catalog", f="skill",
check=manager_mode)(
check=(manager_mode, skills))(
M("Create", m="create"),
#M("Skill Provisions", f="skill_provision"),
),
Expand Down Expand Up @@ -1071,23 +1074,25 @@ def vol():
show_programmes = lambda i: settings.get_hrm_vol_experience() == "programme"
show_tasks = lambda i: settings.has_module("project") and \
settings.get_project_mode_task()
skills = lambda i: settings.get_hrm_use_skills()
certificates = lambda i: settings.get_hrm_use_certificates()
teams = settings.get_hrm_teams()
use_teams = lambda i: teams
show_staff = lambda i: settings.get_hrm_show_staff()

return M(c="vol")(
M("Volunteers", f="volunteer", m="summary",
check=[manager_mode])(
check=(manager_mode))(
M("Create", m="create"),
M("Search by skills", f="competency"),
M("Search by skills", f="competency", check=skills),
M("Import", f="person", m="import",
vars={"group":"volunteer"}, p="create"),
),
M("Staff & Volunteers (Combined)",
c="vol", f="human_resource", m="summary",
check=[manager_mode, show_staff]),
check=(manager_mode, show_staff)),
M(teams, f="group",
check=[manager_mode, use_teams])(
check=(manager_mode, use_teams))(
M("Create", m="create"),
M("Search Members", f="group_membership"),
M("Import", f="group_membership", m="import"),
Expand Down Expand Up @@ -1117,7 +1122,7 @@ def vol():
#M("Course Certificates", f="course_certificate"),
),
M("Certificate Catalog", f="certificate",
check=manager_mode)(
check=(manager_mode, certificates))(
M("Create", m="create"),
#M("Skill Equivalence", f="certificate_skill"),
),
Expand Down Expand Up @@ -1460,7 +1465,11 @@ def org():
M("Map", m="map"),
M("Import", m="import")
),
M("Facilities", f="facility", m="summary")(
M("Facilities", f="facility")(
M("Create", m="create"),
M("Import", m="import"),
),
M("Resource Inventory", f="resource")(
M("Create", m="create"),
M("Import", m="import")
),
Expand Down
2 changes: 0 additions & 2 deletions modules/templates/IFRC/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2419,8 +2419,6 @@ def custom_prep(r):
filter_widgets = resource.get_config("filter_widgets")
# Remove type (always 'RC')
filter_widgets.pop(1)
# Remove sector (not relevant)
filter_widgets.pop(1)

# Modify CRUD Strings
s3.crud_strings.org_organisation = Storage(
Expand Down
2 changes: 2 additions & 0 deletions modules/templates/default/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ def config(settings):
# Organisations
# Uncomment to use an Autocomplete for Organisation lookup fields
#settings.org.autocomplete = True
# Enable the Organisation Sector field
#settings.org.sector = True
# Enable the use of Organisation Branches
#settings.org.branches = True
# Show branches as tree rather than as table
Expand Down

0 comments on commit 41e18bb

Please sign in to comment.