예제 #1
0
def full_calendar(request):
    try:
        if schedule_permissions(request.user):
            schedule_boards = ScheduleBoard.objects.all().order_by('start_date')
            if not schedule_boards:
                ScheduleBoard.objects.create(name="Unnamed")
                schedule_boards = ScheduleBoard.objects.all()
            calendar_configuration = CalendarConfiguration.objects.get()
            context = {
                'scheduleBoards': schedule_boards,
                'scroll_time': calendar_configuration.scroll_time.strftime('%H:%M:%S'),
                'first_day': calendar_configuration.first_day + 1,
                'language': request.LANGUAGE_CODE,
                'current_scheduleBoard': ScheduleBoard.get_current(datetime.datetime.now())
            }
            return render(request, 'dashboard/fullcalendar.html', context)
        else:
            return render(
                request,
                'dashboard/fullcalendar_error.html',
                {'error_info': _('Sorry, you don\'t have enough permissions. Please contact your administrator.')}
            )
    except CalendarConfiguration.DoesNotExist:
        return render(
            request,
            'dashboard/fullcalendar_error.html',
            {'error_info': _('Calendar Configuration not found. Please contact your administrator.')}
        )
예제 #2
0
    def test_runtime(self):
        january_board = ScheduleBoard.objects.get(name="january")
        february_board = ScheduleBoard.objects.get(name="1_14_february")
        after_board = ScheduleBoard.objects.get(name="after_14_february")

        self.assertEqual(None, ScheduleBoard.get_current(datetime.datetime(2013, 12, 1, 0, 0, 0, 0)))
        self.assertEqual(january_board, ScheduleBoard.get_current(datetime.datetime(2014, 1, 1, 0, 0, 0, 0)))
        self.assertEqual(january_board, ScheduleBoard.get_current(datetime.datetime(2014, 1, 31, 0, 0, 0, 0)))
        self.assertEqual(january_board, ScheduleBoard.get_current(datetime.datetime(2014, 1, 31, 12, 0, 0, 0)))
        self.assertEqual(february_board, ScheduleBoard.get_current(datetime.datetime(2014, 2, 1, 0, 0, 0, 0)))
        self.assertEqual(february_board, ScheduleBoard.get_current(datetime.datetime(2014, 2, 14, 0, 0, 0, 0)))
        self.assertEqual(after_board, ScheduleBoard.get_current(datetime.datetime(2014, 2, 15, 0, 0, 0, 0)))
        self.assertEqual(after_board, ScheduleBoard.get_current(datetime.datetime(2014, 6, 1, 0, 0, 0, 0)))
예제 #3
0
    def test_runtime(self):
        january_board = ScheduleBoard.objects.get(name="january")
        february_board = ScheduleBoard.objects.get(name="1_14_february")
        after_board = ScheduleBoard.objects.get(name="after_14_february")

        self.assertEqual(
            None,
            ScheduleBoard.get_current(
                datetime.datetime(2013, 12, 1, 0, 0, 0, 0)))
        self.assertEqual(
            january_board,
            ScheduleBoard.get_current(datetime.datetime(
                2014, 1, 1, 0, 0, 0, 0)))
        self.assertEqual(
            january_board,
            ScheduleBoard.get_current(
                datetime.datetime(2014, 1, 31, 0, 0, 0, 0)))
        self.assertEqual(
            january_board,
            ScheduleBoard.get_current(
                datetime.datetime(2014, 1, 31, 12, 0, 0, 0)))
        self.assertEqual(
            february_board,
            ScheduleBoard.get_current(datetime.datetime(
                2014, 2, 1, 0, 0, 0, 0)))
        self.assertEqual(
            february_board,
            ScheduleBoard.get_current(
                datetime.datetime(2014, 2, 14, 0, 0, 0, 0)))
        self.assertEqual(
            after_board,
            ScheduleBoard.get_current(
                datetime.datetime(2014, 2, 15, 0, 0, 0, 0)))
        self.assertEqual(
            after_board,
            ScheduleBoard.get_current(datetime.datetime(
                2014, 6, 1, 0, 0, 0, 0)))
예제 #4
0
def full_calendar(request):
    try:
        if schedule_permissions(request.user):
            schedule_boards = ScheduleBoard.objects.all().order_by(
                'start_date')
            if not schedule_boards:
                ScheduleBoard.objects.create(name="Unnamed")
                schedule_boards = ScheduleBoard.objects.all()
            calendar_configuration = CalendarConfiguration.objects.get()
            context = {
                'scheduleBoards':
                schedule_boards,
                'scroll_time':
                calendar_configuration.scroll_time.strftime('%H:%M:%S'),
                'first_day':
                calendar_configuration.first_day + 1,
                'language':
                request.LANGUAGE_CODE,
                'current_scheduleBoard':
                ScheduleBoard.get_current(datetime.datetime.now())
            }
            return render(request, 'dashboard/fullcalendar.html', context)
        else:
            return render(
                request, 'dashboard/fullcalendar_error.html', {
                    'error_info':
                    _('Sorry, you don\'t have enough permissions. Please contact your administrator.'
                      )
                })
    except CalendarConfiguration.DoesNotExist:
        return render(
            request, 'dashboard/fullcalendar_error.html', {
                'error_info':
                _('Calendar Configuration not found. Please contact your administrator.'
                  )
            })