def base_create_dep_objs(cls):
     """
     Create all objects that InstrumentCustodian need.
     """
     inst = Instruments()
     TestInstruments.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTRUMENT_HASH)
     inst.save(force_insert=True)
     custodian = Users()
     TestUsers.base_create_dep_objs()
     custodian.from_hash(SAMPLE_USER_HASH)
     custodian.save(force_insert=True)
 def base_create_dep_objs(cls):
     """
     Create all objects that ProposalParticipant need.
     """
     prop3 = Proposals()
     TestProposals.base_create_dep_objs()
     prop3.from_hash(SAMPLE_PROPOSAL_HASH)
     prop3.save(force_insert=True)
     user = Users()
     TestUsers.base_create_dep_objs()
     user.from_hash(SAMPLE_USER_HASH)
     user.save(force_insert=True)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def base_create_dep_objs(cls):
     """
     Create all objects that UserGroup need.
     """
     member = Users()
     TestUsers.base_create_dep_objs()
     member.from_hash(SAMPLE_USER_HASH)
     member.save(force_insert=True)
     groups = Groups()
     TestGroups.base_create_dep_objs()
     groups.from_hash(SAMPLE_GROUP_HASH)
     groups.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)
Ejemplo n.º 6
0
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(UserGroup, self).from_hash(obj)
     if 'person_id' in obj:
         self.person = Users.get(Users.id == obj['person_id'])
     if 'group_id' in obj:
         self.group = Groups.get(Groups.id == obj['group_id'])
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(ProposalParticipant, self).from_hash(obj)
     if 'person_id' in obj:
         self.person = Users.get(Users.id == obj['person_id'])
     if 'proposal_id' in obj:
         self.proposal = Proposals.get(Proposals.id == obj['proposal_id'])
Ejemplo n.º 8
0
 def base_create_dep_objs(cls):
     """
     Build the object and make dependent user object.
     """
     submitter = Users()
     TestUsers.base_create_dep_objs()
     submitter.from_hash(SAMPLE_SUBMITTER_HASH)
     submitter.save(force_insert=True)
     prop = Proposals()
     TestProposals.base_create_dep_objs()
     prop.from_hash(SAMPLE_PROPOSAL_HASH)
     prop.save(force_insert=True)
     inst = Instruments()
     TestInstruments.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTRUMENT_HASH)
     inst.save(force_insert=True)
Ejemplo n.º 9
0
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(InstrumentCustodian, self).from_hash(obj)
     if 'instrument_id' in obj:
         self.instrument = Instruments.get(Instruments.id == obj['instrument_id'])
     if 'custodian_id' in obj:
         self.custodian = Users.get(Users.id == obj['custodian_id'])
