Example #1
0
 def setUp(self):
     self.timezone = pytz.timezone('Europe/Amsterdam')
     self.year = Year(
         events=Event.objects.all(),
         date=self.timezone.localize(datetime.datetime(2013, 12, 17, 9, 0)),
         tzinfo=self.timezone,
     )
class TestYear(TestCase):
    def setUp(self):
        self.year = Year(reservations=[], date=datetime.datetime(2008, 4, 1))

    def test_get_months(self):
        months = self.year.get_months()
        self.assertEqual([month.start for month in months], [datetime.datetime(2008, i, 1) for i in range(1, 13)])
Example #3
0
class TestYear(TestCase):
    def setUp(self):
        self.year = Year(events=[], date=datetime.datetime(2008, 4, 1))

    def test_get_months(self):
        months = self.year.get_months()
        self.assertEqual([month.start for month in months],
                         [datetime.datetime(2008, i, 1) for i in range(1, 13)])
class TestYear(TestCase):
    def setUp(self):
        self.year = Year(events=[], date=datetime.datetime(2008, 4, 1))

    def test_get_months(self):
        months = self.year.get_months()
        expected = [datetime.datetime(2008, i, 1) for i in range(1, 13)]
        self.assertEqual([month.start for month in months], expected)
class TestYear(TestCase):

    def setUp(self):
        self.year = Year(events=[], date=datetime.datetime(2008, 4, 1, tzinfo=pytz.utc))

    def test_get_months(self):
        months = self.year.get_months()
        self.assertEqual([month.start for month in months],
            [datetime.datetime(2008, i, 1, tzinfo=pytz.utc) for i in range(1,13)])
Example #6
0
 def setUp(self):
     self.year = Year(events=[],
                      date=datetime.datetime(2008, 4, 1, tzinfo=pytz.utc))
 def setUp(self):
     self.year = Year(events=[], date=datetime.datetime(2008, 4, 1, tzinfo=pytz.utc))
Example #8
0
 def setUp(self):
     self.year = Year(events=[], date=datetime.datetime(2008, 4, 1))
Example #9
0
 def setUp(self):
     self.year = Year(events=[], date=datetime.datetime(2008,4,1))
 def setUp(self):
     self.year = Year(reservations=[], date=datetime.datetime(2008, 4, 1))
Example #11
0
def details(request, calendar_slug,  periods=None):
    try:
        schedule = get_object_or_404(Calendar, slug=calendar_slug)
        date = coerce_date_dict(request.GET) or None
        if date:
            try:
                date = datetime(**date)
            except ValueError:
                raise Http404
        else:
            date = timezone.now()
        event_list = schedule.event_set.all()
        currently_oncall_users = escalation_helper.get_current_events_users(schedule)
        if len(currently_oncall_users) >= 2:
            oncall1 = f"{currently_oncall_users[0].username}, Phone Number: {currently_oncall_users[0].profile.phone_number}"
            oncall2 = f"{currently_oncall_users[1].username}, Phone Number: {currently_oncall_users[1].profile.phone_number}"
        else:
            oncall1 = "Nobody"
            oncall2 = "Nobody"

        if 'django_timezone' in request.session:
            local_timezone = pytz.timezone(request.session['django_timezone'])
        else:
            local_timezone = timezone.get_default_timezone()
        period_objects = {}
        for period in periods:
            if period.__name__.lower() == 'year':
                period_objects[period.__name__.lower()] = Year(event_list, date, None, local_timezone)
            else:
                period_objects[period.__name__.lower()] = Month(event_list, date, None, None, local_timezone)
        template = 'schedules/detail.html'
        month = period_objects['month']
        shift = None
        if shift:
            if shift == -1:
                month = month.prev()
            if shift == 1:
                month = next(month)
        size = 'regular'
        if size == 'small':
            day_names = weekday_abbrs
        else:
            day_names = weekday_names

        context = {
            'day_names': day_names,
            'month': month,
            'size': size,

            'date': date,
            'periods': period_objects,
            'calendar': schedule,
            'weekday_names': weekday_names,
            'currently_oncall_1': oncall1,
            'currently_oncall_2': oncall2,
            'local_timezone': local_timezone,
            'current_date': timezone.now(),
            'here': f"{request.get_full_path()}",
        }
        return render(request, template, context)
    except Calendar.DoesNotExist:
        raise Http404
 def current_year(self):
     return Year(self.events, self.start, tzinfo=self.tzinfo)
 def setUp(self):
     self.year = Year(reservations=[], date=datetime.datetime(2008, 4, 1))