Exemple #1
0
class ModMixin(_Model):
    count = LongType()

    liked = ListType(ObjectIdType(ObjectId))
    # create RatingType
    # https   ://developers.google.com/gdata/docs/2.0/elements#gdRating
    rating = IntType()
    followers = ListType(ObjectIdType(ObjectId))
    favorited = ListType(ObjectIdType(ObjectId))

    reviews = ListType(ModelType(Review))

    tags = ListType(ModelType(Tag))

    tels = ListType(ModelType(Tel), description='Telephones')
    emails = ListType(ModelType(Email), description='Emails')
    ims = ListType(ModelType(Im), description='Instant Message Network')

    urls = ListType(URLType(), description='Urls associated with this doc.')
    rdts = ListType(ModelType(Rdt))
    desc = StringType(description='Description')
    notes = ListType(ModelType(Note))

    shrs = ListType(
        ModelType(Shr),
        description=
        'Share List of Share docs that describe who and at what level/role this doc is shared with.'
    )

    # tos     : ie, parents
    tos = ListType(ModelType(Pth))

    # frs     : froms, ie, children
    frCount = IntType()
    frs = ListType(ModelType(Pth))
Exemple #2
0
Fichier : dx.py Projet : mlys/gsapi
class Dx(Mod):
    '''Used to link two Models/Docs together along with reference to rel(ationship) description.
        '''
        fr_c     = ObjectIdType(ObjectId) # From/Subject Class
        fr_id    = ObjectIdType(ObjectId) # From/Subject ID
        
        to_c     = ObjectIdType(ObjectId) # To Parent Class
        to_id    = ObjectIdType(ObjectId) # Parent ID
        
        dxRel_id = ObjectIdType(ObjectId) # DxRel ID
        
        meta     = {
        'collection': 'dxs',
        '_c': 'Dx',
        }
Exemple #3
0
class Shr(Mod):
    '''Share'''
    # The reason for this parent field given the fact that Wid'gets can contain an array of other widgets is that OTHER Widgets may LINK to this widget AND add their Share properties. It is necessary
    parId = ObjectIdType(
        description='Parent Doc ID, Primary Parent owner of this doc.')

    # needed? Mod has oBy which is owner id
    usrId = ObjectIdType(description='Usr ID for this Share.')

    permission = StringType(
        description='Permission, a=At and Above, ab=At and below, b=Below.',
        choices=['a', 'ab', 'b'])

    meta = {
        '_c': 'Shr',
    }
Exemple #4
0
class Cnt(Mod):
    shares = ListType(ObjectIdType(ObjectId),
                      minimized_field_name='Share List',
                      description='List of Contacts shared with.')
    emails = ListType(ModelType(Email),
                      minimized_field_name='Emails',
                      description='Email addresses.')
    meta = {
        'collection': 'contacts',
        '_c': 'cnt',
    }
