0001-backoffice-fix-error-count-displayed-55810.patch
tests/admin_pages/test_logged_errors.py | ||
---|---|---|
136 | 136 |
assert resp.text.count('Logged Error n°') == 17 |
137 | 137 | |
138 | 138 |
# formdef errors |
139 |
resp = app.get('/backoffice/forms/%s/' % formdef.id) |
|
140 |
assert '21 errors' in resp |
|
139 | 141 |
resp = app.get('/backoffice/forms/%s/logged-errors/' % formdef.id) |
140 | 142 |
assert '1-20/21' in resp.text |
141 | 143 |
assert resp.text.count('FormDef Workflow Logged Error n°') == 20 |
... | ... | |
144 | 146 |
assert resp.text.count('FormDef Workflow Logged Error n°') == 1 |
145 | 147 | |
146 | 148 |
# carddef errors |
149 |
resp = app.get('/backoffice/cards/%s/' % carddef.id) |
|
150 |
assert '21 errors' in resp |
|
147 | 151 |
resp = app.get('/backoffice/cards/%s/logged-errors/' % carddef.id) |
148 | 152 |
assert '1-20/21' in resp.text |
149 | 153 |
assert resp.text.count('CardDef Workflow Logged Error n°') == 20 |
... | ... | |
152 | 156 |
assert resp.text.count('CardDef Workflow Logged Error n°') == 1 |
153 | 157 | |
154 | 158 |
# workflows errors |
159 |
resp = app.get('/backoffice/workflows/%s/' % workflow.id) |
|
160 |
assert '63 errors' in resp |
|
155 | 161 |
resp = app.get('/backoffice/workflows/%s/logged-errors/' % workflow.id) |
156 | 162 |
assert '1-20/63' in resp.text |
157 | 163 |
assert resp.text.count('Workflow Logged Error n°') == 20 |
wcs/admin/logged_errors.py | ||
---|---|---|
110 | 110 |
_q_exports = [''] |
111 | 111 | |
112 | 112 |
@classmethod |
113 |
def get_errors( |
|
114 |
cls, offset, limit, formdef_class=None, formdef_id=None, workflow_id=None, with_total=False |
|
115 |
): |
|
113 |
def get_errors(cls, offset, limit, formdef_class=None, formdef_id=None, workflow_id=None): |
|
116 | 114 |
errors = [] |
117 | 115 |
if not get_publisher().loggederror_class: |
118 | 116 |
return errors, 0 |
... | ... | |
141 | 139 |
clauses.append(NotNull('formdef_class')) |
142 | 140 | |
143 | 141 |
errors = get_publisher().loggederror_class.select(clause=clauses, **select_kwargs) |
144 | ||
145 |
count = 0 |
|
146 |
if with_total: |
|
147 |
count = get_publisher().loggederror_class.count(clauses) |
|
142 |
count = get_publisher().loggederror_class.count(clauses) |
|
148 | 143 | |
149 | 144 |
return list(errors), count |
150 | 145 | |
151 | 146 |
@classmethod |
152 | 147 |
def errors_block(cls, formdef_class=None, formdef_id=None, workflow_id=None): |
153 | 148 |
# select 3 + 1 last errors |
154 |
errors = cls.get_errors( |
|
149 |
errors, total = cls.get_errors(
|
|
155 | 150 |
offset=0, limit=4, formdef_class=formdef_class, formdef_id=formdef_id, workflow_id=workflow_id |
156 |
)[0]
|
|
151 |
) |
|
157 | 152 |
if not errors: |
158 | 153 |
return '' |
159 | 154 | |
... | ... | |
161 | 156 |
r += htmltext('<div class="bo-block logged-errors">') |
162 | 157 |
r += ( |
163 | 158 |
htmltext('<h3><a href="logged-errors/">%s</a></h3>') |
164 |
% ngettext('%(count)d error', '%(count)d errors', len(errors))
|
|
165 |
% {'count': len(errors)}
|
|
159 |
% ngettext('%(count)d error', '%(count)d errors', total)
|
|
160 |
% {'count': total}
|
|
166 | 161 |
) |
167 | 162 |
r += htmltext('<ul>') |
168 | 163 |
for error in errors[:3]: |
... | ... | |
208 | 203 |
formdef_class=self.formdef_class, |
209 | 204 |
formdef_id=self.formdef_id, |
210 | 205 |
workflow_id=self.workflow_id, |
211 |
with_total=True, |
|
212 | 206 |
) |
213 | 207 |
links = '' |
214 | 208 |
if get_publisher().is_using_postgresql(): |
215 |
- |