-
Notifications
You must be signed in to change notification settings - Fork 16
/
journal.py
56 lines (47 loc) · 1.6 KB
/
journal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from portality import models
from portality.api.current.data_objects.common_journal_application import OutgoingCommonJournalApplication, _SHARED_STRUCT
# we only have outgoing journals for the moment
from portality.lib.coerce import COERCE_MAP
JOURNAL_STRUCT = {
"objects": ["bibjson", "admin"],
"fields": {
"id": {"coerce": "unicode"},
"created_date": {"coerce": "utcdatetime"},
"last_updated": {"coerce": "utcdatetime"},
"last_manual_update": {"coerce": "utcdatetime"},
"es_type": {"coerce": "unicode"}
},
"structs": {
"admin": {
"fields": {
"in_doaj": {"coerce": "bool", "get__default": False},
"ticked": {"coerce": "bool", "get__default": False},
"seal": {"coerce": "bool", "get__default": False}
}
}
}
}
class OutgoingJournal(OutgoingCommonJournalApplication):
"""
~~APIOutgoingJournal:Model->APIOutgoingCommonJournalApplication:Model~~
~~->Journal:Model~~
"""
__SEAMLESS_COERCE__ = COERCE_MAP
__SEAMLESS_STRUCT__ = [
JOURNAL_STRUCT,
_SHARED_STRUCT
]
def __init__(self, raw=None, **kwargs):
super(OutgoingJournal, self).__init__(raw, silent_prune=True, **kwargs)
@classmethod
def from_model(cls, jm):
assert isinstance(jm, models.Journal)
d = super(OutgoingJournal, cls).from_model(jm)
return d
@classmethod
def from_model_by_id(cls, id_):
j = models.Journal.pull(id_)
return cls.from_model(j)
@property
def data(self):
return self.__seamless__.data