Ejemplo n.º 1
0
 def base_create_dep_objs(cls):
     """
     Create all objects that Files depend on.
     """
     journal = Journals()
     TestJournals.base_create_dep_objs()
     journal.from_hash(SAMPLE_JOURNAL_HASH)
     journal.save(force_insert=True)
Ejemplo n.º 2
0
 def from_hash(self, obj):
     """
     Converts the object into the citation object fields.
     """
     super(Citations, self).from_hash(obj)
     if '_id' in obj:
         # pylint: disable=invalid-name
         self.id = int(obj['_id'])
         # pylint: enable=invalid-name
     if 'article_title' in obj:
         self.article_title = unicode(obj['article_title'])
     if 'journal_id' in obj:
         self.journal = Journals.get(Journals.id == int(obj['journal_id']))
     if 'journal_volume' in obj:
         self.journal_volume = int(obj['journal_volume'])
     if 'journal_issue' in obj:
         self.journal_issue = int(obj['journal_issue'])
     if 'page_range' in obj:
         self.page_range = str(obj['page_range'])
     if 'doi_reference' in obj:
         self.doi_reference = str(obj['doi_reference'])
     if 'xml_text' in obj:
         self.xml_text = unicode(obj['xml_text'])
     if 'release_authorization_id' in obj:
         self.release_authorization_id = str(obj['release_authorization_id'])
     if 'abstract_text' in obj:
         self.abstract_text = unicode(obj['abstract_text'])
     if 'encoding' in obj:
         self.encoding = str(obj['encoding'])
Ejemplo n.º 3
0
 def where_clause(self, kwargs):
     """Generate the PeeWee where clause used in searching."""
     where_clause = super(Citations, self).where_clause(kwargs)
     if 'journal_id' in kwargs:
         journal = Journals.get(Journals.id == int(kwargs['journal_id']))
         where_clause &= Expression(Citations.journal, OP.EQ, journal)
     if '_id' in kwargs:
         where_clause &= Expression(Citations.id, OP.EQ, int(kwargs['_id']))
     return self._where_attr_clause(where_clause, kwargs)
Ejemplo n.º 4
0
 def where_clause(self, kwargs):
     """
     Generate the PeeWee where clause used in searching.
     """
     where_clause = super(Citations, self).where_clause(kwargs)
     if 'journal_id' in kwargs:
         journal = Journals.get(Journals.id == int(kwargs['journal_id']))
         where_clause &= Expression(Citations.journal, OP.EQ, journal)
     if '_id' in kwargs:
         where_clause &= Expression(Citations.id, OP.EQ, int(kwargs['_id']))
     for key in ['article_title', 'journal_volume', 'journal_issue', 'page_range',
                 'doi_reference', 'encoding']:
         if key in kwargs:
             where_clause &= Expression(getattr(Citations, key), OP.EQ, kwargs[key])
     return where_clause
Ejemplo n.º 5
0
 def from_hash(self, obj):
     """Convert the object into the citation object fields."""
     super(Citations, self).from_hash(obj)
     self._set_only_if('_id', obj, 'id', lambda: int(obj['_id']))
     self._set_only_if(
         'journal_id', obj, 'journal',
         lambda: Journals.get(Journals.id == int(obj['journal_id'])))
     for key in ['journal_volume', 'journal_issue']:
         self._set_only_if(key, obj, key, lambda k=key: int(obj[k]))
     for key in [
             'page_range', 'release_authorization_id', 'encoding',
             'doi_reference'
     ]:
         self._set_only_if(key, obj, key, lambda k=key: str(obj[k]))
     for key in ['article_title', 'xml_text', 'abstract_text']:
         self._set_only_if(key,
                           obj,
                           key,
                           lambda k=key: unicode_type(obj[k]))
Ejemplo n.º 6
0
 def base_create_dep_objs(cls):
     """Create all objects that Files depend on."""
     journal = Journals()
     TestJournals.base_create_dep_objs()
     journal.from_hash(SAMPLE_JOURNAL_HASH)
     journal.save(force_insert=True)