def get_context_data(self, *args, **kwargs):
        context = super(AgendaDetailView, self).get_context_data(*args, **kwargs)
        agenda = context['object']
        try:
            context['title'] = "%s" % agenda.name
        except AttributeError:
            context['title'] = _('None')

        if self.request.user.is_authenticated():
            p = self.request.user.get_profile()
            watched = agenda in p.agendas
            watched_members = self.request.user.get_profile().members
        else:
            watched = False
            watched_members = False
        context.update({'watched_object': watched})
        context['watched_members'] = watched_members

        all_mks = 'all_mks' in self.request.GET.keys()
        mks_values = agenda.get_mks_values()
        context['agenda_mk_values'] = dict(mks_values)
        cmp_rank = lambda x, y: x[1]['rank'] - y[1]['rank']
        if all_mks:
            context['all_mks_ids'] = map(itemgetter(0),mks_values[:200])
            context['all_mks'] = True
        else:
            context['mks_top'] = map(itemgetter(0),mks_values[:5])
            context['mks_bottom'] = map(itemgetter(0),mks_values[-5:])

        allAgendaPartyVotes = agenda.get_all_party_values()
        context['agenda_party_values']=dict(map(lambda x:(x[0],x[1]),allAgendaPartyVotes.setdefault(agenda.id,[])))
        context['agendaTopParties']=map(itemgetter(0),sorted(allAgendaPartyVotes[agenda.id],key=itemgetter(1),reverse=True)[:20])

        agenda_votes = cache.get('agenda_votes_%d' % agenda.id)

        if not agenda_votes:
            agenda_votes = agenda.agendavotes.order_by(
                '-vote__time').select_related('vote')
            cache.set('agenda_votes_%d' % agenda.id, agenda_votes, 900)

        try:
            total_votes = agenda_votes.count()
        except TypeError:
            total_votes = len(agenda_votes)

        context['INITIAL'] = self.INITIAL
        context['agenda_votes_more'] = total_votes > self.INITIAL
        context['agenda_votes'] = agenda_votes[:self.INITIAL]

        agenda_bills = agenda.agendabills.all()
        context['agenda_bills_more'] = agenda_bills.count() > self.INITIAL
        context['agenda_bills'] = agenda_bills[:self.INITIAL]

        agenda_meetings = agenda.agendameetings.all()
        context['agenda_meetings_more'] = agenda_meetings.count() > self.INITIAL
        context['agenda_meetings'] = agenda_meetings[:self.INITIAL]

        # Optimization: get all parties and members before rendering
        # Further possible optimization: only bring parties/members needed for rendering
        parties_objects = Party.objects.all()
        partiesDict = dict(map(lambda party:(party.id,party),parties_objects))
        context['parties']=partiesDict

        member_objects = Member.objects.all()
        membersDict = dict(map(lambda mk:(mk.id,mk),member_objects))
        context['members']=membersDict
        return context
dataset/ETHPy150Open ofri/Open-Knesset/agendas/views.py/AgendaDetailView.get_context_data/original