def to_dict(self): return { 'id': self.pk, 'scan_id': self.scan_id, 'type': self.type, 'title': self.title, 'affiliation': self.affiliation.to_dict() if self.affiliation else None, 'body': self.body, 'adult': self.adult, 'in_reply_to': self.in_reply_to.code if self.in_reply_to else None, 'reply_code': self.reply_code.code, 'author': self.author.profile.to_dict(), 'date_written': self.date_written.isoformat() if self.date_written else None, 'highlight': self.highlight.url if self.highlight else None, 'highlight_transform': json.loads(self.highlight_transform) if self.highlight_transform else "", 'status': self.status, 'pdf': self.pdf.url if self.pdf else None, 'public_pdf': public_url(self.pdf.url) if self.pdf else None, 'editor': self.editor.profile.to_dict(), 'created': self.created.isoformat(), 'modified': self.modified.isoformat(), 'pages': [p.to_dict() for p in self.documentpage_set.all()], 'tags': ";".join([t.name for t in self.tags.all()]), 'url': self.get_absolute_url(), 'edit_url': self.get_edit_url(), 'comment_count': self.comments.count(), 'notes_count': self.notes.count(), 'is_public': self.is_public(), }
def to_dict(self): return { 'id': self.pk, 'scan_id': self.scan_id, 'type': self.type, 'title': self.title, 'affiliation': self.affiliation.to_dict() if self.affiliation else None, 'body': self.body, 'adult': self.adult, 'in_reply_to': self.in_reply_to.code if self.in_reply_to else None, 'reply_code': self.reply_code.code, 'author': self.author.profile.to_dict(), 'date_written': self.date_written.isoformat() if self.date_written else None, 'highlight': self.highlight.url if self.highlight else None, 'highlight_transform': json.loads(self.highlight_transform) if self.highlight_transform else "", 'status': self.status, 'pdf': self.pdf.url if self.pdf else None, 'public_pdf': public_url(self.pdf.url) if self.pdf else None, 'editor': self.editor.profile.to_dict(), 'created': self.created.isoformat(), 'modified': self.modified.isoformat(), 'pages': [p.to_dict() for p in self.documentpage_set.all()], 'tags': ";".join([t.name for t in self.tags.all()]), 'url': self.get_absolute_url(), 'edit_url': self.get_edit_url(), 'comment_count': self.comments.count(), 'notes_count': self.notes.count(), 'is_public': self.is_public(), }
def to_dict(self): return { 'id': self.pk, 'document_id': self.document_id, 'scan_page': self.scan_page.to_dict(), 'order': self.order, 'image': self.image.url if self.image else None, 'public_image': public_url(self.image.url) if self.image else None, 'transformations': json.loads(self.transformations) if self.transformations else "", }
def to_dict(self): return { 'id': self.pk, 'document_id': self.document_id, 'scan_page': self.scan_page.to_dict(), 'order': self.order, 'image': self.image.url if self.image else None, 'public_image': public_url(self.image.url) if self.image else None, 'transformations': json.loads(self.transformations) if self.transformations else "", }
def full_posts_feed(request, context): feed = _feed(request, title=context['title'], klass=Atom1FeedWithImages) for post in context['posts'][:10]: profile = post.author.profile descr = render_to_string("blogs/_full_post_feed.html", { "post": post, "profile": profile, }, context_instance=RequestContext(request)) try: tx = post.transcription tx_current = tx.current() except (Transcription.DoesNotExist, AttributeError): tx = None tx_current = None if tx and tx_current: tx_body = tx_current.body tx_status = "complete" if tx.complete else "partial" else: tx_body = "" tx_status = "missing" feed.add_item( title=post.get_title(), #HACK -- making URLs absolute # make an absolute link to get a valid TAG URI fails if a port is # included with domain (see Django bug #8758). link=feed.site_base + post.get_absolute_url()[1:], description=descr, author_name=profile.display_name, author_link=profile.get_absolute_url(), pubdate=post.date_written, images=[ site_url(public_url(p.image.url)) for p in post.documentpage_set.all() ], transcription=tx_body, transcription_status=tx_status) response = HttpResponse(mimetype=feed.mime_type) feed.write(response, 'utf-8') return response
def full_posts_feed(request, context): feed = _feed(request, title=context['title'], klass=Atom1FeedWithImages) for post in context['posts'][:10]: profile = post.author.profile descr = render_to_string("blogs/_full_post_feed.html", { "post": post, "profile": profile, }, context_instance=RequestContext(request)) try: tx = post.transcription tx_current = tx.current() except (Transcription.DoesNotExist, AttributeError): tx = None tx_current = None if tx and tx_current: tx_body = tx_current.body tx_status = "complete" if tx.complete else "partial" else: tx_body = "" tx_status = "missing" feed.add_item( title=post.get_title(), #HACK -- making URLs absolute # make an absolute link to get a valid TAG URI fails if a port is # included with domain (see Django bug #8758). link=feed.site_base + post.get_absolute_url()[1:], description=descr, author_name=profile.display_name, author_link=profile.get_absolute_url(), pubdate=post.date_written, images=[site_url(public_url(p.image.url)) for p in post.documentpage_set.all()], transcription=tx_body, transcription_status=tx_status ) response = HttpResponse(mimetype=feed.mime_type) feed.write(response, 'utf-8') return response