示例#1
0
 def setUp(self):
     country = w_factories.CountryFactory()
     self.program = w_factories.RFProgramFactory(tiers=True, levels=2)
     self.program.country.add(country)
     for level in self.program.levels.all():
         i_factories.RFIndicatorFactory(program=self.program,
                                        level=level,
                                        targets=500,
                                        results=400)
     tola_user = w_factories.TolaUserFactory(country=country)
     w_factories.grant_program_access(tola_user, self.program, country,
                                      'high')
     self.client.force_login(tola_user.user)
示例#2
0
 def setUp(self):
     country = w_factories.CountryFactory()
     self.program = w_factories.RFProgramFactory(migrated=False)
     self.program.country.add(country)
     for _, level in Indicator.OLD_LEVELS:
         i_factories.RFIndicatorFactory(program=self.program,
                                        old_level=level,
                                        targets=500,
                                        results=400)
     tola_user = w_factories.TolaUserFactory(country=country)
     w_factories.grant_program_access(tola_user, self.program, country,
                                      'high')
     self.client.force_login(tola_user.user)
 def setUp(self):
     country = w_factories.CountryFactory()
     self.program = w_factories.RFProgramFactory(migrated=False)
     self.program.country.add(country)
     self.indicator = i_factories.RFIndicatorFactory(
         program=self.program,
         target_frequency=Indicator.ANNUAL,
         targets=500,
         results=True)
     tola_user = w_factories.TolaUserFactory(country=country)
     w_factories.grant_program_access(tola_user, self.program, country,
                                      'high')
     self.client.force_login(tola_user.user)
 def setUp(self):
     country = w_factories.CountryFactory()
     self.program_empty = w_factories.RFProgramFactory()
     self.program_empty.country.add(country)
     self.program_full = w_factories.RFProgramFactory(tiers=True, levels=1)
     self.program_full.country.add(country)
     for level in self.program_full.levels.all():
         indicator = i_factories.RFIndicatorFactory(program=self.program_full, level=level, targets=True)
         site = w_factories.SiteProfileFactory(country=country)
         result = i_factories.ResultFactory(indicator=indicator, achieved=100)
         result.site.set([site])
     self.site = site
     tola_user = w_factories.TolaUserFactory(country=country)
     w_factories.grant_program_access(tola_user, self.program_empty, country, 'high')
     self.client.force_login(tola_user.user)
 def setUp(self):
     country = w_factories.CountryFactory()
     self.program = w_factories.RFProgramFactory(
         migrated=True,
         tiers=[u'Spécîal Chåracters1', u'###!@#$', 'asdf'],
         levels=2)
     self.program.country.add(country)
     self.indicator = i_factories.RFIndicatorFactory(
         program=self.program,
         target_frequency=Indicator.ANNUAL,
         targets=500,
         results=True,
         level=self.program.levels.all()[3])
     tola_user = w_factories.TolaUserFactory(country=country)
     w_factories.grant_program_access(tola_user, self.program, country,
                                      'high')
     self.client.force_login(tola_user.user)
    def init(self):
        self.home_country = w_factories.CountryFactory(country='HOME country',
                                                       code='HM')
        self.in_country = w_factories.CountryFactory(country='IN country',
                                                     code='IN')
        self.out_country = w_factories.CountryFactory(country='OUT country',
                                                      code='OUT')
        self.program_in_country = w_factories.ProgramFactory(
            name='program in IN country',
            gaitid='inpr',
            country=self.in_country,
            reporting_period_start=datetime.date(2016, 1, 1),
            reporting_period_end=datetime.date(2016, 12, 31))
        self.program_in_country.country.add(self.in_country)
        self.program_out_of_country = w_factories.ProgramFactory(
            name='program in OUT country',
            gaitid='outpr',
            country=self.out_country,
            reporting_period_start=datetime.date(2016, 1, 1),
            reporting_period_end=datetime.date(2016, 12, 31))
        self.program_out_of_country.country.clear()
        self.program_out_of_country.country.add(self.out_country)
        self.add_indicators()
        self.add_results()
        if Organization.objects.filter(pk=1).count() == 1:
            self.mercy_corps_organization = Organization.objects.get(pk=1)
        else:
            self.mercy_corps_organization = w_factories.OrganizationFactory(
                pk=1)
        self.partner_organization = w_factories.OrganizationFactory(
            name="Partner Org")
        user = d_factories.UserFactory(first_name='mercy corps',
                                       last_name='country low')
        self.mercy_corps_country_low = w_factories.TolaUserFactory(
            name="mercy corps country low",
            organization=self.mercy_corps_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_country_access(self.mercy_corps_country_low,
                                         self.in_country,
                                         COUNTRY_ROLE_CHOICES[0][0])
        user = d_factories.UserFactory(first_name='mercy corps',
                                       last_name='country admin')
        self.mercy_corps_country_admin = w_factories.TolaUserFactory(
            name="mercy corps country admin",
            organization=self.mercy_corps_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_country_access(self.mercy_corps_country_admin,
                                         self.in_country,
                                         COUNTRY_ROLE_CHOICES[1][0])
        user = d_factories.UserFactory(first_name='mercy corps',
                                       last_name='program low')
        self.mercy_corps_low = w_factories.TolaUserFactory(
            name="mercy corps low",
            organization=self.mercy_corps_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_program_access(self.mercy_corps_low,
                                         self.program_in_country,
                                         self.in_country,
                                         PROGRAM_ROLE_CHOICES[0][0])
        user = d_factories.UserFactory(first_name='mercy corps',
                                       last_name='program medium')
        self.mercy_corps_medium = w_factories.TolaUserFactory(
            name="mercy corps medium",
            organization=self.mercy_corps_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_program_access(self.mercy_corps_medium,
                                         self.program_in_country,
                                         self.in_country,
                                         PROGRAM_ROLE_CHOICES[1][0])
        user = d_factories.UserFactory(first_name='mercy corps',
                                       last_name='program high')
        self.mercy_corps_high = w_factories.TolaUserFactory(
            name="mercy corps high",
            organization=self.mercy_corps_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_program_access(self.mercy_corps_high,
                                         self.program_in_country,
                                         self.in_country,
                                         PROGRAM_ROLE_CHOICES[2][0])
        user = d_factories.UserFactory(first_name='mercy corps',
                                       last_name='super admin')
        self.mercy_corps_super_admin = w_factories.TolaUserFactory(
            name="mercy corps super admin",
            organization=self.mercy_corps_organization,
            country=self.home_country,
            user=user)
        self.mercy_corps_super_admin.user.is_superuser = True
        self.mercy_corps_super_admin.user.save()
        user = d_factories.UserFactory(first_name='non mercy corps',
                                       last_name='program low')
        self.non_mercy_corps_low = w_factories.TolaUserFactory(
            name="non-MC low",
            organization=self.partner_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_program_access(self.non_mercy_corps_low,
                                         self.program_in_country,
                                         self.in_country,
                                         PROGRAM_ROLE_CHOICES[0][0])
        user = d_factories.UserFactory(first_name='non mercy corps',
                                       last_name='program medium')
        self.non_mercy_corps_medium = w_factories.TolaUserFactory(
            name="non-MC medium",
            organization=self.partner_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_program_access(self.non_mercy_corps_medium,
                                         self.program_in_country,
                                         self.in_country,
                                         PROGRAM_ROLE_CHOICES[1][0])
        user = d_factories.UserFactory(first_name='non mercy corps',
                                       last_name='program high')
        self.non_mercy_corps_high = w_factories.TolaUserFactory(
            name="non-MC medium",
            organization=self.partner_organization,
            country=self.home_country,
            user=user)
        w_factories.grant_program_access(self.non_mercy_corps_high,
                                         self.program_in_country,
                                         self.in_country,
                                         PROGRAM_ROLE_CHOICES[2][0])

        self.external_service = i_factories.ExternalServiceFactory()