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

NMRL-301 Removing Html from ARReport #101

Merged
merged 4 commits into from
May 30, 2017
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
1 change: 0 additions & 1 deletion bika/lims/browser/analysisrequest/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ def publishFromHTML(self, aruid, results_html):
report.edit(
AnalysisRequest=ar.UID(),
Pdf=pdf_report,
Html=results_html,
Recipients=recipients
)
report.unmarkCreationFlag()
Expand Down
2 changes: 0 additions & 2 deletions bika/lims/content/arreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
),
BlobField('Pdf',
),
StringField('Html',
),
StringField('SMS',
),
RecordsField('Recipients',
Expand Down
22 changes: 22 additions & 0 deletions bika/lims/upgrade/v3_2_0_1705.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,34 @@ def upgrade(tool):
if CATALOG_ANALYSIS_REQUEST_LISTING not in ut.refreshcatalog:
ut.refreshcatalog.append(CATALOG_ANALYSIS_REQUEST_LISTING)

# Deleting 'Html' field from ARReport objects.
removeHtmlFromAR(portal)

# Refresh affected catalogs
ut.refreshCatalogs()

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


def removeHtmlFromAR(portal):
"""
'Html' StringField has been deleted from ARReport Schema.
Now removing this attribute from old objects to save some memory.
"""
uc = getToolByName(portal, 'uid_catalog')
ar_reps = uc(portal_type='ARReport')
f_name = 'Html'
counter = 0
for ar in ar_reps:
obj = ar.getObject()
if hasattr(obj, f_name):
delattr(obj, f_name)
counter += 1

logger.info("'Html' attribute has been removed from %d ARReport objects."
% counter)

def migareteFileFields(portal):
"""
This function walks over all attachment types and migrates their FileField
Expand All @@ -99,3 +120,4 @@ def migareteFileFields(portal):
logger.info(
"Finished migration of FileField fields from {}."
.format(portal_type))