class Datetest(EntityType): dt1 = Datetime(default=u'now') dt2 = Datetime(default=u'today') d1 = Date(default=u'today') d2 = Date(default=date(2007, 12, 11)) t1 = Time(default=time(8, 40)) t2 = Time(default=time(9, 45))
class Datetest(EntityType): dt1 = Datetime(default=u'now') dt2 = Datetime(default=u'today') d1 = Date(default=u'today', constraints=[BoundaryConstraint('<=', TODAY())]) d2 = Date(default=date(2007, 12, 11)) t1 = Time(default=time(8, 40)) t2 = Time(default=time(9, 45))
class Transaction(EntityType): date = Date() type_achat = String(maxsize=2) # a virer ? pagination = String(maxsize=255, fulltextindexed=True) date_ordre = Date() date_recette = Date() remarques = RichString(fulltextindexed=True, default_format='text/rest') intervenants = SubjectRelation('Intervenant', composite='subject', cardinality='*1') destinataires = SubjectRelation('Destinataire', composite='subject', cardinality='*1') travaux = SubjectRelation('Travail', composite='subject', cardinality='**') vendeurs = SubjectRelation('Vendeur', composite='subject', cardinality='*1') prix_partage = Boolean(required=True, default=False) base_paradox = Boolean(default=False, description='vient de la base Paradox')
class Compte(EntityType): type_compte = String(maxsize=255, required=True) inventaire = String(maxsize=255, required=True, fulltextindexed=True) debut = Date() fin = Date() change_str = String(maxsize=255, fulltextindexed=True) # XXX drop me? receveur = SubjectRelation('Personne', cardinality='**') base_paradox = Boolean(default=False, description='vient de la base Paradox') historic = Boolean(default=True, description=u"vrai si le compte est historique, " "faux s'il s'agit d'un compte technique utilise " "par exemple pour la gestion des changes")
class AchatFabrication(EntityType): date_achat = Date() quantite = Int() quantite_plusieurs = Boolean(default=False, required=True, description='True if quantite is "plusieurs"') parure = SubjectRelation('Parure', cardinality='1*', inlined=True) avec_mat = SubjectRelation('FabriqueAvecMat', cardinality='*1') remarques = RichString(fulltextindexed=True, default_format='text/rest')
class Person(EntityType): __unique_together__ = [('nom', 'prenom')] nom = String(maxsize=64, fulltextindexed=True, required=True) prenom = String(maxsize=64, fulltextindexed=True) sexe = String(maxsize=1, default='M') promo = String(vocabulary=('bon', 'pasbon')) titre = String(maxsize=128, fulltextindexed=True) adel = String(maxsize=128) ass = String(maxsize=128) web = String(maxsize=128) tel = Int(__permissions__={ 'read': (), 'add': ('managers', ), 'update': ('managers', ) }) fax = Int() datenaiss = Date() test = Boolean() salary = Float() travaille = SubjectRelation('Societe', __permissions__={ 'read': (), 'add': (), 'delete': ('managers', ), }) evaluee = SubjectRelation('Note')
class ProcessingRun(EntityType): identifier = String(required=True, maxsize=256, unique=True) type = String(maxsize=256, required=True) label = String(maxsize=256) tool = String(maxsize=256) datetime = Date() category = String(maxsize=256) version = String(maxsize=64) parameters = String(maxsize=256) note = RichString(fulltextindexed=True)
class AchatMateriaux(EntityType): date_achat = Date() type_mesure = String(vocabulary=_TYPES_MESURE, fulltextindexed=True) quantite = Float() quantite_plusieurs = Boolean(default=False, required=True, description='True if quantite is "plusieurs"') unite = String(maxsize=255, fulltextindexed=True) provenance_mesure = String(maxsize=255, fulltextindexed=True) conversion = Float() materiaux = SubjectRelation('Materiaux', cardinality='1*', inlined=True) remarques = RichString(fulltextindexed=True, default_format='text/rest')
class CWSearch(EntityType): """ An entity used to save a search which may contains resources on the server file system. Attributes ---------- title: String (mandatory) a short description of the file. path: String (mandatory) the rql request that will be saved. expiration_data: Date (mandatory) the expiration date of the current search. result: SubjectRelation (mandatory) a json file with all the server resources associated with the current search - {"rql": rql, "files": [], "nonexistent-files": []} rset: SubjectRelation (mandatory) the result set associated with the current search. rset_type: String (optional, default 'jsonexport') the type of the rset. """ __permissions__ = { "read": ( "managers", ERQLExpression("X owned_by U"), ), "add": ("managers", "users"), "delete": ("managers", "owners"), "update": ("managers", "owners"), } title = String(maxsize=256, required=True, constraints=[ RQLUniqueConstraint( "X title N, S title N, X owned_by U, X is CWSearch", mainvars="X", msg=_("this name is already used")) ], description=_("Please set a unique subset name.")) path = String(required=True, description=_("the rql request we will save (do not edit " "this field).")) expiration_date = Date(required=True, indexed=True) # json which contains resultset and filepath result = SubjectRelation("File", cardinality="1*", inlined=True, composite="subject") rset = SubjectRelation("File", cardinality="1*", inlined=True, composite="subject") # view regid to show rset rset_type = String(required=True, default="jsonexport", maxsize=50)
class Note(Para): __specializes_schema__ = True __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'),)} whatever = Int(default=0) # keep it before `date` for unittest_migraction.test_add_attribute_int yesno = Boolean(default=False) date = Datetime() type = String(maxsize=1) unique_id = String(maxsize=1, required=True, unique=True) mydate = Date(default='TODAY') oldstyledefaultdate = Date(default='2013/01/01') newstyledefaultdate = Date(default=dt.date(2013, 1, 1)) shortpara = String(maxsize=11, default='hop', vocabulary=['hop', 'hop hop', 'hop hop hop']) ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')]) attachment = SubjectRelation('File')
class Travail(EntityType): artisan = SubjectRelation('Personne', cardinality='1*', composite='object', inlined=True) salaire_argent = SubjectRelation('Prix', cardinality='??', inlined=True, composite='subject') salaire_nature_qt = Int() salaire_nature_obj = String(maxsize=64, fulltextindexed=True) nombre_aides = Int() designation_aides = String(maxsize=64, fulltextindexed=True) salaire_aides = SubjectRelation('Prix', cardinality='??', inlined=True, composite='subject') tache = String(maxsize=255, fulltextindexed=True) duree = Int() date_travail = Date() remarques = RichString(fulltextindexed=True, default_format='text/rest') facon_et_etoffe = Boolean(default=False, required=True)
class Person(EntityType): """a physical person""" surname = String(required=True, fulltextindexed=True, indexed=True, maxsize=64) firstname = String(fulltextindexed=True, maxsize=64) civility = String(required=True, internationalizable=True, vocabulary=('Mr', 'Ms', 'Mrs'), default='Mr') description = RichString(fulltextindexed=True) birthday = Date()
def test_unfinalized_manipulation(self): class MyEntity(EntityType): base_arg_b = String() base_arg_a = Boolean() base_sub = SubjectRelation('MyOtherEntity') class base_obj(RelationDefinition): subject = 'MyOtherEntity' object = 'MyEntity' class MyOtherEntity(EntityType): base_o_obj = SubjectRelation('MyEntity') class base_o_sub(RelationDefinition): subject = 'MyEntity' object = 'MyOtherEntity' MyEntity.add_relation(Date(), name='new_arg_a') MyEntity.add_relation(Int(), name='new_arg_b') MyEntity.add_relation(SubjectRelation('MyOtherEntity'), name="new_sub") MyOtherEntity.add_relation(SubjectRelation('MyEntity'), name="new_o_obj") class new_obj(RelationDefinition): subject = 'MyOtherEntity' object = 'MyEntity' class new_o_sub(RelationDefinition): subject = 'MyEntity' object = 'MyOtherEntity' schema = build_schema_from_namespace(locals().items()) self.assertIn('MyEntity', schema.entities()) my_entity = schema['MyEntity'] attributes_def = my_entity.attribute_definitions() attributes = sorted(attr[0].type for attr in attributes_def) self.assertEqual(['base_arg_a', 'base_arg_b', 'new_arg_a', 'new_arg_b'], attributes) relations_def = my_entity.relation_definitions() relations = sorted( rel[0].type for rel in relations_def) self.assertEqual(['base_o_obj', 'base_o_sub', 'base_obj', 'base_sub', 'new_o_obj', 'new_o_sub', 'new_obj', 'new_sub'], relations)
class ScoreValue(EntityType): text = String(maxsize=2048, fulltextindexed=True) value = Float(indexed=True) datetime = Date()
class Occasion(EntityType): type = String(maxsize=255, required=True, fulltextindexed=True) date = Date() remarques = RichString(fulltextindexed=True, default_format='text/rest')
class AchatPretPorter(EntityType): date_achat = Date() quantite = Float() quantite_plusieurs = Boolean(default=False, required=True, description='True if quantite is "plusieurs"') parure = SubjectRelation('Parure', cardinality='1*', inlined=True) remarques = RichString(fulltextindexed=True, default_format='text/rest')