Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nursix/eden-asp
Browse files Browse the repository at this point in the history
  • Loading branch information
nursix committed Nov 14, 2024
2 parents 3b5851c + 34fb428 commit d752827
Show file tree
Hide file tree
Showing 24 changed files with 784 additions and 232 deletions.
7 changes: 7 additions & 0 deletions controllers/supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def prep(r):

return crud_controller(rheader=s3db.supply_distribution_rheader)

# -----------------------------------------------------------------------------
def distribution():
""" Distributions: CRUD Controller """

Expand All @@ -181,4 +182,10 @@ def prep(r):

return crud_controller(rheader=s3db.supply_distribution_rheader)

# -----------------------------------------------------------------------------
def distribution_item():
""" Distribution Items: CRUD Controller """

return crud_controller(rheader=s3db.supply_distribution_rheader)

# END =========================================================================
5 changes: 5 additions & 0 deletions languages/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,7 @@
'Currently no Skill Equivalences registered': 'Derzeit sind keine Fähigkeits-Vergleichbarkeiten registriert',
'Currently no Trainings registered': 'Derzeit keine Schulungen registriert',
'Currently no entries in the catalog': 'Derzeit keine Einträge im Katalog',
'Currently no items to process for this beneficiary': 'Zurzeit keine Artikel für diesen Empfänger zu bearbeiten',
'Cushitic languages': 'Kuschitische Sprachen',
'Customer number, file reference or other reference number': 'Kunden-Nr., Aktenzeichen oder anderes GeschZ',
'Customs Capacity': 'Zollkapazität',
Expand Down Expand Up @@ -1954,6 +1955,8 @@
'Distance between defecation area and water source': 'Distanz zwischen Sanitärbereich und Wasserquelle',
'Distance from %s:': 'Abstand von %s:',
'Distance(Kms)': 'Distanz (km)',
'Distributed Item': 'Ausgeteilter Artikel',
'Distributed Items': 'Ausgeteilte Artikel',
'Distributed without Record': 'Verteilt ohne Aufzeichnung',
'Distribution Center': 'Verteilungszentrum',
'Distribution Item Set added': 'Ausgabeartikelsatz hinzugefügt',
Expand Down Expand Up @@ -2721,6 +2724,7 @@
'Government': 'Regierung',
'Grade': 'Klasse',
'Grant##distribution': 'Zuwendung',
'Grants Total##supplies': 'Zuwendungen gesamt',
'Greece': 'Griechenland',
'Greek': 'Griechisch',
'Green': 'Grün',
Expand Down Expand Up @@ -3459,6 +3463,7 @@
'List Depositories': 'Verwahrungsorte auflisten',
'List Diagnoses': 'Liste Diagnosen',
'List Direct Offers': 'Liste Direktangebote',
'List Distributed Items': 'Liste Ausgeteilte Artikel',
'List Distribution Item Sets': 'Liste Ausgabeartikelsätze',
'List Distributions': 'Liste Austeilungen',
'List Documents': 'Liste Dokumente',
Expand Down
3 changes: 2 additions & 1 deletion modules/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ def search_id(self):
if not search_id:
array = [self.controller, self.function]
if self.args:
array.extend(self.args)
# Drop format extensions from args
array.extend(arg.rsplit(".", 1)[0] for arg in self.args)

string = "#".join(array)
import hashlib
Expand Down
4 changes: 4 additions & 0 deletions modules/core/methods/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,12 @@ def registration_form(self, r, **attr):

# Show profile picture by default or only on demand?
show_picture = settings.get_ui_checkpoint_show_picture()
multi_preselect_all = settings.get_ui_checkpoint_multi_preselect_all()

# Inject JS
options = {"tablename": resourcename,
"ajaxURL": self.ajax_url(r),
"multiPreselectAll": multi_preselect_all,
"showPicture": show_picture,
"showPictureText": s3_str(T("Show Picture")),
"hidePictureText": s3_str(T("Hide Picture")),
Expand Down Expand Up @@ -1045,6 +1047,8 @@ def get_family_members(self, person_id, organisation_id):
"n": s3_fullname(member),
"d": S3DateTime.date_represent(member.date_of_birth),
}
if str(member.id) == str(person_id):
data["s"] = True

