def share_page(request, short_id): try: comment_id = get_mapping_id_from_short_id(short_id) except ValueError: raise Http404 comment = get_object_or_404(QuestComment, id=comment_id) comment_details = comment.details() quest_details = QuestDetails.from_id(comment_details.quest_id) author_details = UserDetails.from_id(comment.author_id) ctx = { "quest": quest_details, "quest_template_url": "", "comment": comment_details, "author": author_details, "private_profile": bool(UserKV(comment.author_id).web_profile_privacy.get()), } if quest_details.content: ctx.update( { "quest_template_url": quest_details.content.get_absolute_url_for_image_type("gallery"), "original_quest_template_url": quest_details.content.get_absolute_url_for_image_type("original"), } ) return r2r_jinja("quest_comments/share_comment_page.html", ctx, request)
def quest_comment(request, comment_id): comment = QuestCommentDetails.from_id(comment_id) quest = QuestDetails.from_id(comment.quest_id) if request.user.is_authenticated(): comment.user.viewer_is_following = comment.user.id in request.user.following_ids() add_viewer_has_starred_field([comment], viewer=request.user) return { 'comment': comment, 'quest': quest, }
def share_comment_by_email(comment, sender, recipients): from drawquest.apps.quests.details_models import QuestDetails quest_details = QuestDetails.from_id(comment.parent_comment_id) template_url = "" if quest_details.content: template_url = quest_details.content.gallery["url"] return _share_by_email( sender, recipients, _("Someone shared a drawing with you on DrawQuest!"), "comment_share", {"comment": comment.details(), "quest": quest_details, "quest_template_url": template_url}, )
def share_page(request, short_id): try: comment_id = get_mapping_id_from_short_id(short_id) except ValueError: raise Http404 comment = get_object_or_404(QuestComment, id=comment_id) comment_details = comment.details() quest_details = QuestDetails.from_id(comment_details.quest_id) author_details = UserDetails.from_id(comment.author_id) return r2r_jinja('quest_comments/share_page.html', { 'quest': quest_details, 'comment': comment_details, 'author': author_details, }, request)
def get_share_page_url(comment_details): if getattr(comment_details, 'ugq', False) or isinstance(comment_details, QuestDetails): obj = QuestDetails.from_id(comment_details.id) else: obj = QuestCommentDetails.from_id(comment_details.id) return obj.share_page_url