def about(request): peeps = [] comments = [] for short_id in settings.ABOUT_PAGE_COMMENTS: mapping_id = get_mapping_id_from_short_id(short_id) comment = get_object_or_404(Comment.all_objects, id=mapping_id) comments.append(comment) peeps.append(TileDetails(comment.details())) tiles = TileDetails.from_queryset_with_viewer_stickers(request.user, comments) sort = None show_pins = False render_options = tile_render_options(sort, show_pins) return r2r_jinja("about.html", locals())
def test_from_queryset_with_pins(self): self.assertTrue(self.comments) tiles = TileDetails.from_queryset_with_pins(self.comments) self.assertTrue(tiles) for tile in tiles: self.assertNotEqual(tile.pins, None) self.assertIsInstance(tile.comment, CommentDetails)
def view_thread_more(request, ids, tile_renderer="jinja_thread_page_tiles"): tiles = [ TileDetails(reply.details()) for reply in Comment.visible.in_bulk(ids).itervalues() ] from canvas.templatetags.jinja_tags import jinja_thread_page_tile tiles = ''.join( jinja_thread_page_tile(dict(request=request), tile) for tile in tiles) return HttpResponse(tiles)
def popup_thread_posted(request): ctx = {} comment = get_object_or_404(Comment.all_objects, pk=request.GET.get('comment')) comment_details = comment.details() tile = TileDetails(comment_details) thumbnail = comment_details.reply_content.get_absolute_url_for_image_type( 'stream') ctx.update({ 'comment': comment_details, 'tile': tile, 'thumbnail_url': thumbnail, }) return r2r_jinja('post_thread/popup_thread_posted.html', ctx, request)
def tiles(): return TileDetails.from_queryset_with_viewer_stickers(user, self.comments)
def tiles(): return TileDetails.from_queryset_with_viewer_stickers( user, self.comments)
def view(request, short_id, option=None): from apps.monster.jinja_tags import monster_image_tile view_data = CommentViewData(request, short_id) main_comment = view_data.op_comment replies = [Comment.details_by_id(cid) for cid in view_data.reply_ids] has_replies = len(replies) > 0 complete_link = option and (option == 'complete') if complete_link and request.user.is_anonymous(): fact.record('monster_start_flow', request, {'monster_id': short_id}) reply_id = None if option: try: reply_id = int(option) except ValueError: pass ( (main_comment,), replies ) = CachedCall.many_multicall( [main_comment], replies, ) replies = [reply for reply in replies if not reply.is_collapsed] monster_part = MonsterPart.get_by_comment(main_comment) main_comment_details = main_comment main_comment = TileDetails(main_comment) made_bottom = False made_top = main_comment.comment.real_author == request.user.username linked_monster_footer_image = "" current_monster_index = 0 for i in range(len(replies)): reply = replies[i] if reply_id is not None and reply.id == int(reply_id): current_monster_index = i elif reply.real_author == request.user.username and reply_id is None: current_monster_index = i made_bottom = True try: if (has_replies and replies[current_monster_index].reply_content and replies[current_monster_index].reply_content.footer): linked_monster_footer_image = replies[current_monster_index].reply_content.footer['name'] except (AttributeError, IndexError): pass made_part = made_top or made_bottom if made_part: CompletedMonsterSet(request.user).sadd(main_comment.comment.id) can_make_bottom = (not made_part) and complete_link can_invite = made_top # incomplete monster without an invite link, send to monster index if not has_replies and not complete_link and not can_invite: return HttpResponseRedirect('/monster') ctx = { 'can_invite': can_invite, 'can_make_bottom': can_make_bottom, 'current_monster_index': current_monster_index, 'domain': settings.DOMAIN, 'made_bottom': made_bottom, 'made_part': made_part, 'made_top': made_top, 'main_comment': main_comment, 'monster_content': main_comment.comment.reply_content, 'og_image_url': linked_monster_footer_image.replace("https", "http", 1), 'monster_group': MONSTER_GROUP, 'monster_name': main_comment.comment.title, 'replies': MonsterTileDetails.from_shared_op_details_with_viewer_stickers(request.user, main_comment_details, replies), 'request': request, 'short_id': main_comment.comment.short_id(), 'start_content': Content.all_objects.get(id=Content.SMALL_DRAW_FROM_SCRATCH_PK).details(), } return r2r_jinja('monster/view.html', ctx)