From: olivier Date: Mon, 15 Feb 2010 19:56:19 +0000 (+0000) Subject: allow revision user field to be null, add collections and items import revisions... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d4ecc24738b8a835775daaa2d58cd0d4c60db52a;p=telemeta-data.git allow revision user field to be null, add collections and items import revisions builders git-svn-id: http://svn.parisson.org/svn/crem@157 3bf09e05-f825-4182-b9bc-eedd7160adf0 --- diff --git a/trunk/docref/crem.sql b/trunk/docref/crem.sql index aac764f..4c4fcb1 100644 --- a/trunk/docref/crem.sql +++ b/trunk/docref/crem.sql @@ -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; diff --git a/trunk/docref/docref.odt b/trunk/docref/docref.odt index a1482ea..1373847 100644 Binary files a/trunk/docref/docref.odt and b/trunk/docref/docref.odt differ diff --git a/trunk/import/migration/tasks/collections.py b/trunk/import/migration/tasks/collections.py index 7c176a8..3c0b4bf 100644 --- a/trunk/import/migration/tasks/collections.py +++ b/trunk/import/migration/tasks/collections.py @@ -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() diff --git a/trunk/import/migration/tasks/items.py b/trunk/import/migration/tasks/items.py index b00b67e..dc6a751 100644 --- a/trunk/import/migration/tasks/items.py +++ b/trunk/import/migration/tasks/items.py @@ -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()