def json(self, request, serialize=True, include_pages=True): j = { "date_issued": strftime(self.date_issued, "%Y-%m-%d"), "url": request.build_absolute_uri(self.json_url), "volume": self.volume, "number": self.number, "edition": self.edition, "title": { "name": self.title.display_name, "url": request.build_absolute_uri(self.title.json_url), }, "batch": { "name": self.batch.name, "url": request.build_absolute_uri(self.batch.json_url) }, } j["pages"] = [{ "url": request.build_absolute_uri(p.json_url), "sequence": p.sequence } for p in self.pages.all()] if serialize: return json.dumps(j) return j
def json(self, request, include_issues=True, serialize=True): b = {} b["name"] = self.name b["ingested"] = rfc3339(self.created) b["page_count"] = self.page_count b["lccns"] = self.lccns() b["awardee"] = { "name": self.awardee.name, "url": request.build_absolute_uri(self.awardee.json_url) } b["url"] = request.build_absolute_uri(self.json_url) if include_issues: b["issues"] = [] for issue in self.issues.prefetch_related("title"): i = { "title": { "name": issue.title.display_name, "url": request.build_absolute_uri(issue.title.json_url), }, "date_issued": strftime(issue.date_issued, "%Y-%m-%d"), "url": request.build_absolute_uri(issue.json_url), } b["issues"].append(i) if serialize: return json.dumps(b) else: return b
def json(self, request, serialize=True): j = { "url": request.build_absolute_uri(self.json_url), "lccn": self.lccn, "name": self.display_name, "place_of_publication": self.place_of_publication, "publisher": self.publisher, "start_year": self.start_year, "end_year": self.end_year, "subject": list(self.subjects.values_list("heading", flat=True)), "place": list(self.places.values_list("name", flat=True)), "issues": [{ "url": request.build_absolute_uri(i.json_url), "date_issued": strftime(i.date_issued, "%Y-%m-%d"), } for i in self.issues.all()], } if serialize: return json.dumps(j) return j
def json(self, serialize=True, include_pages=True, host='chroniclingamerica.loc.gov'): j = { 'url': 'http://' + host + self.json_url, 'date_issued': strftime(self.date_issued, "%Y-%m-%d"), 'volume': self.volume, 'number': self.number, 'edition': self.edition, 'title': { "name": self.title.display_name, "url": 'http://' + host + self.title.json_url }, 'batch': { "name": self.batch.name, "url": 'http://' + host + self.batch.json_url }, } j['pages'] = [{ "url": "http://" + host + p.json_url, "sequence": p.sequence } for p in self.pages.all()] if serialize: return json.dumps(j, indent=2) return j
def json(self, include_issues=True, serialize=True, host="chroniclingamerica.loc.gov"): b = {} b['name'] = self.name b['ingested'] = rfc3339(self.created) b['page_count'] = self.page_count b['lccns'] = self.lccns() b['awardee'] = { "name": self.awardee.name, "url": "http://" + host + self.awardee.json_url } b['url'] = "http://" + host + self.json_url if include_issues: b['issues'] = [] for issue in self.issues.all(): i = { "title": { "name": issue.title.display_name, "url": "http://" + host + issue.title.json_url, }, "date_issued": strftime(issue.date_issued, "%Y-%m-%d"), "url": "http://" + host + issue.json_url } b['issues'].append(i) if serialize: return json.dumps(b) else: return b
def json(self, serialize=True, host="chroniclingamerica.loc.gov"): j = { "url": "http://" + host + self.json_url, "lccn": self.lccn, "name": self.display_name, "place_of_publication": self.place_of_publication, "publisher": self.publisher, "start_year": self.start_year, "end_year": self.end_year, "subject": [s.heading for s in self.subjects.all()], "place": [p.name for p in self.places.all()], "issues": [{ "url": "http://" + host + i.json_url, "date_issued": strftime(i.date_issued, "%Y-%m-%d") } for i in self.issues.all()] } if serialize: return json.dumps(j, indent=2) return j
def __unicode__(self): parts = [u"%s" % self.issue.title] # little hack to get django's datetime support for stftime # when the year is < 1900 parts.append(strftime(self.issue.date_issued, "%B %d, %Y")) if self.issue.edition_label: parts.append(self.issue.edition_label) if self.section_label: parts.append(self.section_label) parts.append("Image %s" % self.sequence) return u", ".join(parts)
def __unicode__(self): parts = [u'%s' % self.issue.title] # little hack to get django's datetime support for stftime # when the year is < 1900 parts.append(strftime(self.issue.date_issued, '%B %d, %Y')) if self.issue.edition_label: parts.append(self.issue.edition_label) if self.section_label: parts.append(self.section_label) parts.append('Image %s' % self.sequence) return u', '.join(parts)
def json(self, serialize=True, host="chroniclingamerica.loc.gov"): j = { "sequence": self.sequence, "issue": {"date_issued": strftime(self.issue.date_issued, "%Y-%m-%d"), "url": "http://" + host + self.issue.json_url}, "jp2": "http://" + host + self.jp2_url, "ocr": "http://" + host + self.ocr_url, "text": "http://" + host + self.txt_url, "pdf": "http://" + host + self.pdf_url, "title": {"name": self.issue.title.display_name, "url": "http://" + host + self.issue.title.json_url} } if serialize: return json.dumps(j, indent=2) return j
def json(self, serialize=True, include_pages=True, host='chroniclingamerica.loc.gov'): j = { 'url': 'http://' + host + self.json_url, 'date_issued': strftime(self.date_issued, "%Y-%m-%d"), 'volume': self.volume, 'edition': self.edition, 'title': {"name": self.title.display_name, "url": 'http://' + host + self.title.json_url}, 'batch': {"name": self.batch.display_name, "url": 'http://' + host + self.batch.json_url}, } j['pages'] = [{"url": "http://" + host + p.json_url, "sequence": p.sequence} for p in self.pages.all()] if serialize: return json.dumps(j, indent=2) return j
def json(self, serialize=True, host="chroniclingamerica.loc.gov"): j = { "url": "http://" + host + self.json_url, "lccn": self.lccn, "name": self.name, "place_of_publication": self.place_of_publication, "publisher": self.publisher, "start_year": self.start_year, "end_year": self.end_year, "subject": [s.heading for s in self.subjects.all()], "place": [p.name for p in self.places.all()], "issues": [{"url": "http://" + host + i.json_url, "date_issued": strftime(i.date_issued, "%Y-%m-%d")} for i in self.issues.all()] } if serialize: return json.dumps(j, indent=2) return j
def json(self, serialize=True, host="chroniclingamerica.loc.gov"): j = { "sequence": self.sequence, "issue": { "date_issued": strftime(self.issue.date_issued, "%Y-%m-%d"), "url": "http://" + host + self.issue.json_url}, "jp2": "http://" + host + self.jp2_url, "ocr": "http://" + host + self.ocr_url, "text": "http://" + host + self.txt_url, "pdf": "http://" + host + self.pdf_url, "title": { "name": self.issue.title.display_name, "url": "http://" + host + self.issue.title.json_url} } if serialize: return json.dumps(j, indent=2) return j
def json(self, request, serialize=True): j = { "sequence": self.sequence, "issue": { "date_issued": strftime(self.issue.date_issued, "%Y-%m-%d"), "url": request.build_absolute_uri(self.issue.json_url), }, "jp2": request.build_absolute_uri(self.jp2_url), "ocr": request.build_absolute_uri(self.ocr_url), "text": request.build_absolute_uri(self.txt_url), "pdf": request.build_absolute_uri(self.pdf_url), "title": { "name": self.issue.title.display_name, "url": request.build_absolute_uri(self.issue.title.json_url), }, } if serialize: return json.dumps(j) return j
def json(self, serialize=True, host="chroniclingamerica.loc.gov"): j = { "sequence": self.sequence, "issue": { "date_issued": strftime(self.issue.date_issued, "%Y-%m-%d"), "url": "http://" + host + self.issue.json_url }, "title": { "name": self.issue.title.display_name, "url": "http://" + host + self.issue.title.json_url } } if self.issue.batch.api_available: j["iiif"] = self.iiif_url + '/info.json' j["ocr"] = "https://" + host + self.ocr_url j["text"] = "https://" + host + self.txt_url j["pdf"] = "https://" + host + self.pdf_url if serialize: return json.dumps(j, indent=2) return j