def _simple_report_topic(self,section=None, visit_id=None, primary=''):
status = []
report_buckets = {}
cvm = Cvm(visit_id=visit_id)
ns = cvm.get_cvm_namespace()
vmd = ns['vmd']
assoc_instances = vmd.assoc_instances
all_factoids = []
for ad in section['factoids']:
all_factoids.extend(self.get_factoids(ad))
for rt in self.report_topics:
factoids = [f for f in all_factoids if f.report_topic and \
f.report_topic.ad == rt['ad'] and \
f.ad not in self.global_seen_factoids]
# Figure out if we have data for this factoid.
prs = PatientResponse.objects.filter(
visit__id=visit_id,
confirmation__in=self.valid_states,
factoid__in=factoids,
feature__ad=section['feature'],
norm_value__gte=section['threshold'],
).order_by('-norm_value')
if not prs:
continue
fv_ad = prs[0].feature_value
# This flag controls when we show the title for this report topic.
suppress_label = False
render_data = []
if not suppress_label:
render_data.append(widgets.TopicTitleWidget(title=rt['text']))
suppress_label = True
for pr in prs:
self.global_seen_factoids.add(pr.factoid.ad)
# The result of the rendering will be a FactoidWidget.
result = self.render_factoid(factoid=pr.factoid, visit_id=visit_id, primary=primary)
if result:
render_data.append(result)
if report_buckets.get(fv_ad):
report_buckets[fv_ad].append(render_data)
else:
report_buckets[fv_ad] = [render_data]
report_buckets = report_buckets.items()
report_buckets.sort(lambda x,y: cmp(y[0], x[0]))
# Number the topics.
counter = 1
for key, value in report_buckets:
for each_list in value:
for item in each_list:
if item.widget_type == 'TopicTitle':
item.title = '%s) %s' % (counter, capfirst(item.title))
counter += 1
if not report_buckets:
#print "report buckets are %s" % report_buckets
#print "vmd.m_pmh is %s" % vmd.m_pmh
if vmd.m_pmh == 'done':
status.append({
'text':"No current issues were identified." ,
'weight':2
})
elif vmd.m_pmh == "running":
status.append({
'text':'Section started, but not completed.',
'weight':2
})
else:
status.append({
'text':'No data collected',
'weight':2,
})
for t1 in status:
t1['weight'] = string.zfill(str(t1['weight']), 4)
#print " value of report_buckets is %s" % report_buckets
#print " value of status is %s" % status
#print "value of report_buckets %s " % report_buckets
c = {'status':status}
print "################################################"
print c
#return c
#return report_buckets
return {
'_report_buckets':report_buckets,
'status':c,
}
Я получаю значение c как:
{'status': [{'text': 'Section started, but not completed.', 'weight': '0002'}]}
Я хочу отобразить значение текста, поэтому я написал в своем шаблоне как
{% load text_tools %}
Why are you not getting printed ?
{% ifequal this_section.type 'simple-report-topic' %}
{% if status %}
{% for group in status %}
{% for score in group %}
{{ score.text|capfirst }};
{% endfor %}
{% endfor %}
{% endif %}
{% endifequal %}
этоотображение
Почему вы не печатаете?S S
Почему он не входит в цикл?Какой шаблон тега мне не хватает?