# Profile picture URL
picture = row.pr_image
Expand Down
3 changes: 2 additions & 1 deletion modules/core/methods/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def registration_form(self, r, **attr):
"hidePictureLabel": s3_str(T("Hide Picture")),
"selectDistributionSetLabel": s3_str(T("Please select a distribution item set")),
"noDistributionSetsLabel": s3_str(T("No distribution item sets available")),
"noItemsLabel": s3_str(T("Currently no items to process for this beneficiary")),
"distributeLabel": s3_str(T("Distribution")),
"returnLabel": s3_str(T("Return##distribution")),
"itemLabel": s3_str(T("Item")),
Expand Down Expand Up @@ -881,7 +882,7 @@ def get_items(cls, person_id, distribution_set, is_resident=None):
distribution_set,
is_resident = is_resident,
)
output["distribute"] = {"items": items, "msg": s3_str(msg)}
output["distribute"] = {"items": items, "msg": s3_str(msg) if msg else None}

# Look up returnable items
items = cls.get_returnable_items(person_id, distribution_set)
Expand Down
10 changes: 6 additions & 4 deletions modules/core/ui/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,16 +1471,18 @@ def render(self, r):
if not record_id and r.record:
record_id = r.record[r.table._id]

request = current.request
for i, tab in enumerate(tabs):

# Determine the query variables for the tab URL
vars_match = tab.vars_match(r)
# - applying original GET vars to prevent session filter creep
vars_match = tab.vars_match(request)
if vars_match:
_vars = Storage(r.get_vars)
_vars = Storage(request.get_vars)
else:
_vars = Storage(tab.vars)
if "viewing" in r.get_vars:
_vars.viewing = r.get_vars.viewing
if "viewing" in request.get_vars:
_vars.viewing = request.get_vars.viewing

