| Rev | Line | |
|---|
| [2774] | 1 | import dbhelper |
|---|
| [17010] | 2 | import re |
|---|
| [2774] | 3 | from trac.ticket.default_workflow import get_workflow_config |
|---|
| [6531] | 4 | try: |
|---|
| 5 | set |
|---|
| 6 | except NameError: |
|---|
| 7 | from sets import Set as set # Python 2.3 fallback |
|---|
| [2774] | 8 | |
|---|
| 9 | def status_variables(statuses): |
|---|
| [17010] | 10 | return ', '.join(['$'+re.sub(r"\W|_|\s", "", i.upper(), re.I) |
|---|
| 11 | for i in list(statuses)]) |
|---|
| [3784] | 12 | |
|---|
| [8140] | 13 | def 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 | """ |
|---|
| [8140] | 19 | stats |= set(dbhelper.get_column_as_list(env, status_sql)) |
|---|
| [2774] | 20 | stats.difference_update(['', None]) |
|---|
| 21 | return stats |
|---|
| 22 | |
|---|
| 23 | def 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.