incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [06/50] git commit: [#6608] Close milestones on import if no open tickets
Date Tue, 24 Sep 2013 17:07:45 GMT
[#6608] Close milestones on import if no open tickets

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


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

Branch: refs/heads/cj/6422
Commit: 54c43fd9018c7dc7a66ec54ea087825d44f32874
Parents: c6f4a9d
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Sep 11 14:25:16 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Sep 18 20:24:30 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/trac/tickets.py |  8 ++++----
 ForgeTracker/forgetracker/import_support.py   | 20 +++++++++-----------
 2 files changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/54c43fd9/ForgeImporters/forgeimporters/trac/tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tickets.py b/ForgeImporters/forgeimporters/trac/tickets.py
index cafd403..88ee769 100644
--- a/ForgeImporters/forgeimporters/trac/tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tickets.py
@@ -141,11 +141,11 @@ class TracTicketImporter(ToolImporter):
                     export_string, validate=False)
             AuditLog.log(
                 'import tool %s from %s' % (
-                        app.config.options.mount_point, 
-                        trac_url, 
-                    ), 
+                        app.config.options.mount_point,
+                        trac_url,
+                    ),
                 project=project, user=user, url=app.url,
-            ) 
+            )
             g.post_event('project_updated')
             return app
         except Exception as e:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/54c43fd9/ForgeTracker/forgetracker/import_support.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/import_support.py b/ForgeTracker/forgetracker/import_support.py
index 9637ebc..cfc7839 100644
--- a/ForgeTracker/forgetracker/import_support.py
+++ b/ForgeTracker/forgetracker/import_support.py
@@ -148,7 +148,7 @@ class ImportSupport(object):
         u = M.User.by_username(username)
         return u._id if u else None
 
-    def check_custom_field(self, field, value):
+    def check_custom_field(self, field, value, ticket_status):
         field = c.app.globals.get_custom_field(field)
         if (field['type'] == 'select') and value:
             field_options = h.split_select_field_options(h.really_unicode(field['options']))
@@ -156,20 +156,21 @@ class ImportSupport(object):
                 field['options'] = ' '.join([field['options'], value])
         elif (field['type'] == 'milestone') and value:
             milestones = field['milestones']
-            is_exists = False
             for milestone in milestones:
                 if milestone['name'] == value:
-                    is_exists = True
-            if not is_exists:
+                    if ticket_status in c.app.globals.open_status_names:
+                        milestone['complete'] = False
+                    break
+            else:
                 milestone = {'due_date': '',
-                             'complete': False,
+                             'complete': not ticket_status in c.app.globals.open_status_names,
                              'description': '',
                              'name': value,
                              'old_name': value}
                 field['milestones'].append(milestone)
         ThreadLocalORMSession.flush_all()
 
-    def custom(self, ticket, field, value):
+    def custom(self, ticket, field, value, ticket_status):
         field = '_' + field
         if not c.app.has_custom_field(field):
             log.warning('Custom field %s is not defined, defining as string', field)
@@ -177,12 +178,9 @@ class ImportSupport(object):
             ThreadLocalORMSession.flush_all()
         if 'custom_fields' not in ticket:
             ticket['custom_fields'] = {}
-        self.check_custom_field(field, value)
+        self.check_custom_field(field, value, ticket_status)
         ticket['custom_fields'][field] = value
 
-    #
-    # Object convertors
-    #
     def make_artifact(self, ticket_dict):
         remapped = {}
         for f, v in ticket_dict.iteritems():
@@ -194,7 +192,7 @@ class ImportSupport(object):
             elif callable(transform):
                 transform(remapped, f, v)
             elif transform is ():
-                self.custom(remapped, f, v)
+                self.custom(remapped, f, v, ticket_dict.get('status'))
             else:
                 new_f, conv = transform
                 remapped[new_f] = conv(v)


Mime
View raw message