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