Ejemplo n.º 10
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'])
Ejemplo n.º 11
0
 def from_hash(self, obj):
     """
     Converts the hash into the object
     """
     super(UserGroup, self).from_hash(obj)
     if 'person_id' in obj:
         self.person = Users.get(Users.id == obj['person_id'])
     if 'group_id' in obj:
         self.group = Groups.get(Groups.id == obj['group_id'])
 def from_hash(self, obj):
     """
     Converts the hash into the object
     """
     super(ProposalParticipant, self).from_hash(obj)
     if 'person_id' in obj:
         self.person = Users.get(Users.id == obj['person_id'])
     if 'proposal_id' in obj:
         self.proposal = Proposals.get(Proposals.id == obj['proposal_id'])
 def from_hash(self, obj):
     """
     Converts the hash into the object
     """
     super(InstrumentCustodian, self).from_hash(obj)
     if 'instrument_id' in obj:
         self.instrument = Instruments.get(Instruments.id == obj['instrument_id'])
     if 'person_id' in obj:
         self.custodian = Users.get(Users.id == obj['person_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
Ejemplo n.º 15
0
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(UserGroup, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         user = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(UserGroup.person, OP.EQ, user)
     if 'group_id' in kwargs:
         group = Groups.get(Groups.id == kwargs['group_id'])
         where_clause &= Expression(UserGroup.group, OP.EQ, group)
     return where_clause
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(InstrumentCustodian, self).where_clause(kwargs)
     if 'instrument_id' in kwargs:
         instrument = Instruments.get(Instruments.id == kwargs['instrument_id'])
         where_clause &= Expression(InstrumentCustodian.instrument, OP.EQ, instrument)
     if 'custodian_id' in kwargs:
         user = Users.get(Users.id == kwargs['custodian_id'])
         where_clause &= Expression(InstrumentCustodian.custodian, OP.EQ, user)
     return where_clause
 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']
         )
Ejemplo n.º 19
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 where_clause(self, kwargs):
     """
     Where clause for the various elements.
     """
     where_clause = super(ProposalParticipant, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         member = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(ProposalParticipant.person, OP.EQ, member)
     if 'proposal_id' in kwargs:
         proposal = Proposals.get(Proposals.id == kwargs['proposal_id'])
         where_clause &= Expression(ProposalParticipant.proposal, OP.EQ, proposal)
     return where_clause
 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
Ejemplo n.º 22
0
 def where_clause(self, kwargs):
     """
     Where clause for the various elements.
     """
     where_clause = super(UserGroup, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         user = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(UserGroup.person, OP.EQ, user)
     if 'group_id' in kwargs:
         group = Groups.get(Groups.id == kwargs['group_id'])
         where_clause &= Expression(UserGroup.group, OP.EQ, group)
     return where_clause
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(ProposalParticipant, self).where_clause(kwargs)
     if 'person_id' in kwargs:
         member = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(ProposalParticipant.person, OP.EQ,
                                    member)
     if 'proposal_id' in kwargs:
         proposal = Proposals.get(Proposals.id == kwargs['proposal_id'])
         where_clause &= Expression(ProposalParticipant.proposal, OP.EQ,
                                    proposal)
     return where_clause
 def where_clause(self, kwargs):
     """
     Where clause for the various elements.
     """
     where_clause = super(InstrumentCustodian, self).where_clause(kwargs)
     if 'instrument_id' in kwargs:
         instrument = Instruments.get(Instruments.id == kwargs['instrument_id'])
         where_clause &= Expression(InstrumentCustodian.instrument, OP.EQ, instrument)
     if 'person_id' in kwargs:
         user = Users.get(Users.id == kwargs['person_id'])
         where_clause &= Expression(InstrumentCustodian.custodian, OP.EQ, user)
     return where_clause
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(Transactions, self).from_hash(obj)
     if '_id' in obj:
         # pylint: disable=invalid-name
         self.id = int(obj['_id'])
         # pylint: enable=invalid-name
     if 'submitter' in obj:
         self.submitter = Users.get(Users.id == obj['submitter'])
     if 'instrument' in obj:
         self.instrument = Instruments.get(Instruments.id == obj['instrument'])
     if 'proposal' in obj:
         self.proposal = Proposals.get(Proposals.id == obj['proposal'])
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(Transactions, self).where_clause(kwargs)
     if '_id' in kwargs:
         where_clause &= Expression(Transactions.id, OP.EQ, kwargs['_id'])
     if 'submitter' in kwargs:
         user = Users.get(Users.id == kwargs['submitter'])
         where_clause &= Expression(Transactions.submitter, OP.EQ, user)
     if 'instrument' in kwargs:
         inst = Instruments.get(Instruments.id == kwargs['instrument'])
         where_clause &= Expression(Transactions.instrument, OP.EQ, inst)
     if 'proposal' in kwargs:
         prop = Proposals.get(Proposals.id == kwargs['proposal'])
         where_clause &= Expression(Transactions.proposal, OP.EQ, prop)
     return where_clause
Ejemplo n.º 27
0
 def from_hash(self, obj):
     """
     Converts the hash into the object
     """
     super(Transactions, self).from_hash(obj)
     if '_id' in obj:
         # pylint: disable=invalid-name
         self.id = int(obj['_id'])
         # pylint: enable=invalid-name
     if 'submitter' in obj:
         self.submitter = Users.get(Users.id == obj['submitter'])
     if 'instrument' in obj:
         self.instrument = Instruments.get(Instruments.id == obj['instrument'])
     if 'proposal' in obj:
         self.proposal = Proposals.get(Proposals.id == obj['proposal'])
Ejemplo n.º 28
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)
Ejemplo n.º 29
0
 def base_create_dep_objs(cls):
     """Create all objects that InstrumentCustodian need."""
     inst = Instruments()
     TestInstruments.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTRUMENT_HASH)
     inst.save(force_insert=True)
     custodian = Users()
     TestUsers.base_create_dep_objs()
     custodian.from_hash(SAMPLE_USER_HASH)
     custodian.save(force_insert=True)
 def base_create_dep_objs(cls):
     """Create all objects that ProposalParticipant need."""
     prop3 = Proposals()
     TestProposals.base_create_dep_objs()
     prop3.from_hash(SAMPLE_PROPOSAL_HASH)
     prop3.save(force_insert=True)
     user = Users()
     TestUsers.base_create_dep_objs()
     user.from_hash(SAMPLE_USER_HASH)
     user.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)
 def base_create_dep_objs(cls):
     """Create all objects that UserGroup need."""
     member = Users()
     TestUsers.base_create_dep_objs()
     member.from_hash(SAMPLE_USER_HASH)
     member.save(force_insert=True)
     groups = Groups()
     TestGroups.base_create_dep_objs()
     groups.from_hash(SAMPLE_GROUP_HASH)
     groups.save(force_insert=True)
Ejemplo n.º 33
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)
     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
Ejemplo n.º 34
0
 def where_clause(self, kwargs):
     """
     Where clause for the various elements.
     """
     where_clause = super(Transactions, self).where_clause(kwargs)
     if '_id' in kwargs:
         where_clause &= Expression(Transactions.id, OP.EQ, kwargs['_id'])
     if 'submitter' in kwargs:
         user = Users.get(Users.id == kwargs['submitter'])
         where_clause &= Expression(Transactions.submitter, OP.EQ, user)
     if 'instrument' in kwargs:
         inst = Instruments.get(Instruments.id == kwargs['instrument'])
         where_clause &= Expression(Transactions.instrument, OP.EQ, inst)
     if 'proposal' in kwargs:
         prop = Proposals.get(Proposals.id == kwargs['proposal'])
         where_clause &= Expression(Transactions.proposal, OP.EQ, prop)
     return where_clause
Ejemplo n.º 35
0
 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'])
 def base_create_dep_objs(cls):
     """Build the object and make dependent user object."""
     submitter = Users()
     TestUsers.base_create_dep_objs()
     submitter.from_hash(SAMPLE_SUBMITTER_HASH)
     submitter.save(force_insert=True)
     prop = Proposals()
     TestProposals.base_create_dep_objs()
     prop.from_hash(SAMPLE_PROPOSAL_HASH)
     prop.save(force_insert=True)
     inst = Instruments()
     TestInstruments.base_create_dep_objs()
     inst.from_hash(SAMPLE_INSTRUMENT_HASH)
     inst.save(force_insert=True)