Skip to content

Commit

Permalink
RLPPTM: small tweaks and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nursix committed Oct 24, 2022
1 parent dd6bed4 commit 8b4faaa
Show file tree
Hide file tree
Showing 12 changed files with 352 additions and 272 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nursix-dev-5513-g97844f1f6 (2022-10-24 13:14:09)
nursix-dev-5514-gdd6bed45d (2022-10-24 23:17:37)
11 changes: 1 addition & 10 deletions modules/templates/RLPPTM/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,16 +686,6 @@ def __call__(self):
set_record_owner(dtable, details, owned_by_user=user_id)
s3db_onaccept(dtable, details, method="create")

# Link facility to facility type
fttable = s3db.org_facility_type
tltable = s3db.org_site_facility_type
facility_type = db(fttable.name == "Infection Test Station") \
.select(fttable.id, limitby=(0, 1)).first()
if facility_type:
tltable.insert(site_id = site_id,
facility_type_id = facility_type.id,
)

# Link facility to services
if service_ids:
sltable = s3db.org_service_site
Expand All @@ -711,6 +701,7 @@ def __call__(self):
# - see facility_postprocess
from .models.org import TestStation
ts = TestStation(site_id)
ts.set_facility_type()
ts.add_facility_code()
ts.update_approval()

Expand Down
73 changes: 35 additions & 38 deletions modules/templates/RLPPTM/customise/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,18 @@ def prep(r):
S3SQLInlineLink, \
OptionsFilter, \
TextFilter
from ..config import TESTSTATIONS
from ..helpers import is_org_group

# Custom form
if is_org_group_admin:

is_test_station = record and is_org_group(record.id, TESTSTATIONS)
if is_test_station:
acronym = logo = None # irrelevant for test stations
else:
acronym, logo = "acronym", "logo"

