incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1404932 - in /incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct: api.py model.py
Date Fri, 02 Nov 2012 12:00:17 GMT
Author: gjm
Date: Fri Nov  2 12:00:16 2012
New Revision: 1404932

URL: http://svn.apache.org/viewvc?rev=1404932&view=rev
Log:
change trac tickets to link to product.prefix instead of product.name - includes a basic migration
to update tickets from the old name references - towards #110

Modified:
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/model.py

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py?rev=1404932&r1=1404931&r2=1404932&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py Fri Nov  2 12:00:16
2012
@@ -33,7 +33,7 @@ from trac.web.chrome import ITemplatePro
 
 from multiproduct.model import Product
 
-DB_VERSION = 1
+DB_VERSION = 2
 DB_SYSTEM_KEY = 'bloodhound_multi_product_version'
 PLUGIN_NAME = 'Bloodhound multi product'
 
@@ -102,6 +102,18 @@ class MultiProductSystem(Component):
                     for statement in db_connector.to_sql(table):
                         db(statement)
                 db_installed_version = self.get_version()
+            
+            if db_installed_version == 1:
+                from multiproduct.model import Product
+                products = Product.select(self.env)
+                for prod in products:
+                    db("""UPDATE ticket SET product=%s
+                          WHERE product=%s""", (prod.prefix, prod.name))
+                
+                db("""UPDATE system SET value=%s
+                      WHERE name=%s""", (DB_VERSION, DB_SYSTEM_KEY))
+                self.log.info("Upgraded multiproduct db schema from version %d"
+                              " to %d" % (db_installed_version, DB_VERSION))
     
     # ITemplateProvider methods
     def get_templates_dirs(self):
@@ -122,7 +134,7 @@ class MultiProductSystem(Component):
     def get_select_fields(self):
         """Product select fields"""
         return [(35, {'name': 'product', 'label': N_('Product'),
-                      'cls': Product, 'optional': True})]
+                      'cls': Product, 'pk': 'prefix', 'optional': True})]
     
     def get_radio_fields(self):
         """Product radio fields"""

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/model.py?rev=1404932&r1=1404931&r2=1404932&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/model.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/model.py Fri Nov  2 12:00:16
2012
@@ -273,9 +273,8 @@ class Product(ModelBase):
         now = datetime.now(utc)
         comment = 'Product %s renamed to %s' % (old_name, new_name)
         if old_name != new_name:
-            for t in Product.get_tickets(self._env, old_name):
+            for t in Product.get_tickets(self._env, self._data['prefix']):
                 ticket = Ticket(self._env, t['id'], db)
-                ticket['product'] = new_name
                 ticket.save_changes(author, comment, now)
     
     @classmethod



Mime
View raw message