def get_context_data(self, **kwargs): ctx = super(BaseMainView, self).get_context_data(**kwargs) ctx.update(main_page_context()) self.location = Location.objects.country() self.location_query = get_roles_query(self.location) self.info = self.location.info(related=True) self.tabs = [ ('main', u'Что делать?', reverse('main'), 'main/view.html'), ('wall', u'Комментарии: %i' % self.info['comments']['count'], reverse('wall'), 'locations/wall.html'), ('participants', u'Участники', reverse('participants'), 'locations/participants.html'), ('elections', u'Выборы', reverse('elections'), 'locations/elections.html'), ] ctx.update(entity_tabs_view(self)) ctx.update(breadcrumbs_context(self.location)) ctx.update({ 'info': self.info, 'show_date': True, }) #self.data_location = ctx['data_location'] ctx.update(self.update_context()) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseLocationView, self).get_context_data(**kwargs) loc_id = int(kwargs['loc_id']) try: self.location = location = Location.objects.select_related().get(id=loc_id) except Location.DoesNotExist: raise Http404(u'Избирательный округ не найден') # TODO: different query generators might be needed for different data types self.location_query = get_roles_query(location) self.info = location.info(related=True) self.tabs = [ ('wall', u'Комментарии: %i' % self.info['comments']['count'], reverse('location_wall', args=[location.id]), 'locations/wall.html'), ('participants', u'Участники', reverse('location_participants', args=[location.id]), 'locations/participants.html'), ('info', u'Информация', reverse('location_info', args=[location.id]), 'locations/info.html'), ('elections', u'Выборы', reverse('location_elections', args=[location.id]), 'locations/elections.html'), ('violations', u'Нарушения', reverse('location_violations', args=[location.id]), 'locations/violations.html'), ] ctx.update(entity_tabs_view(self)) ctx.update(breadcrumbs_context(location)) self.data_location = ctx['data_location'] ctx.update({ 'loc_id': kwargs['loc_id'], 'info': self.info, 'show_date': True, 'counters': get_roles_counters(location), 'add_commission_member_form': CommissionMemberForm(), 'become_web_observer_form': WebObserverForm(), 'ROLE_CHOICES': ROLE_CHOICES_PLURAL, }) ctx.update(self.update_context()) return ctx