if is_org_group_admin:
# Show organisation type(s) and verification tag as required
types = S3SQLInlineLink("organisation_type",
field = "organisation_type_id",
Expand All @@ -255,10 +263,7 @@ def prep(r):
multiple = settings.get_org_organisation_types_multiple(),
widget = "multiselect",
)
from ..config import TESTSTATIONS
from ..helpers import is_org_group
if record and is_org_group(record.id, TESTSTATIONS) and \
TestProvider(record.id).verifreq:
if is_test_station and TestProvider(record.id).verifreq:
TestProvider.configure_verification(r.resource,
role = "approver",
record_id = record.id,
Expand Down Expand Up @@ -295,14 +300,21 @@ def prep(r):
# Show delivery-tag
delivery = "delivery.value"
else:
# Test provider cannot change the name of their organisation
if is_test_station:
table = resource.table
field = table.name
field.writable = False

# Administrative fields not visible
groups = projects = delivery = types = type_check = None

crud_fields = [groups,
"name",
"acronym",
crud_fields = ["name",
acronym,
groups,
types,
projects,
type_check,
projects,
delivery,
S3SQLInlineComponent(
"contact",
Expand All @@ -316,7 +328,7 @@ def prep(r):
),
"phone",
"website",
"logo",
logo,
"comments",
]

Expand Down Expand Up @@ -566,9 +578,14 @@ def facility_create_onaccept(form):
if not record_id:
return

# Generate facility ID
ts = TestStation(facility_id=record_id)

# Set default facility type
ts.set_facility_type()

# Generate facility ID
ts.add_facility_code()

if current.response.s3.bulk:
# Postprocess not called during imports
# => call approval update manually
Expand Down Expand Up @@ -705,13 +722,13 @@ def configure_facility_form(r, is_org_group_admin=False):
# -- Facility
"name",
"code",
S3SQLInlineLink(
"facility_type",
label = T("Facility Type"),
field = "facility_type_id",
widget = "groupedopts",
cols = 3,
),
#S3SQLInlineLink(
# "facility_type",
# label = T("Facility Type"),
# field = "facility_type_id",
# widget = "groupedopts",
# cols = 3,
# ),
# -- Address
"location_id",
# -- Service Offer
Expand Down Expand Up @@ -814,7 +831,6 @@ def org_facility_resource(r, tablename):
S3LocationSelector,
OptionsFilter,
TextFilter,
s3_text_represent,
)

table = s3db.org_facility
Expand Down Expand Up @@ -901,25 +917,6 @@ def org_facility_resource(r, tablename):
if isinstance(requires, IS_EMPTY_OR):
field.requires = requires.other

field = dtable.authorisation_advice
field.label = T("Advice")
css = "approve-workflow"
field.represent = lambda v, row=None: \
s3_text_represent(v,
truncate = False,
_class = ("%s workflow-advice" % css) if v else css,
)
field.readable = True
if is_org_group_admin:
field.comment = DIV(_class="tooltip",
_title="%s|%s" % (T("Advice"),
T("Instructions/advice for the test station how to proceed with regard to authorization"),
),
)
field.writable = True
else:
field.writable = False

# Special views
get_vars = r.get_vars
if is_org_group_admin and not in_org_controller:
Expand Down
57 changes: 46 additions & 11 deletions modules/templates/RLPPTM/models/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def model(self):
configure = self.configure

crud_strings = current.response.s3.crud_strings
css = "approval-workflow"

# ---------------------------------------------------------------------
# Current approval details
Expand Down Expand Up @@ -491,12 +492,11 @@ def model(self):
),
Field("advice", "text",
label = T("Advice"),
comment = DIV(_class="tooltip",
_title="%s|%s" % (T("Advice"),
T("Instructions/advice for the test station how to proceed with regard to authorization"),
),
),
represent = s3_text_represent,
represent = lambda v, row=None: \
s3_text_represent(v,
truncate = False,
_class = ("%s workflow-advice" % css) if v else css,
),
widget = s3_comments_widget,
readable = False,
writable = False,
Expand Down Expand Up @@ -1756,6 +1756,33 @@ def add_approval_defaults(self):

return self._approval

# -------------------------------------------------------------------------
def set_facility_type(self):
"""
Link this test station to the default facility type, if it
does not have a type yet
"""

site_id = self.site_id

db = current.db
s3db = current.s3db

fttable = s3db.org_facility_type
tltable = s3db.org_site_facility_type

query = (tltable.site_id == site_id) & \
(tltable.deleted == False)
if not db(query).select(tltable.id, limitby=(0, 1)).first():
query = (fttable.name == "Infection Test Station") & \
(fttable.deleted == False)
facility_type = db(query).select(fttable.id, limitby=(0, 1)).first()
if facility_type:
tltable.insert(site_id = site_id,
facility_type_id = facility_type.id,
)


# -------------------------------------------------------------------------
def add_facility_code(self):
"""
Expand Down Expand Up @@ -2305,11 +2332,11 @@ def configure_site_approval(resource, role="applicant", record_id=None):
review_tags_visible = True

# Once the site has applied for approval, prevent further changes
# to the address (must be done by administrator after considering
# to certain details (must be done by administrator after considering
# the reasons for the change)
if applied_before:
field = ftable.location_id
field.writable = False
for fn in ("name", "location_id"):
ftable[fn].writable = False

is_approver = role == "approver"

Expand Down Expand Up @@ -2342,8 +2369,16 @@ def configure_site_approval(resource, role="applicant", record_id=None):

# Configure advice
field = ctable.advice
field.readable = is_approver or row and row.public != "Y"
field.writable = is_approver
if is_approver:
T = current.T
field.readable = field.writable = True
field.comment = DIV(_class="tooltip",
_title="%s|%s" % (T("Advice"),
T("Instructions/advice for the test station how to proceed with regard to authorization"),
),
)
elif row and row.public != "Y":
field.readable = True

visible_tags.extend(["approval.public",
"approval.public_reason",
Expand Down
2 changes: 1 addition & 1 deletion static/themes/DRK/eden.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 8b4faaa

Please sign in to comment.