Edgewall Software

source: trunk/contrib/workflow/migrate_original_to_basic.py

Last change on this file was 17759, checked in by Jun Omae, 6 months ago

1.7.1dev: merge [17757:17758] from 1.6-stable (fix for #13629)

[skip ci]

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) 2007-2023 Edgewall Software
5# Copyright (C) 2007 Eli Carter <retracile@gmail.com>
6# All rights reserved.
7#
8# This software is licensed as described in the file COPYING, which
9# you should have received as part of this distribution. The terms
10# are also available at https://trac.edgewall.org/wiki/TracLicense.
11#
12# This software consists of voluntary contributions made by many
13# individuals. For the exact contribution history, see the revision
14# history and logs, available at https://trac.edgewall.org/.
15
16import sys
17
18import trac.env
19from trac.ticket.default_workflow import load_workflow_config_snippet
20
21
22def main():
23 """Rewrite the ticket-workflow section of the config; and change all
24 'assigned' tickets to 'accepted'.
25 """
26 if len(sys.argv) != 2:
27 print("Usage: %s path_to_trac_environment" % sys.argv[0])
28 sys.exit(1)
29 tracdir = sys.argv[1]
30 trac_env = trac.env.open_environment(tracdir)
31
32 # Update the config...
33 old_workflow = trac_env.config.options('ticket-workflow')
34 for name, value in old_workflow:
35 trac_env.config.remove('ticket-workflow', name)
36 load_workflow_config_snippet(trac_env.config, 'basic-workflow.ini')
37 trac_env.config.save()
38
39 # Update the ticket statuses...
40 trac_env.db_transaction("""
41 UPDATE ticket SET status = 'accepted' WHERE status = 'assigned'
42 """)
43
44if __name__ == '__main__':
45 main()
Note: See TracBrowser for help on using the repository browser.