-
Notifications
You must be signed in to change notification settings - Fork 2
/
prizes.py
28 lines (20 loc) · 806 Bytes
/
prizes.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
from .data import NobelObject
__all__ = ['Prize']
class Prize(NobelObject):
"""Nobel Prize."""
attributes = ('category', 'year', 'laureates', 'motivation')
unique_together = ('category', 'year',)
resource = 'prize'
resource_plural = 'prizes'
@classmethod
def _parse(cls, data, full=False):
obj = super(Prize, cls)._parse(data, full)
obj.year = int(data['year'])
if 'laureates' in data:
obj.laureates = [cls.api.laureates._parse(l, full=False)
for l in data['laureates']]
if 'motivation' in data['laureates'][0]:
obj.motivation = data['laureates'][0]['motivation']
return obj
def __unicode__(self):
return u"%s, %d" % (self.category.capitalize(), self.year)