def _assemble_inbox_data(request, entries, actor_streams, inbox_owner_ref): stream_keys = [e.stream for e in entries] stream_keys += [s.key().name() for s in actor_streams] streams = api.stream_get_streams(request.user, stream_keys) contact_nicks = api.actor_get_contacts_safe(request.user, inbox_owner_ref.nick, limit=CONTACTS_PER_PAGE) channel_nicks = api.actor_get_channels_member_safe(request.user, inbox_owner_ref.nick, limit=CHANNELS_PER_PAGE) actor_nicks = (contact_nicks + channel_nicks + [inbox_owner_ref.nick] + [s.owner for s in streams.values()] + [e.owner for e in entries] + [e.actor for e in entries]) actors = api.actor_get_actors(request.user, actor_nicks) # here comes lots of munging data into shape contacts = [actors[x] for x in contact_nicks if actors[x]] channels = [actors[x] for x in channel_nicks if actors[x]] streams = display.prep_stream_dict(streams, actors) entries = display.prep_entry_list(entries, streams, actors) return (contacts, channels, streams, entries)
def explore_recent(request, format="html"): if request.user: view = request.user logging.info("entering here") #twitter unauth = twitter.is_unauth(request) if 'twitter' in request.POST: if unauth: return http.HttpResponseRedirect('/twitter/auth?redirect_to=/') status = twitter.post_update(request) if status: flasherror = ["We have experimented some problems trying to post a cc in twitter"] handled = common_views.handle_view_action( request, { 'entry_remove': request.path, 'entry_remove_comment': request.path, 'entry_mark_as_spam': request.path, 'actor_add_contact': request.path, 'actor_remove_contact': request.path, 'post': request.path, 'presence_set': request.path, } ) if handled: return handled subtab = 'explore' per_page = ENTRIES_PER_PAGE offset, prev = util.page_offset(request) inbox = api.inbox_get_explore(request, limit=(per_page + 1), offset=offset) entries, more = helper.get_inbox_entries(request, inbox) stream_keys = [e.stream for e in entries] streams = api.stream_get_streams(request.user, stream_keys) actor_nicks = [e.owner for e in entries] + [e.actor for e in entries] actors = api.actor_get_actors(request.user, actor_nicks) # here comes lots of munging data into shape entries = prep_entry_list(entries, streams, actors) if request.user: channels_count = view.extra.get('channel_count', 0) channels_more = channels_count > CHANNELS_PER_PAGE followers_count = view.extra.get('follower_count', 0) contacts_count = view.extra.get('contact_count', 0) contacts_more = contacts_count > CONTACTS_PER_PAGE contact_nicks = api.actor_get_contacts_safe(request.user, view.nick, limit=CONTACTS_PER_PAGE) contacts = api.actor_get_actors(request.user, contact_nicks) contacts = [contacts[x] for x in contact_nicks if contacts[x]] green_top = True sidebar_green_top = True # END inbox generation chaos area = 'explore' actor_link = True c = template.RequestContext(request, locals()) if format == 'html': t = loader.get_template('explore/templates/recent.html') return http.HttpResponse(t.render(c)); elif format == 'json': t = loader.get_template('explore/templates/recent.json') r = util.HttpJsonResponse(t.render(c), request) return r elif format == 'atom': t = loader.get_template('explore/templates/recent.atom') r = util.HttpAtomResponse(t.render(c), request) return r elif format == 'rss': t = loader.get_template('explore/templates/recent.rss') r = util.HttpRssResponse(t.render(c), request) return r