Coverage for portality/api/current/client/models.py: 31%

35 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-07-20 16:12 +0100

1from portality.api.current.data_objects.journal import OutgoingJournal 

2from portality.api.current.data_objects.article import IncomingArticleDO 

3 

4 

5class Journal(OutgoingJournal): 

6 

7 def all_issns(self): 

8 issns = [] 

9 for _ident in ('pissn', 'eissn'): 

10 if self.data.get('bibjson', {}).get(_ident) is not None: 

11 issns.append(self.data['bibjson'][_ident]) 

12 return issns 

13 

14 

15class Article(IncomingArticleDO): 

16 

17 def add_identifier(self, _type, _id): 

18 if _type is None or _id is None: 

19 return 

20 self._add_to_list("bibjson.identifier", {"type": _type, "id": _id}) 

21 

22 def get_identifier(self, _type): 

23 for _id in self._get_list("bibjson.identifier"): 

24 if _id.get("type") == _type: 

25 return _id.get("id") 

26 return None 

27 

28 def add_link(self, _type, url): 

29 if type is None or url is None: 

30 return 

31 self._add_to_list("bibjson.link", {"type": _type, "url": url}) 

32 

33 def get_link(self, _type): 

34 for link in self._get_list("bibjson.link"): 

35 if link.get("type") == _type: 

36 return link.get("url") 

37 return None 

38 

39 def add_author(self, name): 

40 if name is None: 

41 return 

42 self._add_to_list("bibjson.author", {"name": name}) 

43 

44 def is_api_valid(self): 

45 self.check_construct() 

46 self.custom_validate()