コード例 #1
0
ファイル: views.py プロジェクト: rapidpro/ureport
    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        org = self.request.org
        context["org"] = org

        latest_poll = Poll.get_main_poll(org)
        context["latest_poll"] = latest_poll
        if context["latest_poll"]:
            context["trending_words"] = latest_poll.get_trending_words()

        brick_poll_ids = Poll.get_brick_polls_ids(org)
        context["recent_polls"] = Poll.objects.filter(id__in=brick_poll_ids).order_by("-created_on")

        context["stories"] = Story.objects.filter(org=org, is_active=True, featured=True).order_by("-created_on")

        videos = Video.objects.filter(is_active=True, org=org).order_by("-created_on")
        context["videos"] = videos

        news = NewsItem.objects.filter(is_active=True, org=org).order_by("-created_on")
        context["news"] = news.count() > 0

        context["most_active_regions"] = org.get_regions_stats()

        # global counter
        if org.get_config("common.is_global"):
            context["global_counter"] = get_global_count()

        context["gender_stats"] = org.get_gender_stats()
        context["age_stats"] = org.get_age_stats()
        context["reporters"] = org.get_reporters_count()

        return context
コード例 #2
0
    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        org = self.request.org
        context['org'] = org

        latest_poll = Poll.get_main_poll(org)
        context['latest_poll'] = latest_poll
        if context['latest_poll']:
            context['trending_words'] = latest_poll.get_trending_words()

        brick_poll_ids = Poll.get_brick_polls_ids(org)
        context['recent_polls'] = Poll.objects.filter(id__in=brick_poll_ids)

        context['stories'] = Story.objects.filter(org=org, is_active=True, featured=True).order_by('-created_on')

        videos = Video.objects.filter(is_active=True, org=org).order_by('-created_on')
        context['videos'] = videos

        news = NewsItem.objects.filter(is_active=True, org=org).order_by('-created_on')
        context['news'] = news.count() > 0

        context['most_active_regions'] = org.get_regions_stats()

        # global counter
        if org.get_config('common.is_global'):
            context['global_counter'] = get_global_count()

        context['gender_stats'] = org.get_gender_stats()
        context['age_stats'] = org.get_age_stats()
        context['reporters'] = org.get_reporters_count()

        return context
コード例 #3
0
ファイル: views.py プロジェクト: Assaye/ureport
    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        org = self.request.org
        context["org"] = org

        latest_poll = Poll.get_main_poll(org)
        context["latest_poll"] = latest_poll
        if context["latest_poll"]:
            context["trending_words"] = latest_poll.get_trending_words()

        brick_poll_ids = Poll.get_brick_polls_ids(org)
        context["recent_polls"] = Poll.objects.filter(id__in=brick_poll_ids).order_by("-created_on")

        context["stories"] = Story.objects.filter(org=org, is_active=True, featured=True).order_by("-created_on")

        videos = Video.objects.filter(is_active=True, org=org).order_by("-created_on")
        context["videos"] = videos

        news = NewsItem.objects.filter(is_active=True, org=org).order_by("-created_on")
        context["news"] = news.count() > 0

        context["most_active_regions"] = org.get_regions_stats()

        # global counter
        if org.get_config("common.is_global"):
            context["global_counter"] = get_global_count()

        context["gender_stats"] = org.get_gender_stats()
        context["age_stats"] = org.get_age_stats()
        context["reporters"] = org.get_reporters_count()

        return context
コード例 #4
0
ファイル: views.py プロジェクト: Assaye/ureport
    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        org = self.request.org
        context["org"] = org

        latest_poll = Poll.get_main_poll(org)
        context["latest_poll"] = latest_poll
        if context["latest_poll"]:
            context["trending_words"] = latest_poll.get_trending_words()

        brick_poll_ids = Poll.get_brick_polls_ids(org)
        context["recent_polls"] = Poll.objects.filter(
            id__in=brick_poll_ids).order_by("-created_on")

        context["stories"] = Story.objects.filter(
            org=org, is_active=True, featured=True).order_by("-created_on")

        videos = Video.objects.filter(is_active=True,
                                      org=org).order_by("-created_on")
        context["videos"] = videos

        news = NewsItem.objects.filter(is_active=True,
                                       org=org).order_by("-created_on")
        context["news"] = news.count() > 0

        context["most_active_regions"] = org.get_regions_stats()

        # global counters
        context["global_contact_count"] = get_global_count()
        context["global_org_count"] = Org.objects.filter(
            is_active=True).count() + len(settings.PREVIOUS_ORG_SITES)

        context["gender_stats"] = org.get_gender_stats()
        context["age_stats"] = json.loads(org.get_age_stats())
        context["reporters"] = org.get_reporters_count()
        context["feat_images"] = range(10)

        # fake photos, generated from stories that are featured and have a photo
        context["photos"] = (Story.objects.filter(
            org=org, featured=True,
            is_active=True).exclude(images=None).order_by("-created_on")[4:])

        context["main_stories"] = Story.objects.filter(
            org=org, featured=True, is_active=True).order_by("-created_on")

        return context