Projet

Général

Profil

0001-backoffice-consider-visibility-in-total-formdata-cou.patch

Frédéric Péters, 21 octobre 2018 15:55

Télécharger (1,83 ko)

Voir les différences:

Subject: [PATCH] backoffice: consider visibility in total formdata counts
 (#27483)

 wcs/backoffice/management.py |  2 +-
 wcs/sql.py                   | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
wcs/backoffice/management.py
474 474
        if using_postgresql:
475 475
            from wcs import sql
476 476
            actionable_counts = sql.get_actionable_counts(user_roles)
477
            total_counts = sql.get_total_counts()
477
            total_counts = sql.get_total_counts(user_roles)
478 478

  
479 479
        def append_form_entry(formdef):
480 480
            if using_postgresql:
wcs/sql.py
2030 2030
    return counts
2031 2031

  
2032 2032
@guard_postgres
2033
def get_total_counts():
2033
def get_total_counts(user_roles):
2034 2034
    conn, cur = get_connection_and_cursor()
2035
    criterias = [
2036
        Intersects('concerned_roles_array', user_roles),
2037
    ]
2038
    where_clauses, parameters, func_clause = parse_clause(criterias)
2035 2039
    statement = '''SELECT formdef_id, COUNT(*)
2036 2040
                     FROM wcs_all_forms
2037
                    WHERE status != 'draft'
2038
                 GROUP BY formdef_id'''
2039
    cur.execute(statement)
2041
                    WHERE %s
2042
                 GROUP BY formdef_id''' % ' AND '.join(where_clauses)
2043
    cur.execute(statement, parameters)
2040 2044
    counts = {str(x): y for x, y in cur.fetchall()}
2041 2045
    conn.commit()
2042 2046
    cur.close()
2043
-