def quest(request, short_id, slug=None): quest = get_object_or_404(Quest, id=base36decode_or_404(short_id)) _slug = slugify(quest.title) if _slug and _slug != slug: return redirect('quest', base36encode(quest.id), _slug) quest_details = quest.details() ctx = { 'quest': quest_details, 'comments': top_gallery_comments(quest, include_reactions=False), 'quest_template_url': '', 'original_quest_template_url': '', } if quest.reply_content_id: 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('quests/quest.html', ctx, request)
def news_img(url): token = os.path.basename(urlparse.urlparse(url).path) if "reply" in url: post_id = int(token) else: post_id = util.base36decode_or_404(token) img_url = Comment.details_by_id(post_id)()['reply_content']['thumbnail']['name'] return "<a href='%s'><img src='http://example.com/ugc/%s'></a>" % (url, img_url)
def news_img(url): token = os.path.basename(urlparse.urlparse(url).path) if "reply" in url: post_id = int(token) else: post_id = util.base36decode_or_404(token) img_url = Comment.details_by_id( post_id)()['reply_content']['thumbnail']['name'] return "<a href='%s'><img src='http://example.com/ugc/%s'></a>" % (url, img_url)
def get_img_url(url, image_size="thumbnail"): token = os.path.basename(urlparse.urlparse(url).path) if "reply" in url: post_id = int(token) else: post_id = util.base36decode_or_404(token) try: img_url = Comment.details_by_id(post_id)().reply_content[image_size]['name'] except (KeyError, Comment.DoesNotExist): img_url = "" return img_url
def news_img(url): token = os.path.basename(urlparse.urlparse(url).path) if "reply" in url: post_id = int(token) else: post_id = util.base36decode_or_404(token) try: comment_details = Comment.details_by_id(post_id)() img_url = comment_details.reply_content['thumbnail']['name'] url = comment_details.url except (KeyError, Comment.DoesNotExist): img_url = "" return "<a href='%s'><img class='content' src='%s'></a>" % (url, img_url)
def shared_url(request, share_id): share = get_object_or_404(ShareTrackingUrl, id=base36decode_or_404(share_id)) share.record_view(request) return HttpResponseRedirect(share.redirect_url)