Exemple #5
0
Fichier : dx.py Projet : mlys/gsapi
class DRel(_Model):
    '''Doc Relationship 
    # In a list of (rel)ationships, ie, Companies (cmp), Persons (prs), Places (pl), Events (ev), etc, docC = the class so that client can retrieve place (rel)ationships for example.
       '''
    # QUESTION: needed? In an embedded list of DRel, and wanna update a specific one, this can be the key for the list
    dx_id      = ObjectIdType(ObjectId)

    # Doc Class is the doc Class of the immediate parent/to OR child/fr/from in the array/list of IDs/dRels
    d_c       = StringType(description='Document class of immediate parent/to OR child/fr")
    
    dRelTitle = StringType(description='Role/relationship/title')
    dRelNote  = StringType(description='Role/relationship description, ie, Job Description.')
    
    # List of Doc IDs in the relToFms list. This is used to quickly check whether a doc ID is referenced.
    # This should be reviewed for effeciency
    ids       = ListType(ObjectIdType(ObjectId))
    
    # List of (rel)ationship details
    dRelToFrs = ListType(ModelType(DRelToFr))
    
    # in a list of aPath's, sort list on this value to control order
    w         = FloatType(description='Sort weight value', description='')
Exemple #6
0
Fichier : dx.py Projet : mlys/gsapi
class DRelToFr(_Model):
    '''Doc Relation To and From
        To/Parent/Target/From/Child relationship details which are embedded into a ListType named tos and frs.
        ''' 
    # doc ID
    # 
    d_id    = ObjectIdType(ObjectId)
    
    # doc Class
    # ie, pl for Place
    d_c    = ObjectIdType(ObjectId)
    
    # doc Relation Display Name 
    # ie, Administrator
    dxNam  = StringType(description="Relation/Role")
    
    # doc Relation Display Name Short
    # ie, admin
    dxNamS = StringType(description="Relation/Role Short")
    
    ddNam  = StringType(description="Doc Display Name")
    ddNamS = StringType(description="Doc Display Name Short")
Exemple #7
0
class Mod(_Model):
    _c = StringType(required=True, description='Class')
    _public_fields = ['_c']
    oBy = ObjectIdType()
    oOn = DateTimeType()  # ObjectIdType()
    oLoc = StringType()
    cOn = DateTimeType()
    cBy = ObjectIdType()
    cLoc = StringType()
    mOn = DateTimeType()
    mBy = ObjectIdType()
    mLoc = StringType()
    dBy = ObjectIdType()
    dOn = DateTimeType()
    dLoc = StringType()
    note = StringType()

    meta = {
        'collection': 'contacts',
        '_c': 'Mod',
    }

    @classmethod
    def logit(self, user_id, method='post'):

        # Log this
        now = datetime.datetime.utcnow()

        if method == 'post':
            self.oBy = user_id
            self.oOn = now
            self.cBy = user_id
            self.cOn = now

        self.mBy = user_id
        self.mOn = now
Exemple #8
0
class Prs(Cnt):
    title = StringType(minimized_field_name='Title',
                       description='Examples: Mr, Mrs, Ms, etc')
    fNam = StringType()  #max_length=4
    fNam2 = StringType()
    lNam = StringType()
    lNam2 = StringType()
    suffix = StringType(minimized_field_name='Suffix',
                        description='Examples: MD, PHD, Jr, Sr, etc')
    gen = StringType(minimized_field_name='Gender',
                     choices=['m', 'f'],
                     description='Gender')
    rBy = ObjectIdType(
        minimized_field_name='Referred/Registered By',
        description='User that referred or registered this user.')

    meta = {
        'collection': 'contacts',
        '_c': 'Prs',
    }

    @property
    def dNam(self):
        return 'hello'

    def onUpdate(self):
        super(Prs, self).onUpdate()
        dnam = ''
        fNam = ''
        fNam += self.title + ' ' if self.title else ''
        fNam += self.fNam + ' ' if self.fNam else ''
        fNam += self.fNam2 + ' ' if self.fNam2 else ''
        fNam = fNam[:-1] if fNam else ''

        lNam = ''
        lNam += self.lNam + ' ' if self.lNam else ''
        lNam += self.lNam2 + ' ' if self.lNam2 else ''
        lNam += self.suffix + ' ' if self.suffix else ''
        lNam = lNam[:-1] if lNam else ''

        if lNam:
            dnam += lNam
            if fNam:
                dnam += ', ' + fNam
        elif fNam:
            dnam += fNam
        self.dnam = dnam
class MongoModel(Model):
    _id = ObjectIdType()
Exemple #10
0
class Prs(Cnt):
    '''https://developers.google.com/gdata/docs/2.0/elements#gdName'''

    # namePrefix
    prefix = StringType(description='Examples: Mr, Mrs, Ms, etc')

    # givenName
    fNam = StringType()

    # additionalName
    fNam2 = StringType()

    # givenName
    lNam = StringType()
    lNam2 = StringType()

    # nameSuffix
    suffix = StringType(description='Examples: MD, PHD, Jr, Sr, etc')
    gen = StringType(choices=['m', 'f'], description='Gender')
    rBy = ObjectIdType(
        description='User that referred or registered this user.')

    meta = {
        'collection': 'cnts',
        '_c': 'Prs',
    }

    @property
    def index(self):
        return {
            "dNam": self.dNam,
            "oOn": self.oOn,
        }

    @property
    def fullName(self):
        '''Mr Bill Wayne Smith Sr'''
        dNam = ''
        fNam = ''
        fNam += self.prefix + ' ' if self.prefix else ''
        fNam += self.fNam + ' ' if self.fNam else ''
        fNam += self.fNam2 + ' ' if self.fNam2 else ''
        fNam = fNam[:-1] if fNam else ''

        lNam = ''
        lNam += self.lNam + ' ' if self.lNam else ''
        lNam += self.lNam2 + ' ' if self.lNam2 else ''
        lNam += self.suffix + ' ' if self.suffix else ''
        lNam = lNam[:-1] if lNam else ''

        return fNam + (' ' + lNam if lNam else '')

    @property
    def vNam(self):
        '''Generate dNam, ie, Smith Sr, Mr Bill Wayne'''
        dNam = ''
        fNam = ''
        fNam += self.prefix + ' ' if self.prefix else ''
        fNam += self.fNam + ' ' if self.fNam else ''
        fNam += self.fNam2 + ' ' if self.fNam2 else ''
        fNam = fNam[:-1] if fNam else ''

        lNam = ''
        lNam += self.lNam + ' ' if self.lNam else ''
        lNam += self.lNam2 + ' ' if self.lNam2 else ''
        lNam += self.suffix + ' ' if self.suffix else ''
        lNam = lNam[:-1] if lNam else ''

        if lNam:
            dNam += lNam
            if fNam:
                dNam += ', ' + fNam
        elif fNam:
            dNam += fNam
        return dNam

    @property
    def vNamS(self):
        return self.dNam.lower().replace(' ', '_')