Beispiel #1
0
    def render(self, context, instance, placeholder):
        representatives = Representative.parliament.all()
        context['representatives'] = Representative.by_lastname_lastname_first(
            representatives=representatives)
        context['random'] = RandomRepresentative.get()

        try:
            # temporary:
            #latest = Question.public.order_by('-date')[0]
            latest = Question.answered.order_by('-date')[0]
        except IndexError:
            latest = None
        context['latest'] = latest
        # temporary:
        #return context

        if not latest:
            context['most_active'] = None
            context['least_active'] = None
            return context

        try:
            representative = representatives.order_by('-answered')[0]
            context['most_active'] = self._add_activity(representative)
        except IndexError:
            context['most_active'] = None

        try:
            representative = representatives.order_by('answered')[0]
            context['least_active'] = self._add_activity(representative)
        except IndexError:
            context['least_active'] = None

        return context
Beispiel #2
0
    def render(self, context, instance, placeholder):
        representatives = Representative.parliament.all()
        context['representatives'] = Representative.by_lastname_lastname_first(
            representatives=representatives)
        context['random'] = RandomRepresentative.get()

        try:
            # temporary:
            #latest = Question.public.order_by('-date')[0]
            latest = Question.answered.order_by('-date')[0]
        except IndexError:
            latest = None
        context['latest'] = latest
        # temporary:
        #return context

        if not latest:
            context['most_active'] = None
            context['least_active'] = None
            return context

        try:
            representative = representatives.order_by('-answered')[0]
            context['most_active'] = self._add_activity(representative)
        except IndexError:
            context['most_active'] = None

        try:
            representative = representatives.order_by('answered')[0]
            context['least_active'] = self._add_activity(representative)
        except IndexError:
            context['least_active'] = None

        return context
Beispiel #3
0
    def test_get  (self):
        now = datetime.datetime.utcnow().replace(tzinfo=utc)
        current = RandomRepresentative.objects.all()[0]
        days_passed = (now - current.date_set).days
        rr = RandomRepresentative.get()

        if  days_passed >= 1:
            self.assertNotEqual(current.representative.pk, rr.pk)
        else:
            self.assertEqual(current.representative.pk, rr.pk)
Beispiel #4
0
    def test_get(self):
        now = datetime.datetime.utcnow().replace(tzinfo=utc)
        current = RandomRepresentative.objects.all()[0]
        days_passed = (now - current.date_set).days
        rr = RandomRepresentative.get()

        if days_passed >= 1:
            self.assertNotEqual(current.representative.pk, rr.pk)
        else:
            self.assertEqual(current.representative.pk, rr.pk)