]> git.parisson.com Git - telemeta-data.git/commitdiff
allow revision user field to be null, add collections and items import revisions...
authorolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Mon, 15 Feb 2010 19:56:19 +0000 (19:56 +0000)
committerolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Mon, 15 Feb 2010 19:56:19 +0000 (19:56 +0000)
git-svn-id: http://svn.parisson.org/svn/crem@157 3bf09e05-f825-4182-b9bc-eedd7160adf0

trunk/docref/crem.sql
trunk/docref/docref.odt
trunk/import/migration/tasks/collections.py
trunk/import/migration/tasks/items.py

index aac764f5671e1281a5d7ae52c3db72a38faad8e9..4c4fcb13905daee5a88080f612ad3ea481938c3a 100644 (file)
@@ -422,9 +422,9 @@ CREATE TABLE revisions (
     id              INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, 
     element_type    VARCHAR(32) NOT NULL,
     element_id      INTEGER NOT NULL,
-    change_type     ENUM('create', 'update', 'delete') NOT NULL,
+    change_type     ENUM('import', 'create', 'update', 'delete') NOT NULL,
     time            DATETIME NOT NULL,
-    username        VARCHAR(64) NOT NULL,
+    username        VARCHAR(64),
 
     FOREIGN KEY(username) REFERENCES users (username) 
 ) CHARACTER SET='utf8' ENGINE=InnoDB;
index a1482ead57d929ffa0c0376aed42034ad381152d..1373847645371a11e83f5080851315798d7ef347 100644 (file)
Binary files a/trunk/docref/docref.odt and b/trunk/docref/docref.odt differ
index 7c176a822b9653eb043e7309529ea8d94e8476c0..3c0b4bf01b74aa1ef81768911cdf65e2e81e1fa6 100644 (file)
@@ -37,6 +37,7 @@ from core import DataMigrator, EnumMapper
 from _mysql_exceptions import IntegrityError
 from MySQLdb.constants.ER import DUP_ENTRY
 import re
+from datetime import datetime
 
 class CollectionsCopyMigrator(DataMigrator):
     """Perform a preliminary raw copy of the collection table"""
@@ -372,3 +373,18 @@ class CollectionsPublishedStateMigrator(DataMigrator):
         self.target_cursor.execute("UPDATE media_collections SET is_published = (old_code LIKE 'DI.%')")
         self.stats['published'] = self.target_cursor.rowcount
         self.end()
+
+class CollectionRevisionsBuilder(DataMigrator):
+    """Insert initial import revisions for all collections"""
+
+    implements(IDataMigrator)
+
+    def get_name(self):
+        return "collections:revisions"
+
+    def process(self):
+        self.start()
+        self.target("DELETE FROM revisions WHERE element_type = 'collection'")
+        self.target("INSERT INTO revisions (element_type, element_id, change_type, time) "
+                    "SELECT 'collection', id, 'import', %s FROM media_collections", (datetime.now()))
+        self.end()
index b00b67e65a0883c2346db372d2edcb23d0e588b7..dc6a751aa7843d93646b826b8f2e6ba61fc0f320 100644 (file)
@@ -37,6 +37,7 @@ from core import DataMigrator, EnumMapper
 from geoethno import GeoEthnoImporter
 import re
 import sys
+from datetime import datetime
 
 class ItemsCopyMigrator(DataMigrator):
     """Perform a preliminary raw copy of the item table"""
@@ -344,6 +345,20 @@ class ItemsTitleCleaner(DataMigrator):
         self.stats['emptied'] = self.target_cursor.rowcount
         self.end()
 
+class ItemRevisionsBuilder(DataMigrator):
+    """Insert initial import revisions for all items"""
+
+    implements(IDataMigrator)
+
+    def get_name(self):
+        return "items:revisions"
+
+    def process(self):
+        self.start()
+        self.target("DELETE FROM revisions WHERE element_type = 'item'")
+        self.target("INSERT INTO revisions (element_type, element_id, change_type, time) "
+                    "SELECT 'item', id, 'import', %s FROM media_items", (datetime.now()))
+        self.end()