Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Fix sporadical errors when contacts do not have a valid email address #172

Merged
merged 2 commits into from
Feb 17, 2020
Merged
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ Changelog

**Removed**

- #170 Removal of stale javascripts and css

**Fixed**

- #172 Fix sporadical errors when contacts do not have a valid email address
- #168 Cannot create Patient inside Client (content type not allowed)
- #162 Unable to search by Client Patient ID in Sample Add form
- #159 Ensure `Client` contents allow to hold `Patient` types
Expand Down
23 changes: 21 additions & 2 deletions bika/health/upgrade/v01_02_003.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# Copyright 2018-2019 by it's authors.
# Some rights reserved, see README and LICENSE.

from bika.health import CATALOG_PATIENTS
from bika.health import api
from bika.health import DEFAULT_PROFILE_ID
from bika.health import logger
Expand All @@ -27,6 +27,7 @@
from bika.lims.catalog import CATALOG_ANALYSIS_REQUEST_LISTING
from bika.lims.upgrade import upgradestep
from bika.lims.upgrade.utils import UpgradeUtils
from bika.lims.upgrade.v01_03_003 import fix_email_address

version = '1.2.3'
profile = 'profile-{0}:default'.format(PROJECTNAME)
Expand Down Expand Up @@ -93,6 +94,10 @@ def upgrade(tool):
# Remove stale css
remove_stale_css(portal)

# Fix email addresses
# https://github.com/senaite/senaite.health/pulls/172
fix_health_email_addresses(portal)

logger.info("{0} upgraded to version {1}".format(PROJECTNAME, version))
return True

Expand Down Expand Up @@ -138,6 +143,20 @@ def remove_stale_css(portal):
portal.portal_css.unregisterResource(css)


def fix_health_email_addresses(portal):
"""Validates the email address for portal types that inherit from Person.
The field did not have an email validator, causing some views to fail when
rendering the value while expecting a valid email address format
"""
# Fix email address for portal types from portal_catalog
portal_types = ["VaccinationCenterContact", "Doctor"]
fix_email_address(portal, portal_types=portal_types)

# Fix email address for portal types from other catalogs
portal_types = ["Patient"]
fix_email_address(portal, portal_types=portal_types,
catalog_id=CATALOG_PATIENTS)

def install_senaite_panic(portal):
"""Install the senaite.panic addon
"""
Expand All @@ -150,4 +169,4 @@ def install_senaite_panic(portal):
if qi.isProductInstalled(profile):
logger.info("'{}' is installed".format(profile))
return
qi.installProduct(profile)
qi.installProduct(profile)