コード例 #1
0
    def setUp(self):
        super(InitialStatisticsTest, self).setUp()
        self.stats = Statistics()
        Member.objects.all().delete()

        self.some_user = BlueBottleUserFactory.create()

        self.some_initiative = InitiativeFactory.create(owner=self.some_user)
コード例 #2
0
    def setUp(self):
        super(StatisticsTest, self).setUp()
        self.stats = Statistics()
        Member.objects.all().delete()

        self.some_user = BlueBottleUserFactory.create()
        self.other_user = BlueBottleUserFactory.create()

        self.initiative = InitiativeFactory.create(owner=self.some_user)
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
コード例 #3
0
    def get_value(self, obj):
        if obj.value:
            return obj.value

        statistics = Statistics(
            start=self.context.get('start_date'),
            end=self.context.get('end_date'),
        )

        value = getattr(statistics, obj.type, 0)
        try:
            return {'amount': value.amount, 'currency': str(value.currency)}
        except AttributeError:
            return value
コード例 #4
0
    def get_statistics(self, instance):
        stats = Statistics(start=self.context.get('start_date'),
                           end=self.context.get('end_date'))

        return {
            'people': stats.people_involved,
            'amount': {
                'amount': stats.donated_total.amount,
                'currency': str(stats.donated_total.currency)
            },
            'hours': stats.time_spent,
            'fundraisers': stats.fundings_succeeded,
            'tasks': stats.assignments_succeeded,
            'events': stats.events_succeeded
        }
コード例 #5
0
    def get_statistics(self, instance):
        stats = Statistics(start=self.context.get('start_date'),
                           end=self.context.get('end_date'))

        return {
            'people': stats.people_involved,
            'amount': {
                'amount': stats.donated_total.amount,
                'currency': str(stats.donated_total.currency)
            },
            'hours': stats.time_spent,
            'projects': stats.projects_realized,
            'tasks': stats.tasks_realized,
            'votes': stats.votes_cast,
        }
コード例 #6
0
ファイル: models.py プロジェクト: raux/bluebottle
 def statistics(self):
     return Statistics()
コード例 #7
0
 def test_both(self):
     stats = Statistics(start=timezone.now() - datetime.timedelta(days=9),
                        end=timezone.now() - datetime.timedelta(days=2))
     self.assertEqual(stats.activities_succeeded, 1)
     self.assertEqual(stats.events_succeeded, 1)
     self.assertEqual(stats.people_involved, 2)
コード例 #8
0
 def test_all(self):
     stats = Statistics()
     self.assertEqual(stats.activities_succeeded, 3)
     self.assertEqual(stats.events_succeeded, 3)
     self.assertEqual(stats.people_involved, 5)
コード例 #9
0
 def get_supporters(self, instance):
     stats = Statistics(start=self.context.get('start_date'),
                        end=self.context.get('end_date'))
     return stats.people_involved