Example #1
0
    def get_context_data(self, **kwargs):
        ctx = super(BaseProjectView, self).get_context_data(**kwargs)

        id = int(self.kwargs.get('id'))

        ctx.update(entity_base_view(self, Project, {'id': id}))

        self.tabs = [
            ('view', u'Описание', reverse('project', args=[id]), 'projects/view.html'),
            ('wall', u'Комментарии: %i' % ctx['info']['comments']['count'], reverse('project_wall', args=[id]), 'projects/wall.html'),
            ('participants', u'Участники: %i' % self.info['providers'], reverse('project_participants', args=[id]), 'projects/participants.html'),
        ]

        ctx.update(entity_tabs_view(self))

        # TODO: select_related it needed (?)
        location = ctx['info']['locations']['entities'][0]['instance'] # TODO: looks hacky
        ctx.update(breadcrumbs_context(location))

        ctx.update({
            'title': u'Проект: '+self.entity.title,
            'project': self.entity,
            'admin': ctx['info']['participants']['admin']['entities'][0], # TODO: fix it
        })
        return ctx
Example #2
0
    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
Example #3
0
def static_page(request, **kwargs):
    """
    kwargs must contain the following keys: 'tab', 'template', 'tabs'.
    kwargs['tabs']=[(name, url, template, css_class), ...]
    """
    ctx = breadcrumbs_context(Location.objects.country())
    ctx.update(kwargs)
    return render_to_response(kwargs['template'], context_instance=RequestContext(request, ctx))
Example #4
0
    def get_context_data(self, **kwargs):
        ctx = super(BaseLocationView, self).get_context_data(**kwargs)

        loc_id = int(kwargs["loc_id"])
        # TODO: do we need select_related? (can we use location from cache?)
        try:
            location = Location.objects.select_related("region", "district").get(id=loc_id)
        except:  # Location.DoesNotExist: # TODO: hack to overcome strange bug
            raise Http404(u"Район не найден")

        self.location = location

        self.info = location.info(related=True)

        # TODO: take it from cache (should be in location info)
        tasks_count = location.get_entities("tasks")(limit=0)["count"]
        projects_count = location.get_entities("projects")(limit=0)["count"]

        self.tabs = [
            # ('map', u'Карта', reverse('location_map', args=[location.id]), '', 'locations/map.html'),
            ("tasks", u"Задачи: %i" % tasks_count, reverse("location_tasks", args=[location.id]), "tasks/list.html"),
            (
                "projects",
                u"Проекты: %i" % projects_count,
                reverse("location_projects", args=[location.id]),
                "projects/list.html",
            ),
            (
                "wall",
                u"Комментарии: %i" % self.info["comments"]["count"],
                reverse("location_wall", args=[location.id]),
                "locations/wall.html",
            ),
            (
                "participants",
                u"Участники: %i" % self.info["participants"]["count"],
                reverse("location_participants", args=[location.id]),
                "locations/participants.html",
            ),
        ]

        ctx.update(entity_tabs_view(self))
        ctx.update(breadcrumbs_context(location))

        ctx.update(
            {
                "title": location.name,
                "loc_id": kwargs["loc_id"],  # TODO: what is it for?
                "info": self.info,
                "is_participant": self.request.user.is_authenticated()
                and location.id in self.request.profile_info["locations"]["ids"],
                "is_lowest_level": location.is_lowest_level(),
                "is_location_page": True,
            }
        )
        ctx.update(self.update_context())
        return ctx
Example #5
0
    def get_context_data(self, **kwargs):
        ctx = super(ViolationView, self).get_context_data(**kwargs)

        ctx.update(breadcrumbs_context(self.object.location))

        ctx.update({
            'violation': self.object,
            'violation_id': self.kwargs['violation_id'],
        })
        return ctx
Example #6
0
    def get_context_data(self, **kwargs):
        ctx = super(IdeaView, self).get_context_data(**kwargs)

        id = int(self.kwargs.get('id'))
        ctx.update(entity_base_view(self, Idea, {'id': id}))

        location = self.entity.task.info()['locations']['entities'][0]['instance']
        ctx.update(breadcrumbs_context(location))

        projects = [pi.project for pi in self.entity.projects.select_related('project')]
        ctx.update({
            'title': u'Идея к задаче "%s"' % self.entity.task.title,
            'idea': self.entity,
            'admin': self.info['participants']['admin']['entities'][0],
            'projects': projects,
        })
        return ctx
Example #7
0
    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