source: timingandestimationplugin/branches/trac1.0-Permissions/timingandestimationplugin/statuses.py

Last change on this file was 17010, checked in by Russ Tyndall, 6 years ago

Code to handle status <none>

File size: 872 bytes
Line 
1import dbhelper
2import re
3from trac.ticket.default_workflow import get_workflow_config
4try: 
5    set 
6except NameError: 
7    from sets import Set as set     # Python 2.3 fallback
8
9def status_variables(statuses):
10    return ', '.join(['$'+re.sub(r"\W|_|\s", "", i.upper(), re.I)
11                      for i in list(statuses)])
12
13def get_statuses(env):
14    config = env.config
15    stats = get_statuses_from_workflow(config)
16    status_sql = """
17    SELECT DISTINCT status FROM ticket WHERE status <> '' ;
18    """
19    stats |= set(dbhelper.get_column_as_list(env, status_sql))
20    stats.difference_update(['', None])
21    return stats
22
23def get_statuses_from_workflow(config):
24    wf = get_workflow_config(config)
25    x = set()
26    for key, value in wf.items():
27        x.add(value['newstate'])
28        x |= set(value['oldstates'])
29    x.difference_update([u'*'])
30    return x
Note: See TracBrowser for help on using the repository browser.