source: timingandestimationplugin/branches/trac0.12-Permissions/timingandestimationplugin/statuses.py

Last change on this file was 8141, checked in by Russ Tyndall, 13 years ago

Converting to use new trac12 DB convensions. version 0.9.8b

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