def threaded_comment_json(comment, viewer): coll = ContentType.objects.get_for_model(Collaboration) all = ThreadedComment.objects.filter(content_type=coll, object_pk=comment.content_object.pk, site__pk=settings.SITE_ID) all = fill_tree(all) all = annotate_tree_properties(all) return { 'type': 'discussion', 'form': comments.get_form()(comment.content_object).__unicode__(), 'editing': True, 'can_edit': True, 'discussion': { 'id': comment.id, 'max_length': COMMENT_MAX_LENGTH, 'thread': [{ 'open': obj.open if hasattr(obj, "open") else None, 'close': [ i for i in obj.close ] if hasattr(obj, "close") else None, 'id': obj.id, 'author': obj.name, 'author_username': obj.user.username, 'submit_date': pretty_date(obj.submit_date), 'title': obj.title, 'content': obj.comment, 'can_edit': True if obj.user == viewer else False } for obj in all] } }
def threaded_comment_json(comment, viewer): coll = ContentType.objects.get_for_model(Collaboration) all = ThreadedComment.objects.filter( content_type=coll, object_pk=comment.content_object.pk, site__pk=settings.SITE_ID ) all = fill_tree(all) all = annotate_tree_properties(all) return { "type": "discussion", "form": comments.get_form()(comment.content_object).__unicode__(), "editing": True, "can_edit": True, "discussion": { "id": comment.id, "max_length": COMMENT_MAX_LENGTH, "thread": [ { "open": obj.open if hasattr(obj, "open") else None, "close": [i for i in obj.close] if hasattr(obj, "close") else None, "id": obj.id, "author": obj.name, "author_username": obj.user.username, "submit_date": pretty_date(obj.submit_date), "title": obj.title, "content": obj.comment, "can_edit": True if obj.user == viewer else False, } for obj in all ], }, }
def threaded_comment_json(request, comment): viewer = request.user coll = ContentType.objects.get_for_model(Collaboration) all_comments = ThreadedComment.objects.filter( content_type=coll, object_pk=comment.content_object.pk, site__pk=settings.SITE_ID) all_comments = fill_tree(all_comments) all_comments = list(annotate_tree_properties(all_comments)) rand = ''.join([choice(letters) for i in range(5)]) citations = threaded_comment_citations(all_comments, viewer) asset_resource = AssetResource() sherd_resource = SherdNoteResource() return { 'type': 'discussion', 'form': comments.get_form()(comment.content_object).__unicode__(), 'editing': True, 'can_edit': True, 'discussion': { 'id': comment.id, 'max_length': COMMENT_MAX_LENGTH, 'thread': [{ 'open': obj.open if hasattr(obj, "open") else None, 'close': [i for i in obj.close] if hasattr(obj, "close") else None, 'id': obj.id, 'author': obj.name, 'author_username': obj.user.username, 'submit_date': pretty_date(obj.submit_date), 'title': obj.title, 'content': obj.comment, 'can_edit': True if obj.user == viewer else False } for obj in all_comments] }, 'assets': dict([('%s_%s' % (rand, ann.asset.pk), asset_resource.render_one(request, ann.asset)) for ann in citations if (ann.title != "Annotation Deleted" and ann.title != 'Asset Deleted')]), 'annotations': [sherd_resource.render_one(request, ann, rand) for ann in citations], }
def threaded_comment_json(request, comment): viewer = request.user coll = ContentType.objects.get_for_model(Collaboration) all_comments = ThreadedComment.objects.filter( content_type=coll, object_pk=comment.content_object.pk, site__pk=settings.SITE_ID) all_comments = fill_tree(all_comments) all_comments = list(annotate_tree_properties(all_comments)) rand = ''.join([choice(letters) for i in range(5)]) citations = threaded_comment_citations(all_comments, viewer) asset_resource = AssetResource() sherd_resource = SherdNoteResource() return { 'type': 'discussion', 'form': django_comments.get_form()( comment.content_object).__unicode__(), 'editing': True, 'can_edit': True, 'discussion': { 'id': comment.id, 'max_length': COMMENT_MAX_LENGTH, 'thread': [{'open': obj.open if hasattr(obj, "open") else None, 'close': [i for i in obj.close] if hasattr(obj, "close") else None, 'id': obj.id, 'author': obj.name, 'author_username': obj.user.username, 'submit_date': pretty_date(obj.submit_date), 'title': obj.title, 'content': obj.comment, 'can_edit': True if obj.user == viewer else False} for obj in all_comments] }, 'assets': dict([('%s_%s' % (rand, ann.asset.pk), asset_resource.render_one(request, ann.asset)) for ann in citations if (ann.title != "Annotation Deleted" and ann.title != 'Asset Deleted')]), 'annotations': [sherd_resource.render_one(request, ann, rand) for ann in citations], }