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

Publish verified partitions #1428

Merged
merged 10 commits into from
Sep 12, 2019
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog

**Changed**

- #1428 Publish verified partitions
- #1429 Add2: Do not set template values on already filled fields
- #1427 Improved performance of Sample header table rendering
- #1417 Cache allowed transitions for analyses on the request
Expand Down
24 changes: 10 additions & 14 deletions bika/lims/browser/publish/emailview.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,16 @@ def write_sendlog(self):
def publish_samples(self):
"""Publish all samples of the reports
"""
reports = self.reports
for report in reports:
# publish the primary sample
primary_sample = report.getAnalysisRequest()
self.publish(primary_sample)
# publish the contained samples
contained_samples = report.getContainedAnalysisRequests()
for sample in contained_samples:
# skip the primary sample
if sample == primary_sample:
continue
self.publish(sample)
samples = set()

# collect primary + contained samples of the reports
for report in self.reports:
samples.add(report.getAnalysisRequest())
samples.update(report.getContainedAnalysisRequests())

# publish all samples + their partitions
for sample in samples:
self.publish(sample)

def publish(self, sample):
"""Set status to prepublished/published/republished
Expand All @@ -460,10 +458,8 @@ def publish(self, sample):
wf.doActionFor(sample, transition)
# Commit the changes
transaction.commit()
return True
except WorkflowException as e:
logger.error(e)
return False

def render_email_template(self, template):
"""Return the rendered email template
Expand Down
22 changes: 18 additions & 4 deletions bika/lims/workflow/analysisrequest/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
# Copyright 2018-2019 by it's authors.
# Some rights reserved, see README and LICENSE.

from DateTime import DateTime
from bika.lims import api
from bika.lims.interfaces import IAnalysisRequestPartition
from bika.lims.interfaces import IDetachedPartition
from bika.lims.interfaces import IReceived, IVerified, IAnalysisRequestPartition
from bika.lims.interfaces import IReceived
from bika.lims.interfaces import IVerified
from bika.lims.utils import changeWorkflowState
from bika.lims.utils.analysisrequest import create_retest
from bika.lims.workflow import get_prev_status_from_history
from bika.lims.workflow.analysisrequest import AR_WORKFLOW_ID, \
do_action_to_descendants, do_action_to_analyses, do_action_to_ancestors
from bika.lims.workflow.analysisrequest import AR_WORKFLOW_ID
from bika.lims.workflow.analysisrequest import do_action_to_analyses
from bika.lims.workflow.analysisrequest import do_action_to_ancestors
from bika.lims.workflow.analysisrequest import do_action_to_descendants
from DateTime import DateTime
from zope.interface import alsoProvides
from zope.interface import noLongerProvides

Expand Down Expand Up @@ -93,6 +97,16 @@ def after_verify(analysis_request):
do_action_to_descendants(analysis_request, "verify")


def after_prepublish(analysis_request):
"""Method triggered after a 'prepublish' transition for the Analysis
Request passed in is performed. Performs the 'publish' transition to the
descendant partitions.

Also see: https://github.com/senaite/senaite.core/pull/1428
"""
do_action_to_descendants(analysis_request, "publish")


def after_publish(analysis_request):
"""Method triggered after an 'publish' transition for the Analysis Request
passed in is performed. Performs the 'publish' transition Publishes the
Expand Down