Beispiel #1
0
 def test_invalid(self):
     valid_serializer = HactHistorySerializer(data={
         'year': True,
         'created': datetime.today(),
         'modified': datetime.today(),
         'partner_values': hact_default()
     })
     self.assertFalse(valid_serializer.is_valid())
Beispiel #2
0
    def test_valid(self):

        valid_serializer = AggregateHactSerializer(data={
            'year': 2013,
            'created': datetime.today(),
            'modified': datetime.today(),
            'partner_values': hact_default()
        })
        self.assertTrue(valid_serializer.is_valid())
Beispiel #3
0
    def handle(self, *args, **options):

        countries = Country.objects.exclude(name__iexact='global')
        if options['schema']:
            countries = countries.filter(schema_name=options['schema'])

        year = datetime.now().year
        self.stdout.write('Freeze HACT data for {}'.format(year))

        for country in countries:
            set_country(country.name)
            self.stdout.write('Freezing data for {}'.format(country.name))
            for partner in PartnerOrganization.objects.all():
                if partner.reported_cy > 0 or partner.total_ct_cy > 0:
                    hact_history, created = HactHistory.objects.get_or_create(
                        partner=partner, year=year)
                    self.freeze_data(hact_history)
                partner.hact_values = hact_default()
                partner.save()

                plan = partner.planned_engagement
                if plan:
                    plan.reset()