# Determine the controller function for the tab URL
if tab.function is None:
Expand Down
8 changes: 8 additions & 0 deletions modules/s3cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,14 @@ def get_ui_checkpoint_show_picture(self):
"""
return self.ui.get("checkpoint_show_picture", True)

def get_ui_checkpoint_multi_preselect_all(self):
"""
Checkpoint-type UI to pre-select all eligible case group members
for multiple-registration (otherwise, only the present client
would be pre-selected)
"""
return self.ui.get("checkpoint_multi_preselect_all", True)

# =========================================================================
# Messaging
#
Expand Down
39 changes: 39 additions & 0 deletions modules/s3db/supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,45 @@ def supply_distribution_rheader(r, tabs=None):
["date"],
]

elif tablename == "supply_distribution_item":

if not tabs:
tabs = [(T("Item Details"), None),
]

# Show distribution details in header
dist = resource.select(["distribution_id$person_id",
"distribution_id$organisation_id",
"distribution_id$site_id",
"distribution_id$distribution_set_id",
"distribution_id$date",
"distribution_id$human_resource_id",
],
represent = True,
raw_data = True,
).rows
if dist:
dist = dist[0]
#raw = dist._row

beneficiary = lambda row: dist["supply_distribution.person_id"]
organisation = lambda row: dist["supply_distribution.organisation_id"]
site = lambda row: dist["supply_distribution.site_id"]
staff = lambda row: dist["supply_distribution.human_resource_id"]
date = lambda row: dist["supply_distribution.date"]

rheader_fields = [[(T("Beneficiary"), beneficiary),
(T("Organization"), organisation),
],
[(T("Place"), site),
(T("Staff Member in Charge"), staff),
],
[(T("Date"), date),
],
]
else:
return None

rheader = S3ResourceHeader(rheader_fields, tabs, title=rheader_title)
rheader = rheader(r, table=resource.table, record=record)

Expand Down
7 changes: 6 additions & 1 deletion modules/templates/MRCMS/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def config(settings):
settings.ui.auth_user_represent = "name"
settings.ui.datatables_responsive = False

# Do not pre-select family members for checkpoint registration
#settings.ui.checkpoint_multi_preselect_all = False

# -------------------------------------------------------------------------
# AUTH Settings
#
Expand Down Expand Up @@ -515,13 +518,15 @@ def counsel_home():
supply_distribution_resource, \
supply_distribution_controller, \
supply_distribution_item_resource, \
supply_item_resource
supply_item_resource, \
supply_item_controller

settings.customise_supply_distribution_set_controller = supply_distribution_set_controller
settings.customise_supply_distribution_resource = supply_distribution_resource
settings.customise_supply_distribution_controller = supply_distribution_controller
settings.customise_supply_distribution_item_resource = supply_distribution_item_resource
settings.customise_supply_item_resource = supply_item_resource
settings.customise_supply_item_controller = supply_item_controller

# -------------------------------------------------------------------------
# Security settings
Expand Down
41 changes: 22 additions & 19 deletions modules/templates/MRCMS/customise/dvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ def dvr_case_event_resource(r, tablename):
# -------------------------------------------------------------------------
def dvr_case_event_controller(**attr):

auth = current.auth
s3 = current.response.s3

# Custom postp
Expand All @@ -934,7 +935,13 @@ def custom_postp(r, output):
if callable(standard_postp):
output = standard_postp(r, output)

if r.method in ("register", "register_food", "register_activity"):
if r.interactive and \
r.method in ("register", "register_food", "register_activity"):
if isinstance(output, dict):
if auth.permission.has_permission("read", c="dvr", f="person"):
output["return_url"] = URL(c="dvr", f="person")
else:
output["return_url"] = URL(c="default", f="index")
CustomController._view("MRCMS", "register_case_event.html")
return output
s3.postp = custom_postp
Expand Down Expand Up @@ -1312,8 +1319,10 @@ def dvr_person_prep(r):

# =============================================================================
def dvr_group_membership_prep(r):
# TODO docstring
# TODO integrate in pr_group_membership_controller?
"""
Custom copy of dvr/group_membership prep(), so it can be called
in proxy controllers too (e.g. counsel/group_membership)
"""

db = current.db
s3db = current.s3db
Expand All @@ -1327,20 +1336,15 @@ def dvr_group_membership_prep(r):
settings.pr.request_home_phone = False
settings.hrm.email_required = False

get_vars = r.get_vars
if "viewing" in get_vars:

try:
vtablename, record_id = get_vars["viewing"].split(".")
except ValueError:
return False

if vtablename == "pr_person":
viewing = r.viewing
if viewing:
if viewing[0] == "pr_person":
person_id = viewing[1]

# Get all group_ids with this person_id
gtable = s3db.pr_group
join = gtable.on(gtable.id == table.group_id)
query = (table.person_id == record_id) & \
query = (table.person_id == person_id) & \
(gtable.group_type == 7) & \
(table.deleted != True)
rows = db(query).select(table.group_id, join=join)
Expand All @@ -1351,16 +1355,15 @@ def dvr_group_membership_prep(r):
# Single group ID?
group_id = tuple(group_ids)[0] if len(group_ids) == 1 else None
elif r.http == "POST":
name = s3_fullname(record_id)
name = s3_fullname(person_id)
group_id = gtable.insert(name=name, group_type=7)
s3db.update_super(gtable, {"id": group_id})
table.insert(group_id = group_id,
person_id = record_id,
group_head = True,
)
person_id = person_id,
group_head = True,
)
group_ids = {group_id}
resource.add_filter(FS("person_id") != record_id)

resource.add_filter(FS("person_id") != person_id)
else:
group_ids = set()

Expand Down
1 change: 1 addition & 0 deletions modules/templates/MRCMS/customise/pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ def postp(r, output):

# Activate filters on component tabs
attr["hide_filter"] = {"response_action": False,
"distribution_item": False,
}

return attr
Expand Down
Loading

0 comments on commit d752827

Please sign in to comment.