Пример #1
0
    def milestones(self, create, count, **kwargs):
        if isinstance(count, dict):
            start_date = count['start_date']
            count = None
        else:
            start_date = faker.date_time_between(start_date="now", end_date="1y",
                                                 tzinfo=timezone(settings.TIME_ZONE))
        if count is None:
            count = 4
        make_milestones = getattr(MilestoneFactory, 'create' if create else 'build')
        milestones = list() #[make_milestones(project=self) for i in range(count)]

        fiscal_year = FiscalYear.create_from_date(start_date, display='AF%s')
        self.fiscal_year = str(fiscal_year)
        for i in range(count):
            if i == 0:
                milestone = make_milestones(project=self, milestone_type=Milestone.MILESTONE_START,
                                            date=start_date)
                start_date = start_date + timedelta(weeks=randint(2, 8))
            elif i == count - 1:
                milestone = make_milestones(project=self, milestone_type=Milestone.MILESTONE_END,
                                            date=start_date)
                start_date = start_date + timedelta(weeks=randint(2, 8))
            else:
                milestone = make_milestones(project=self, date=start_date)
                start_date = start_date + timedelta(weeks=randint(2, 8))
            milestones.append(milestone)

        if create:
            self.save()
        else:
            # Fiddle with django internals so self.product_set.all() works with build()
            self._prefetched_objects_cache = {'milestones': milestones}
Пример #2
0
 def test_get_with_errors(self):
     last_holiday = ACPHoliday.objects.last()
     fiscal_year = FiscalYear.create_from_date(last_holiday.date)
     year = fiscal_year.year + 1
     url = reverse('fiscal-year-calendar', kwargs={'fiscal_year': year})
     response = self.client.get(url)
     self.assertEqual(200, response.status_code)
     self.assertRegex(response.context['version'], self.version_regex)
     self.assertEqual(year, response.context['fiscal_year'])
     self.assertEqual('End date exceed the last registered holiday', response.context['errors'])
 def test_get_with_errors(self):
     last_holiday = ACPHoliday.objects.last()
     fiscal_year = FiscalYear.create_from_date(last_holiday.date)
     year = fiscal_year.year + 1
     url = reverse('calendar:fiscal-year-calendar', kwargs={'fiscal_year': year})
     response = self.client.get(url)
     self.assertEqual(200, response.status_code)
     self.assertRegex(response.context['version'], self.version_regex)
     self.assertEqual(year, response.context['fiscal_year'])
     self.assertEqual('End date exceed the last registered holiday', response.context['errors'])
Пример #4
0
    def handle(self, *args, **options):
        office = None
        office_title = 'All'

        if options['office'] != None:
            office = OrganizationUnit.objects.get(short_name=options['office'])
            office_title = options['office']

        if options['fiscal_year'] != None:
            fiscal_year = int(options['fiscal_year'])
        else:
            fy = FiscalYear.create_from_date(datetime.now())
            fiscal_year = fy.year

        if office:
            assignments = UnitAssignment.objects.get_fiscal_year_assignments_to(fiscal_year, office).order_by('employee__last_name')
        self.stdout.write('Office: %s FY: %d' % (office_title, fiscal_year))
        self.stdout.write('-'*100)
        num = 1
        for assignment in assignments:
            self.stdout.write('%2d. %-30s %-10s %-10s %4d' % (num, assignment.employee,
                                                 assignment.start_date, assignment.end_date,
                                                 assignment.age))
            num += 1
Пример #5
0
 def test_create_from_date_datetime(self):
     cdate = datetime.datetime(2013, 10, 1, 0, 0, 0)
     fy = FiscalYear.create_from_date(cdate)
     self.assertEqual('FY14', str(fy))
Пример #6
0
 def test_create_from_date_2(self):
     cdate = datetime.date(2014, 9, 1)
     fy = FiscalYear.create_from_date(cdate)
     self.assertEqual('FY14', str(fy))
Пример #7
0
 def test_create_from_date(self):
     cdate = datetime.date(2013, 10, 1)
     fy = FiscalYear.create_from_date(cdate)
     self.assertEqual('FY14', str(fy))