Compare commits

..

1 Commits

Author SHA1 Message Date
Emmanuel Cazenave 2b26cc3c67 backoffice: display drafts stats (#72542)
gitea/wcs/pipeline/head This commit looks good Details
2024-02-09 12:33:37 +01:00
1 changed files with 20 additions and 19 deletions

View File

@ -1769,25 +1769,26 @@ class FormDefPage(Directory, TempfileDirectoryMixin):
temp_drafts[page_id] += 1
total_drafts += 1
drafts = {}
for key in ('_unkown', '_confirmation_page', '_first_page'):
try:
num_drafts = temp_drafts.pop(key)
except KeyError:
num_drafts = 0
drafts[key] = {'total': num_drafts, 'field': None}
for page_id, num_drafts in temp_drafts.items():
for field in self.formdef.iter_fields(with_backoffice_fields=False):
if page_id == field.id and isinstance(field, PageField):
drafts[page_id] = {'total': num_drafts, 'field': field}
break
else:
drafts['_unkown']['total'] += num_drafts
for draft_data in drafts.values():
draft_percent = 100 * draft_data['total'] / total_drafts
draft_data['percent'] = draft_percent
draft_data['percent_rounded'] = '%d' % draft_percent
context['drafts'] = sorted(drafts.items(), reverse=True, key=lambda x: x[1]['total'])
context['drafts_total'] = total_drafts
if total_drafts:
for key in ('_unkown', '_confirmation_page', '_first_page'):
try:
num_drafts = temp_drafts.pop(key)
except KeyError:
num_drafts = 0
drafts[key] = {'total': num_drafts, 'field': None}
for page_id, num_drafts in temp_drafts.items():
for field in self.formdef.iter_fields(with_backoffice_fields=False):
if page_id == field.id and isinstance(field, PageField):
drafts[page_id] = {'total': num_drafts, 'field': field}
break
else:
drafts['_unkown']['total'] += num_drafts
for draft_data in drafts.values():
draft_percent = 100 * draft_data['total'] / total_drafts
draft_data['percent'] = draft_percent
draft_data['percent_rounded'] = '%d' % draft_percent
context['drafts'] = sorted(drafts.items(), reverse=True, key=lambda x: x[1]['total'])
context['drafts_total'] = total_drafts
return template.QommonTemplateResponse(
templates=[self.inspect_template_name],