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)
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)
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
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 }
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, }
def statistics(self): return Statistics()
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)
def test_all(self): stats = Statistics() self.assertEqual(stats.activities_succeeded, 3) self.assertEqual(stats.events_succeeded, 3) self.assertEqual(stats.people_involved, 5)
def get_supporters(self, instance): stats = Statistics(start=self.context.get('start_date'), end=self.context.get('end_date')) return stats.people_involved