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

NDEV-41 After verification, department managers are not updated in results report anymore #187

Merged
merged 2 commits into from
Jul 25, 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
23 changes: 19 additions & 4 deletions bika/lims/browser/analysisrequest/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,18 +720,33 @@ def __call__(self, ar, overwrite=False):
# if AR was previously digested, use existing data (if exists)
if not overwrite:
# Prevent any error related with digest
data = ar.getDigest() if hasattr(ar, 'getDigest') else ''
data = ar.getDigest() if hasattr(ar, 'getDigest') else {}
if data:
# Seems that sometimes the 'obj' is wrong in the saved data.
data['obj'] = ar
return data
# Check if the department managers have changed since
# verification:
saved_managers = data.get('managers', {})
saved_managers_ids = set(saved_managers.get('ids', []))
current_managers = self.context.getManagers()
current_managers_ids = set([man.getId() for man in
current_managers])
# The symmetric difference of two sets A and B is the set of
# elements which are in either of the sets A or B but not
# in both.
are_different = saved_managers_ids.symmetric_difference(
current_managers_ids)
if len(are_different) == 0:
# Seems that sometimes the 'obj' is wrong in the saved
# data.
data['obj'] = ar
return data

logger.info("=========== creating new data for %s" % ar)

# Set data to the AR schema field, and return it.
data = self._ar_data(ar)
if hasattr(ar, 'setDigest'):
ar.setDigest(data)
logger.info("=========== new data for %s created." % ar)
return data

def _schema_dict(self, instance, skip_fields=None, recurse=True):
Expand Down
5 changes: 2 additions & 3 deletions bika/lims/content/analysisrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,6 @@ def getDefaultMemberDiscount(self):
else:
return "0.00"

security.declareProtected(View, 'getResponsible')

def _getAnalysesNum(self):
""" Return the amount of analyses verified/total in the current AR """
Expand All @@ -1852,6 +1851,7 @@ def _getAnalysesNum(self):
total += 1
return verified,total

@security.public
def getResponsible(self):
""" Return all manager info of responsible departments """
managers = {}
Expand Down Expand Up @@ -1888,8 +1888,7 @@ def getResponsible(self):

return mngr_info

security.declareProtected(View, 'getResponsible')

@security.public
def getManagers(self):
""" Return all managers of responsible departments """
manager_ids = []
Expand Down