incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/5] git commit: [#5727] ticket:264 Command skeleton
Date Tue, 12 Feb 2013 16:59:06 GMT
[#5727] ticket:264 Command skeleton


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6a37341e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6a37341e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6a37341e

Branch: refs/heads/master
Commit: 6a37341e64f16468a3508c235e76d17186175d30
Parents: 1150a67
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Feb 1 09:51:15 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Tue Feb 12 16:58:47 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/command/fix_discussion.py         |   53 +++++++++++++++
 ForgeTracker/setup.py                              |    3 +
 2 files changed, 56 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a37341e/ForgeTracker/forgetracker/command/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/command/__init__.py b/ForgeTracker/forgetracker/command/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a37341e/ForgeTracker/forgetracker/command/fix_discussion.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/command/fix_discussion.py b/ForgeTracker/forgetracker/command/fix_discussion.py
new file mode 100644
index 0000000..bfac130
--- /dev/null
+++ b/ForgeTracker/forgetracker/command/fix_discussion.py
@@ -0,0 +1,53 @@
+from bson import ObjectId
+from bson.errors import InvalidId
+
+from allura.command import base
+from allura import model as M
+from allura.lib import exceptions as exc
+
+
+class FixDiscussion(base.Command):
+    """Fixes trackers that had used buggy 'ticket move' feature before it was fixed.
+
+    See [#5727] for details.
+
+    Usage:
+
+    paster fix-discussion ../Allura/development.ini [project_name_or_id]
+
+    If used with optional parameter will fix trackers for specified project,
+    else will fix all trackers in all projects.
+    """
+    group_name = 'ForgeTracker'
+    min_args = 1
+    max_args = 2
+    usage = '<ini file> [project_name_or_id]'
+    summary = "Fix trackers that had used buggy 'ticket move' feature"
+    parser = base.Command.standard_parser(verbose=True)
+
+    def command(self):
+        self.basic_setup()
+
+        if len(self.args) >= 2:
+            p_name_or_id = self.args[1]
+            try:
+                project = M.Project.query.get(_id=ObjectId(p_name_or_id))
+            except InvalidId:
+                projects = M.Project.query.find({'$or': [
+                    {'shortname': p_name_or_id},
+                    {'name': p_name_or_id}
+                ]})
+                if projects.count() > 1:
+                    raise exc.ForgeError('Multiple projects has a shortname %s. '
+                            'Use project _id instead.' % p_name_or_id)
+                project = projects.first()
+            if not project:
+                raise exc.NoSuchProjectError('The project %s '
+                        'could not be found' % p_name_or_id)
+
+            self.fix_for_project(project)
+        else:
+            base.log.info('Checking discussion instances for each tracker in all projects')
+
+    def fix_for_project(self, project):
+        base.log.info('Checking discussion instances for each tracker in project %s' % project.shortname)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a37341e/ForgeTracker/setup.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/setup.py b/ForgeTracker/setup.py
index b44f1a4..3cd2da0 100644
--- a/ForgeTracker/setup.py
+++ b/ForgeTracker/setup.py
@@ -28,5 +28,8 @@ setup(name='ForgeTracker',
 
       [easy_widgets.resources]
       ew_resources=forgetracker.config.resources:register_ew_resources
+
+      [paste.paster_command]
+      fix-discussion = forgetracker.command.fix_discussion:FixDiscussion
       """,
       )


Mime
View raw message