本文整理汇总了Python中bika.lims.browser.reports.selection_macros.SelectionMacrosView.parse_state方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionMacrosView.parse_state方法的具体用法?Python SelectionMacrosView.parse_state怎么用?Python SelectionMacrosView.parse_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bika.lims.browser.reports.selection_macros.SelectionMacrosView
的用法示例。
在下文中一共展示了SelectionMacrosView.parse_state方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Report
# 需要导入模块: from bika.lims.browser.reports.selection_macros import SelectionMacrosView [as 别名]
# 或者: from bika.lims.browser.reports.selection_macros.SelectionMacrosView import parse_state [as 别名]
class Report(BrowserView):
implements(IViewView)
template = ViewPageTemplateFile(
"templates/qualitycontrol_resultspersamplepoint.pt")
# if unsuccessful we return here:
default_template = ViewPageTemplateFile("templates/qualitycontrol.pt")
def __init__(self, context, request, report=None):
super(Report, self).__init__(context, request)
self.report = report
self.selection_macros = SelectionMacrosView(self.context, self.request)
def get_analysis_spec(self, analysis):
rr = dicts_to_dict(analysis.aq_parent.getResultsRange(), 'keyword')
return rr.get(analysis.getKeyword(), None)
def ResultOutOfRange(self, analysis):
"""Template wants to know, is this analysis out of range? We scan
IResultOutOfRange adapters, and return True if any IAnalysis adapters
trigger a result. """
adapters = getAdapters((analysis, ), IResultOutOfRange)
spec = self.get_analysis_spec(analysis)
for name, adapter in adapters:
if not spec:
return False
if adapter(specification=spec):
return True
def __call__(self):
MinimumResults = self.context.bika_setup.getMinimumResults()
warning_icon = "<img " + \
"src='" + self.portal_url + "/++resource++bika.lims.images/warning.png' " + \
"height='9' width='9'/>"
error_icon = "<img " + \
"src='" + self.portal_url + "/++resource++bika.lims.images/exclamation.png' " + \
"height='9' width='9'/>"
header = _("Results per sample point")
subheader = _(
"Analysis results for per sample point and analysis service")
self.contentFilter = {'portal_type': 'Analysis',
'review_state': ['verified', 'published']}
parms = []
titles = []
val = self.selection_macros.parse_client(self.request)
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
val = self.selection_macros.parse_samplepoint(self.request)
sp_uid = val
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
val = self.selection_macros.parse_sampletype(self.request)
st_uid = val
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
val = self.selection_macros.parse_analysisservice(self.request)
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
else:
message = _("No analysis services were selected.")
self.context.plone_utils.addPortalMessage(message, 'error')
return self.default_template()
val = self.selection_macros.parse_daterange(self.request,
'getDateSampled',
'DateSampled')
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
val = self.selection_macros.parse_state(self.request,
'bika_worksheetanalysis_workflow',
'worksheetanalysis_review_state',
'Worksheet state')
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
# Query the catalog and store analysis data in a dict
analyses = {}
out_of_range_count = 0
in_shoulder_range_count = 0
analysis_count = 0
proxies = self.bika_analysis_catalog(self.contentFilter)
#.........这里部分代码省略.........
示例2: Report
# 需要导入模块: from bika.lims.browser.reports.selection_macros import SelectionMacrosView [as 别名]
# 或者: from bika.lims.browser.reports.selection_macros.SelectionMacrosView import parse_state [as 别名]
class Report(BrowserView):
implements(IViewView)
template = ViewPageTemplateFile("templates/qualitycontrol_resultspersamplepoint.pt")
# if unsuccessful we return here:
default_template = ViewPageTemplateFile("templates/qualitycontrol.pt")
def __init__(self, context, request, report=None):
super(Report, self).__init__(context, request)
self.report = report
self.selection_macros = SelectionMacrosView(self.context, self.request)
def __call__(self):
MinimumResults = self.context.bika_setup.getMinimumResults()
warning_icon = (
"<img "
+ "src='"
+ self.portal_url
+ "/++resource++bika.lims.images/warning.png' "
+ "height='9' width='9'/>"
)
error_icon = (
"<img "
+ "src='"
+ self.portal_url
+ "/++resource++bika.lims.images/exclamation.png' "
+ "height='9' width='9'/>"
)
header = _("Results per sample point")
subheader = _("Analysis results for per sample point and analysis service")
self.contentFilter = {
"portal_type": "Analysis",
"review_state": ["verified", "published"],
"sort_on": "getDateSampled",
}
spec = self.request.form.get("spec", "lab")
spec_title = (spec == "lab") and _("Lab") or _("Client")
parms = []
titles = []
val = self.selection_macros.parse_client(self.request)
if val:
self.contentFilter[val["contentFilter"][0]] = val["contentFilter"][1]
parms.append(val["parms"])
titles.append(val["titles"])
val = self.selection_macros.parse_samplepoint(self.request)
sp_uid = val
if val:
self.contentFilter[val["contentFilter"][0]] = val["contentFilter"][1]
parms.append(val["parms"])
titles.append(val["titles"])
val = self.selection_macros.parse_sampletype(self.request)
st_uid = val
if val:
self.contentFilter[val["contentFilter"][0]] = val["contentFilter"][1]
parms.append(val["parms"])
titles.append(val["titles"])
val = self.selection_macros.parse_analysisservice(self.request)
if val:
self.contentFilter[val["contentFilter"][0]] = val["contentFilter"][1]
parms.append(val["parms"])
else:
message = _("No analysis services were selected.")
self.context.plone_utils.addPortalMessage(message, "error")
return self.default_template()
val = self.selection_macros.parse_daterange(self.request, "getDateSampled", "DateSampled")
if val:
self.contentFilter[val["contentFilter"][0]] = val["contentFilter"][1]
parms.append(val["parms"])
titles.append(val["titles"])
val = self.selection_macros.parse_state(
self.request, "bika_worksheetanalysis_workflow", "worksheetanalysis_review_state", "Worksheet state"
)
if val:
self.contentFilter[val["contentFilter"][0]] = val["contentFilter"][1]
parms.append(val["parms"])
# Query the catalog and store analysis data in a dict
analyses = {}
out_of_range_count = 0
in_shoulder_range_count = 0
analysis_count = 0
proxies = self.bika_analysis_catalog(self.contentFilter)
if not proxies:
message = _("No analyses matched your query")
self.context.plone_utils.addPortalMessage(message, "error")
return self.default_template()
cached_specs = {} # keyed by parent_folder
#.........这里部分代码省略.........
示例3: Report
# 需要导入模块: from bika.lims.browser.reports.selection_macros import SelectionMacrosView [as 别名]
# 或者: from bika.lims.browser.reports.selection_macros.SelectionMacrosView import parse_state [as 别名]
class Report(BrowserView):
implements(IViewView)
default_template = ViewPageTemplateFile("templates/productivity.pt")
template = ViewPageTemplateFile(
"templates/productivity_analysesperdepartment.pt")
def __init__(self, context, request, report=None):
super(Report, self).__init__(context, request)
self.report = report
self.selection_macros = SelectionMacrosView(self.context, self.request)
def __call__(self):
parms = []
titles = []
# Apply filters
self.contentFilter = {'portal_type': 'Analysis'}
val = self.selection_macros.parse_daterange(self.request,
'getDateRequested',
_('Date Requested'))
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
val = self.selection_macros.parse_state(self.request,
'bika_analysis_workflow',
'getAnalysisState',
_('Analysis State'))
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
# Query the catalog and store results in a dictionary
analyses = self.bika_analysis_catalog(self.contentFilter)
if not analyses:
message = _("No analyses matched your query")
self.context.plone_utils.addPortalMessage(message, "error")
return self.default_template()
groupby = self.request.form.get('GroupingPeriod', '')
if (groupby != ''):
parms.append({"title": _("Grouping period"), "value": _(groupby)})
datalines = {}
footlines = {}
totalcount = len(analyses)
totalpublishedcount = 0
totalperformedcount = 0
for analysis in analyses:
analysis = analysis.getObject()
analysisservice = analysis.getService()
department = analysisservice.getDepartment()
department = department.Title() if department else ''
daterequested = analysis.created()
group = ''
if groupby == 'Day':
group = self.ulocalized_time(daterequested)
elif groupby == 'Week':
group = daterequested.strftime(
"%Y") + ", " + daterequested.strftime("%U")
elif groupby == 'Month':
group = daterequested.strftime(
"%B") + " " + daterequested.strftime("%Y")
elif groupby == 'Year':
group = daterequested.strftime("%Y")
else:
group = ''
dataline = {'Group': group, 'Requested': 0, 'Performed': 0,
'Published': 0, 'Departments': {}}
deptline = {'Department': department, 'Requested': 0, 'Performed': 0,
'Published': 0}
if (group in datalines):
dataline = datalines[group]
if (department in dataline['Departments']):
deptline = dataline['Departments'][department]
grouptotalcount = dataline['Requested'] + 1
groupperformedcount = dataline['Performed']
grouppublishedcount = dataline['Published']
depttotalcount = deptline['Requested'] + 1
deptperformedcount = deptline['Performed']
deptpubishedcount = deptline['Published']
workflow = getToolByName(self.context, 'portal_workflow')
arstate = workflow.getInfoFor(analysis.aq_parent, 'review_state', '')
if (arstate == 'published'):
deptpubishedcount += 1
grouppublishedcount += 1
totalpublishedcount += 1
if (analysis.getResult()):
deptperformedcount += 1
groupperformedcount += 1
totalperformedcount += 1
#.........这里部分代码省略.........
示例4: Report
# 需要导入模块: from bika.lims.browser.reports.selection_macros import SelectionMacrosView [as 别名]
# 或者: from bika.lims.browser.reports.selection_macros.SelectionMacrosView import parse_state [as 别名]
class Report(BrowserView):
implements(IViewView)
default_template = ViewPageTemplateFile("templates/productivity.pt")
template = ViewPageTemplateFile("templates/productivity_analysesperdepartment.pt")
def __init__(self, context, request, report=None):
super(Report, self).__init__(context, request)
self.report = report
self.selection_macros = SelectionMacrosView(self.context, self.request)
def __call__(self):
parms = []
titles = []
# Apply filters
self.contentFilter = {'portal_type': 'Analysis'}
val = self.selection_macros.parse_daterange(self.request,
'getDateRequested',
_('Date Requested'))
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
val = self.selection_macros.parse_state(self.request,
'bika_analysis_workflow',
'getAnalysisState',
_('Analysis State'))
if val:
self.contentFilter[val['contentFilter'][0]] = val['contentFilter'][1]
parms.append(val['parms'])
titles.append(val['titles'])
# Query the catalog and store results in a dictionary
analyses = self.bika_analysis_catalog(self.contentFilter)
if not analyses:
message = _("No analyses matched your query")
self.context.plone_utils.addPortalMessage(message, "error")
return self.default_template()
groupby = self.request.form.get('GroupingPeriod', '')
if (groupby != ''):
parms.append({"title": _("Grouping period"), "value": _(groupby)})
datalines = {}
footlines = {}
totalcount = len(analyses)
totalpublishedcount = 0
totalperformedcount = 0
for analysis in analyses:
analysis = analysis.getObject()
analysisservice = analysis.getService()
department = analysisservice.getDepartment().Title()
daterequested = analysis.created()
group = ''
if groupby == 'Day':
group = self.ulocalized_time(daterequested)
elif groupby == 'Week':
group = daterequested.strftime("%Y") + ", " + daterequested.strftime("%U")
elif groupby == 'Month':
group = daterequested.strftime("%B") + " " + daterequested.strftime("%Y")
elif groupby == 'Year':
group = daterequested.strftime("%Y")
else :
group = ''
dataline = {'Group': group, 'Requested': 0, 'Performed': 0, 'Published': 0, 'Departments': {} }
deptline = {'Department':department, 'Requested':0, 'Performed': 0, 'Published': 0 }
if (group in datalines):
dataline = datalines[group]
if (department in dataline['Departments']):
deptline = dataline['Departments'][department]
grouptotalcount = dataline['Requested']+1
groupperformedcount = dataline['Performed']
grouppublishedcount = dataline['Published']
depttotalcount = deptline['Requested']+1
deptperformedcount = deptline['Performed']
deptpubishedcount = deptline['Published']
workflow = getToolByName(self.context, 'portal_workflow')
arstate = workflow.getInfoFor(analysis.aq_parent, 'review_state', '')
if (arstate == 'published'):
deptpubishedcount += 1
grouppublishedcount += 1
totalpublishedcount += 1
if (analysis.getResult()):
deptperformedcount += 1
groupperformedcount += 1
totalperformedcount += 1
group_performedrequested_ratio = float(groupperformedcount)/float(grouptotalcount)
group_publishedperformed_ratio = groupperformedcount > 0 and float(grouppublishedcount)/float(groupperformedcount) or 0
anl_performedrequested_ratio = float(deptperformedcount)/float(depttotalcount)
anl_publishedperformed_ratio = deptperformedcount > 0 and float(deptpubishedcount)/float(deptperformedcount) or 0
#.........这里部分代码省略.........