def base_create_dep_objs(cls):
     """
     Create all objects that Files depend on.
     """
     user = Users()
     TestUsers.base_create_dep_objs()
     user.from_hash(SAMPLE_USER_HASH)
     user.save(force_insert=True)
     inst = Institutions()
     TestInstitutions.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTITUTION_HASH)
     inst.save(force_insert=True)
 def base_create_dep_objs(cls):
     """
     Create all objects that InstitutionPerson need.
     """
     inst = Institutions()
     TestInstitutions.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTITUTION_HASH)
     inst.save(force_insert=True)
     user1 = Users()
     TestUsers.base_create_dep_objs()
     user1.from_hash(SAMPLE_USER_HASH)
     user1.save(force_insert=True)
Exemple #3
0
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(InstitutionPerson, self).from_hash(obj)
     if 'person_id' in obj:
         self.person = Users.get(Users.id == obj['person_id'])
     if 'institution_id' in obj:
         self.institution = Institutions.get(
             Institutions.id == obj['institution_id'])
Exemple #4
0
 def where_clause(self, kwargs):
     """Generate the PeeWee where clause used in searching."""
     where_clause = super(Contributors, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         user = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(Contributors.person, OP.EQ, user)
     if 'institution_id' in kwargs:
         inst = Institutions.get(Institutions.id == kwargs['institution_id'])
         where_clause &= Expression(Contributors.institution, OP.EQ, inst)
     return self._where_attr_clause(where_clause, kwargs)
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(InstitutionPerson, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         person = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(InstitutionPerson.person, OP.EQ, person)
     if 'institution_id' in kwargs:
         institution = Institutions.get(Institutions.id == kwargs['institution_id'])
         where_clause &= Expression(InstitutionPerson.institution, OP.EQ, institution)
     return where_clause
Exemple #6
0
 def from_hash(self, obj):
     """Convert the hash into the object fields."""
     super(Contributors, self).from_hash(obj)
     self._set_only_if('_id', obj, 'id', lambda: int(obj['_id']))
     for attr in ['first_name', 'middle_initial', 'last_name', 'dept_code']:
         self._set_only_if(attr, obj, attr, lambda k=attr: unicode_type(obj[k]))
     self._set_only_if('person_id', obj, 'person',
                       lambda: Users.get(Users.id == int(obj['person_id'])))
     self._set_only_if('institution_id', obj, 'institution',
                       lambda: Institutions.get(Institutions.id == int(obj['institution_id'])))
     self._set_only_if('encoding', obj, 'encoding', lambda: str(obj['encoding']))
 def from_hash(self, obj):
     """
     Converts the hash into the object
     """
     super(InstitutionPerson, self).from_hash(obj)
     if 'person_id' in obj:
         self.person = Users.get(Users.id == obj['person_id'])
     if 'institution_id' in obj:
         self.institution = Institutions.get(
             Institutions.id == obj['institution_id']
         )
 def where_clause(self, kwargs):
     """
     Where clause for the various elements.
     """
     where_clause = super(InstitutionPerson, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         person = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(InstitutionPerson.person, OP.EQ, person)
     if 'institution_id' in kwargs:
         institution = Institutions.get(Institutions.id == kwargs['institution_id'])
         where_clause &= Expression(InstitutionPerson.institution, OP.EQ, institution)
     return where_clause
 def base_create_dep_objs(cls):
     """Create all objects that InstitutionPerson need."""
     inst = Institutions()
     TestInstitutions.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTITUTION_HASH)
     inst.save(force_insert=True)
     user1 = Users()
     TestUsers.base_create_dep_objs()
     user1.from_hash(SAMPLE_USER_HASH)
     user1.save(force_insert=True)
Exemple #10
0
 def base_create_dep_objs(cls):
     """Create all objects that Files depend on."""
     user = Users()
     TestUsers.base_create_dep_objs()
     user.from_hash(SAMPLE_USER_HASH)
     user.save(force_insert=True)
     inst = Institutions()
     TestInstitutions.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTITUTION_HASH)
     inst.save(force_insert=True)
 def where_clause(self, kwargs):
     """
     Generate the PeeWee where clause used in searching.
     """
     where_clause = super(Contributors, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         user = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(Contributors.person, OP.EQ, user)
     if 'institution_id' in kwargs:
         inst = Institutions.get(Institutions.id == kwargs['institution_id'])
         where_clause &= Expression(Contributors.institution, OP.EQ, inst)
     for key in ['author_id', 'first_name', 'last_name', 'encoding'
                 'middle_initial', 'dept_code']:
         if key in kwargs:
             where_clause &= Expression(getattr(Contributors, key), OP.EQ, kwargs[key])
     return where_clause
 def from_hash(self, obj):
     """
     Convert the hash into the object fields.
     """
     super(Contributors, self).from_hash(obj)
     if '_id' in obj:
         # pylint: disable=invalid-name
         self.id = int(obj['_id'])
         # pylint: enable=invalid-name
     for attr in ['first_name', 'middle_initial', 'last_name', 'dept_code']:
         if attr in obj:
             setattr(self, attr, unicode(obj[attr]))
     if 'person_id' in obj:
         self.person = Users.get(Users.id == int(obj['person_id']))
     if 'institution_id' in obj:
         inst_bool = Institutions.id == int(obj['institution_id'])
         self.institution = Institutions.get(inst_bool)
     if 'encoding' in obj:
         self.encoding = str(obj['encoding'])