def __init__(self, person): self.p = self.person = person birth_min, birth_max, death_min, death_max = self.merged_biography._get_min_max_dates() self.geboortedatum_min = format_date(birth_min) self.geboortedatum_max = format_date(birth_max) self.sterfdatum_min = format_date(death_min) self.sterfdatum_max = format_date(death_max) self.geboorteplaats = self.merged_biography.get_value("geboorteplaats") self.sterfplaats = self.merged_biography.get_value("sterfplaats") self.names = u" ".join([unicode(name) for name in self._names]) self.has_contradictions = bool(person.get_biography_contradictions()) illustrations = self.merged_biography.get_illustrations() illustration = illustrations and illustrations[0] if illustration: url = illustration.image_small_url url = url[len(illustration._images_cache_url) :] if url.startswith("/"): url = url[1:] self.thumbnail = url else: self.thumbnail = ""
def test_format_date(self): d = datetime.datetime(1700, 3, 2) self.assertEqual(format_date(d), "1700-03-02 00:00") d = datetime.datetime(1, 3, 2) self.assertEqual(format_date(d), "0001-03-02 00:00")