# HG changeset patch # User Sylvain Thénault # Date 1249075305 -7200 # Node ID c97c4b56e6a01d40154667267d4b4d21b3d361a9 # Parent 287e43c6ed8167da7de8190ac1a8de10b9d2f4a3 rewrite migrscheam diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migratedapp/bootstrap_cubes --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/test/data/migratedapp/bootstrap_cubes Fri Jul 31 23:21:45 2009 +0200 @@ -0,0 +1,1 @@ +card,comment,folder,tag,basket,email,file diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migratedapp/schema.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/test/data/migratedapp/schema.py Fri Jul 31 23:21:45 2009 +0200 @@ -0,0 +1,124 @@ +""" + +:organization: Logilab +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. +:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr +:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses +""" +from yams.buildobjs import (EntityType, RelationType, RelationDefinition, + SubjectRelation, ObjectRelation, + RichString, String, Int, Boolean, Datetime, Date) +from yams.constraints import SizeConstraint, UniqueConstraint +from cubicweb.schema import (WorkflowableEntityType, RQLConstraint, + ERQLExpression, RRQLExpression) + +class Affaire(EntityType): + permissions = { + 'read': ('managers', 'users', 'guests'), + 'add': ('managers', ERQLExpression('X concerne S, S owned_by U')), + 'update': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), + 'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), + } + + ref = String(fulltextindexed=True, indexed=True, + constraints=[SizeConstraint(16)]) + sujet = String(fulltextindexed=True, + constraints=[SizeConstraint(256)]) + concerne = SubjectRelation('Societe') + +class concerne(RelationType): + permissions = { + 'read': ('managers', 'users', 'guests'), + 'add': ('managers', RRQLExpression('U has_update_permission S')), + 'delete': ('managers', RRQLExpression('O owned_by U')), + } + +class Note(EntityType): + permissions = {'read': ('managers', 'users', 'guests',), + 'update': ('managers', 'owners',), + 'delete': ('managers', ), + 'add': ('managers', + ERQLExpression('X ecrit_part PE, U in_group G, ' + 'PE require_permission P, P name "add_note", ' + 'P require_group G'),)} + + date = Datetime() + type = String(maxsize=1) + whatever = Int() + mydate = Date(default='TODAY') + para = String(maxsize=512) + shortpara = String(maxsize=64) + ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')]) + attachment = SubjectRelation(('File', 'Image')) + +class ecrit_par(RelationType): + permissions = {'read': ('managers', 'users', 'guests',), + 'delete': ('managers', ), + 'add': ('managers', + RRQLExpression('O require_permission P, P name "add_note", ' + 'U in_group G, P require_group G'),) + } + inlined = True + cardinality = '?*' + +class Folder2(EntityType): + """folders are used to classify entities. They may be defined as a tree. + When you include the Folder entity, all application specific entities + may then be classified using the "filed_under" relation. + """ + name = String(required=True, indexed=True, internationalizable=True, + constraints=[UniqueConstraint(), SizeConstraint(64)]) + description = RichString(fulltextindexed=True) + + filed_under2 = ObjectRelation('*') + + +class filed_under2(RelationType): + """indicates that an entity is classified under a folder""" + # is_about has been renamed into filed_under + #//* is_about Folder + #* filed_under Folder + +class Personne(EntityType): + nom = String(fulltextindexed=True, required=True, maxsize=64) + prenom = String(fulltextindexed=True, maxsize=64) + sexe = String(maxsize=1, default='M') + promo = String(vocabulary=('bon','pasbon')) + titre = String(fulltextindexed=True, maxsize=128) + adel = String(maxsize=128) + ass = String(maxsize=128) + web = String(maxsize=128) + tel = Int() + fax = Int() + datenaiss = Datetime() + test = Boolean() + + travaille = SubjectRelation('Societe') + concerne = SubjectRelation('Affaire') + concerne2 = SubjectRelation('Affaire') + connait = SubjectRelation('Personne', symetric=True) + +class Societe(EntityType): + permissions = { + 'read': ('managers', 'users', 'guests'), + 'update': ('managers', 'owners'), + 'delete': ('managers', 'owners'), + 'add': ('managers', 'users',) + } + + nom = String(maxsize=64, fulltextindexed=True) + web = String(maxsize=128) + tel = Int() + fax = Int() + rncs = String(maxsize=128) + ad1 = String(maxsize=128) + ad2 = String(maxsize=128) + ad3 = String(maxsize=128) + cp = String(maxsize=12) + ville= String(maxsize=32) + + in_state = SubjectRelation('State', cardinality='?*') + +class evaluee(RelationDefinition): + subject = ('Personne', 'CWUser', 'Societe') + object = ('Note') diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/Affaire.py --- a/server/test/data/migrschema/Affaire.py Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -""" - -:organization: Logilab -:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" - -class Affaire(EntityType): - permissions = { - 'read': ('managers', 'users', 'guests'), - 'add': ('managers', ERQLExpression('X concerne S, S owned_by U')), - 'update': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), - 'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), - } - - ref = String(fulltextindexed=True, indexed=True, - constraints=[SizeConstraint(16)]) - sujet = String(fulltextindexed=True, - constraints=[SizeConstraint(256)]) - -class concerne(RelationType): - permissions = { - 'read': ('managers', 'users', 'guests'), - 'add': ('managers', RRQLExpression('U has_update_permission S')), - 'delete': ('managers', RRQLExpression('O owned_by U')), - } - diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/Folder2.py --- a/server/test/data/migrschema/Folder2.py Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -""" - -:organization: Logilab -:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" - -class Folder2(MetaUserEntityType): - """folders are used to classify entities. They may be defined as a tree. - When you include the Folder entity, all application specific entities - may then be classified using the "filed_under" relation. - """ - name = String(required=True, indexed=True, internationalizable=True, - constraints=[UniqueConstraint(), SizeConstraint(64)]) - description = RichString(fulltextindexed=True) - - filed_under2 = BothWayRelation( - SubjectRelation('Folder2', description=_("parent folder")), - ObjectRelation('*'), - ) - - -class filed_under2(MetaUserRelationType): - """indicates that an entity is classified under a folder""" - # is_about has been renamed into filed_under - #//* is_about Folder - #* filed_under Folder - diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/Note.py --- a/server/test/data/migrschema/Note.py Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -""" - -:organization: Logilab -:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" -class Note(EntityType): - - permissions = {'read': ('managers', 'users', 'guests',), - 'update': ('managers', 'owners',), - 'delete': ('managers', ), - 'add': ('managers', - ERQLExpression('X ecrit_part PE, U in_group G, ' - 'PE require_permission P, P name "add_note", ' - 'P require_group G'),)} - - date = Datetime() - type = String(maxsize=1) - whatever = Int() - mydate = Date(default='TODAY') - para = String(maxsize=512) - shortpara = String(maxsize=64) - ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')]) - -class ecrit_par(RelationType): - permissions = {'read': ('managers', 'users', 'guests',), - 'delete': ('managers', ), - 'add': ('managers', - RRQLExpression('O require_permission P, P name "add_note", ' - 'U in_group G, P require_group G'),) - } - inlined = True diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/Personne.sql --- a/server/test/data/migrschema/Personne.sql Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -nom ivarchar(64) NOT NULL -prenom ivarchar(64) -civility char(1) DEFAULT 'M' -promo choice('bon','pasbon') -titre ivarchar(128) -adel varchar(128) -ass varchar(128) -web varchar(128) -tel integer -fax integer -datenaiss datetime -test boolean diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/Societe.perms --- a/server/test/data/migrschema/Societe.perms Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Read: managers, users, guests diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/Societe.sql --- a/server/test/data/migrschema/Societe.sql Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -nom ivarchar(64) -web varchar(128) -tel integer -fax integer -rncs varchar(32) -ad1 varchar(128) -ad2 varchar(128) -ad3 varchar(128) -cp varchar(12) -ville varchar(32) diff -r 287e43c6ed81 -r c97c4b56e6a0 server/test/data/migrschema/relations.rel --- a/server/test/data/migrschema/relations.rel Fri Jul 31 20:05:33 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -Personne travaille Societe -Personne evaluee Note -CWUser evaluee Note -Societe evaluee Note -Personne concerne Affaire -Affaire concerne Societe -Personne concerne2 Affaire - -Personne connait Personne symetric - -Societe in_state State inline - -Note attachment File -Note attachment Image -