def base_create_dep_objs(cls): """ Create all objects that Files depend on. """ cite1 = Citations() TestCitations.base_create_dep_objs() cite1.from_hash(SAMPLE_CITATION_HASH) cite1.save(force_insert=True) contrib = Contributors() TestContributors.base_create_dep_objs() contrib.from_hash(SAMPLE_CONTRIBUTOR_HASH) contrib.save(force_insert=True)
def from_hash(self, obj): """Convert the hash into the object.""" super(CitationContributor, self).from_hash(obj) if 'citation_id' in obj: self.citation = Citations.get(Citations.id == obj['citation_id']) if 'author_id' in obj: self.author = Contributors.get(Contributors.id == obj['author_id']) if 'author_precedence' in obj: self.author_precedence = int(obj['author_precedence'])
def from_hash(self, obj): """ Converts the hash into the object """ super(CitationContributor, self).from_hash(obj) if 'citation_id' in obj: self.citation = Citations.get(Citations.id == obj['citation_id']) if 'author_id' in obj: self.author = Contributors.get(Contributors.id == obj['author_id']) if 'author_precedence' in obj: self.author_precedence = int(obj['author_precedence'])
def where_clause(self, kwargs): """ Where clause for the various elements. """ where_clause = super(CitationContributor, self).where_clause(kwargs) if 'citation_id' in kwargs: citation = Citations.get(Citations.id == kwargs['citation_id']) where_clause &= Expression(CitationContributor.citation, OP.EQ, citation) if 'person_id' in kwargs: author = Contributors.get(Contributors.id == kwargs['author_id']) where_clause &= Expression(CitationContributor.author, OP.EQ, author) if 'author_precedence' in kwargs: auth_prec = int(kwargs['author_precedence']) where_clause &= Expression(CitationContributor.author_precedence, OP.EQ, auth_prec) return where_clause
def base_create_dep_objs(cls): """Create all objects that Files depend on.""" cite1 = Citations() TestCitations.base_create_dep_objs() cite1.from_hash(SAMPLE_CITATION_HASH) cite1.save(force_insert=True) contrib = Contributors() TestContributors.base_create_dep_objs() contrib.from_hash(SAMPLE_CONTRIBUTOR_HASH) contrib.save(force_insert=True)
def where_clause(self, kwargs): """Where clause for the various elements.""" where_clause = super(CitationContributor, self).where_clause(kwargs) if 'citation_id' in kwargs: citation = Citations.get(Citations.id == kwargs['citation_id']) where_clause &= Expression(CitationContributor.citation, OP.EQ, citation) if 'author_id' in kwargs: author = Contributors.get(Contributors.id == kwargs['author_id']) where_clause &= Expression(CitationContributor.author, OP.EQ, author) if 'author_precedence' in kwargs: auth_prec = int(kwargs['author_precedence']) where_clause &= Expression(CitationContributor.author_precedence, OP.EQ, auth_prec) return where_clause