[cig-commits] r12702 - in cs/portal/trunk/northridge/SeismoWebPortal: . templates/SeismoWebPortal

leif at geodynamics.org leif at geodynamics.org
Fri Aug 22 14:44:26 PDT 2008


Author: leif
Date: 2008-08-22 14:44:26 -0700 (Fri, 22 Aug 2008)
New Revision: 12702

Modified:
   cs/portal/trunk/northridge/SeismoWebPortal/management.py
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html
Log:
Wrote database migration code for upgraded UserInfo table, in
preparation for deployment.


Modified: cs/portal/trunk/northridge/SeismoWebPortal/management.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/management.py	2008-08-22 16:03:55 UTC (rev 12701)
+++ cs/portal/trunk/northridge/SeismoWebPortal/management.py	2008-08-22 21:44:26 UTC (rev 12702)
@@ -277,6 +277,59 @@
     return
 
 
+def upgradeDatabaseFromRevision12467():
+    # Migrate from v3.1.2 to v3.2.0.  Assumes the following SQL
+    # command has already been performed manually:
+    #
+    #     alter table SeismoWebPortal_userinfo rename to SeismoWebPortal_userinfo_old;
+    #
+    # (A new UserInfo table will be created by 'syncdb'.)
+
+    from pysqlite2 import dbapi2 as sqlite
+    from django.contrib.auth.models import User
+    from django.conf import settings
+
+    print "Upgrading database from r12467"
+    
+    con = sqlite.connect(settings.DATABASE_NAME)
+    cur = con.cursor()
+    cur.execute("select * from SeismoWebPortal_userinfo_old")
+    oldUserInfoList = list(cur)
+    con = cur = None # unlock DB
+
+    for oldUserInfo in oldUserInfoList:
+        
+        (user_id,
+         institution,
+         address1, address2, address3, phone,
+         invite_id, approved) = oldUserInfo
+        
+        user = User.objects.get(id = user_id)
+        invite = None
+        if invite_id:
+            invite = models.Invite.objects.get(id = invite_id)
+        
+        models.UserInfo.objects.create(
+            user         = user,
+            institution  = institution,
+
+            # the following fields are now required
+            address1     = address1 or "",
+            address2     = address2 or "",
+            address3     = address3 or "",
+            phone        = phone or "",
+
+            # new fields
+            role         = 5, # other
+            adviser      = "",
+            
+            invite       = invite,
+            approved     = approved,
+            )
+
+    return
+
+
 def createUserInfo():
     from django.contrib.auth.models import User
 
@@ -400,9 +453,13 @@
         createAwards()
 
     legacyDBList = os.environ.get('WEBPORTAL_LEGACY_DB')
+    hook = os.environ.get('WEBPORTAL_MANAGEMENT_HOOK')
     if legacyDBList:
         for legacyDB in legacyDBList.split(':'):
             importLegacyDatabase(legacyDB)
+    elif hook:
+        # upgradeDatabaseFromRevision12467()
+        globals()[hook]()
 
     createUserInfo()
 

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html	2008-08-22 16:03:55 UTC (rev 12701)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html	2008-08-22 21:44:26 UTC (rev 12702)
@@ -20,7 +20,7 @@
 
     <p id="powered">Powered by:</p>
     <ul id="codes">
-        <li><img src="{{root}}/images/specfem3dg_logo.jpg" width=99 height=94> Specfem 3D Globe v4.0
+        <li><img src="{{root}}/images/specfem3dg_logo.jpg" width=99 height=94> Specfem 3D Globe v4.0.3
         <li><img src="{{root}}/images/mineos_logo.gif" width=75 height=75> Mineos v1.0
     </ul>
 



More information about the cig-commits mailing list