backoffice: do not include anonymised formdata in summary counts (#49894)
This commit is contained in:
parent
2152451bcc
commit
0f571321be
|
@ -19,6 +19,7 @@ from wcs.qommon.form import PicklableUpload
|
|||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
import wcs.qommon.storage as st
|
||||
from wcs.roles import Role, logged_users_role
|
||||
from wcs.workflows import (
|
||||
Workflow, CommentableWorkflowStatusItem,
|
||||
|
@ -296,6 +297,25 @@ def test_backoffice_forms(pub):
|
|||
assert 'Forms in your care' in resp.text
|
||||
assert '9 open on 50' in resp.text
|
||||
|
||||
# anonymise some formdata, they should no longer be included
|
||||
if pub.is_using_postgresql():
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
for i, formdata in enumerate(formdef.data_class().select([st.Equal('status', 'wf-finished')], order_by='id')):
|
||||
if i >= 20:
|
||||
break
|
||||
formdata.anonymise()
|
||||
|
||||
for i, formdata in enumerate(formdef.data_class().select([st.Equal('status', 'wf-new')], order_by='id')):
|
||||
if i >= 5:
|
||||
break
|
||||
formdata.anonymise()
|
||||
|
||||
resp = app.get('/backoffice/')
|
||||
resp = resp.click('Management', index=0)
|
||||
resp = resp.follow()
|
||||
assert 'Forms in your care' in resp.text
|
||||
assert '4 open on 25' in resp.text
|
||||
|
||||
|
||||
def test_backoffice_management_css_class(pub):
|
||||
create_superuser(pub)
|
||||
|
|
|
@ -28,7 +28,7 @@ from quixote import get_request, get_publisher, get_session
|
|||
from quixote.http_request import Upload
|
||||
|
||||
from .qommon import _, N_
|
||||
from .qommon.storage import StorableObject, Intersects, Contains
|
||||
from .qommon.storage import StorableObject, Intersects, Contains, Null
|
||||
from .qommon import misc
|
||||
from .qommon.evalutils import make_datetime
|
||||
from .qommon.publisher import get_cfg
|
||||
|
@ -329,8 +329,11 @@ class FormData(StorableObject):
|
|||
def get_actionable_count(cls, user_roles):
|
||||
if get_publisher().is_using_postgresql():
|
||||
statuses = ['wf-%s' % x.id for x in cls._formdef.workflow.get_not_endpoint_status()]
|
||||
criterias = [Intersects('actions_roles_array', user_roles),
|
||||
Contains('status', statuses)]
|
||||
criterias = [
|
||||
Intersects('actions_roles_array', user_roles),
|
||||
Contains('status', statuses),
|
||||
Null('anonymised'),
|
||||
]
|
||||
return cls.count(criterias)
|
||||
else:
|
||||
return len(cls.get_actionable_ids(user_roles))
|
||||
|
|
|
@ -2710,8 +2710,11 @@ def get_period_query(period_start=None, include_start=True, period_end=None, inc
|
|||
@guard_postgres
|
||||
def get_actionable_counts(user_roles):
|
||||
conn, cur = get_connection_and_cursor()
|
||||
criterias = [Equal('is_at_endpoint', False),
|
||||
Intersects('actions_roles_array', user_roles)]
|
||||
criterias = [
|
||||
Equal('is_at_endpoint', False),
|
||||
Intersects('actions_roles_array', user_roles),
|
||||
Null('anonymised'),
|
||||
]
|
||||
where_clauses, parameters, func_clause = parse_clause(criterias)
|
||||
statement = '''SELECT formdef_id, COUNT(*)
|
||||
FROM wcs_all_forms
|
||||
|
@ -2729,6 +2732,7 @@ def get_total_counts(user_roles):
|
|||
conn, cur = get_connection_and_cursor()
|
||||
criterias = [
|
||||
Intersects('concerned_roles_array', user_roles),
|
||||
Null('anonymised'),
|
||||
]
|
||||
where_clauses, parameters, func_clause = parse_clause(criterias)
|
||||
statement = '''SELECT formdef_id, COUNT(*)
|
||||
|
|
Loading…
Reference in New Issue