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

PR 2266 BikaListing. Instrument calibration table fixes #282

Merged
merged 5 commits into from
Oct 24, 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
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changelog
1.1.0 (Unreleased)
------------------

**Added**
**Merged PRs from upstream**
#282 Instrument Calibration Table fixes (pr #2266, Issues #2263 & #2264)

**Changed**

Issue-1999: Allow external Python library functions to be used in Calculation Formulas
LIMS-1504: Calculation formula test widgets
Expand Down
86 changes: 25 additions & 61 deletions bika/lims/browser/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,29 @@
# Copyright 2011-2016 by it's authors.
# Some rights reserved. See LICENSE.txt, AUTHORS.txt.

import json
from operator import itemgetter

import plone
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from bika.lims import bikaMessageFactory as _
from bika.lims.utils import t
from bika.lims.browser import BrowserView
from bika.lims.browser.analyses import AnalysesView
from bika.lims.browser.bika_listing import BikaListingView
from bika.lims.browser.multifile import MultifileView
from bika.lims.browser.resultsimport.autoimportlogs import AutoImportLogsView
from bika.lims.content.instrumentmaintenancetask import InstrumentMaintenanceTaskStatuses as mstatus
from bika.lims.subscribers import doActionFor, skip
from operator import itemgetter
from bika.lims.config import QCANALYSIS_TYPES
from bika.lims.content.instrumentmaintenancetask import \
InstrumentMaintenanceTaskStatuses as mstatus
from bika.lims.utils import t
from plone.app.content.browser.interfaces import IFolderContentsView
from plone.app.layout.globals.interfaces import IViewView
from plone.app.layout.viewlets import ViewletBase
from zope.interface import implements
from bika.lims.browser.bika_listing import BikaListingView
from bika.lims.config import QCANALYSIS_TYPES
from bika.lims.utils import to_utf8
from bika.lims.permissions import *
from operator import itemgetter
from bika.lims.browser import BrowserView
from bika.lims.browser.analyses import AnalysesView
from bika.lims.browser.multifile import MultifileView
from bika.lims.browser.analyses import QCAnalysesView
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zExceptions import Forbidden
from operator import itemgetter
from bika.lims.catalog import CATALOG_AUTOIMPORTLOGS_LISTING
from zope.interface import implements

import plone
import json

class InstrumentMaintenanceView(BikaListingView):
implements(IFolderContentsView, IViewView)
Expand Down Expand Up @@ -501,34 +494,6 @@ def get_analyses_json(self):
return json.dumps(self.anjson)


class InstrumentCertificationsViewView(BrowserView):
""" View of Instrument Certifications
Shows the list of Instrument Certifications, either Internal and
External Calibrations.
"""

implements(IViewView)
template = ViewPageTemplateFile("templates/instrument_certifications.pt")
_certificationsview = None

def __call__(self):
return self.template()

def get_certifications_table(self):
""" Returns the table of Certifications
"""
return self.get_certifications_view().contents_table()

def get_certifications_view(self):
""" Returns the Certifications Table view
"""
if not self._certificationsview:
self._certificationsview = InstrumentCertificationsView(
self.context,
self.request)
return self._certificationsview


class InstrumentCertificationsView(BikaListingView):
""" View for the table of Certifications. Includes Internal and
External Calibrations. Also a bar to filter the results
Expand All @@ -538,39 +503,38 @@ def __init__(self, context, request, **kwargs):
BikaListingView.__init__(self, context, request, **kwargs)
self.form_id = "instrumentcertifications"
self.columns = {
'Title': {'title': _('Cert. Num'),
'index': 'sortable_title'},
'getAgency': {'title': _('Agency')},
'getDate': {'title': _('Date')},
'getValidFrom': {'title': _('Valid from')},
'getValidTo': {'title': _('Valid to')},
'getDocument': {'title': _('Document')},
'Title': {'title': _('Cert. Num'), 'index': 'sortable_title'},
'getAgency': {'title': _('Agency'), 'sortable': False},
'getDate': {'title': _('Date'), 'sortable': False},
'getValidFrom': {'title': _('Valid from'), 'sortable': False},
'getValidTo': {'title': _('Valid to'), 'sortable': False},
'getDocument': {'title': _('Document'), 'sortable': False},
}
self.review_states = [
{'id':'default',
'title':_('All'),
'contentFilter':{},
'columns': [ 'Title',
'columns': ['Title',
'getAgency',
'getDate',
'getValidFrom',
'getValidTo',
'getDocument'],
'transitions': [{}]},
'transitions': []},
]
self.allow_edit = False
self.show_select_column = False
self.show_workflow_action_buttons = False
self.show_workflow_action_buttons = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afak, there are no specific transitions available for Certifications (or at least, shouldn't be). Why the need of displaying the workflow action buttons bar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, good catch @xispa . I had to add this to display the bottom button bar where the "Show more" button lives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, it was just a required trick

uids = [c.UID() for c in self.context.getCertifications()]
self.catalog = 'portal_catalog'
self.contentFilter = {'UID': uids, 'sort_on': 'sortable_title'}

def folderitems(self):
items = BikaListingView.folderitems(self)
valid = [c.UID() for c in self.context.getValidCertifications()]
valid = [c.UID() for c in self.context.getValidCertifications()]
latest = self.context.getLatestValidCertification()
latest = latest.UID() if latest else ''
for x in range (len(items)):
for x in range(len(items)):
if not items[x].has_key('obj'): continue
obj = items[x]['obj']
# items[x]['getAgency'] = obj.getAgency()
Expand Down
2 changes: 1 addition & 1 deletion bika/lims/browser/instrument.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<browser:page
for="bika.lims.interfaces.IInstrument"
name="certifications"
class="bika.lims.browser.instrument.InstrumentCertificationsViewView"
class="bika.lims.browser.instrument.InstrumentCertificationsView"
permission="zope.Public"
layer="bika.lims.interfaces.IBikaLIMS"
/>
Expand Down
9 changes: 4 additions & 5 deletions bika/lims/browser/templates/instrument_certifications.pt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@
</metal:content-description>

<metal:content-core fill-slot="content-core">
<!-- Certifications table -->
<tal:certificatestable>
<tal:parts replace="structure view/get_certifications_table"/>
</tal:certificatestable>

<!-- Certifications table -->
<tal:certificatestable>
<tal:parts replace="structure view/contents_table"/>
</tal:certificatestable>
</metal:content-core>
</body>
</html>