def classroom(request, slug): rooms = Classroom.get_in_institute(reservation=True) try: room = Classroom.get_by_slug(slug) except ObjectDoesNotExist: raise Http404 return TemplateResponse(request, 'schedule/classroom.html', locals())
def room104(): room = Classroom( type=1, description='Sala cwiczeniowa', number='104', building='Instytut Informatyki', capacity=32, floor=1, can_reserve=True ) room.full_clean() return room
def room110(): room = Classroom( type=3, description='Pracownia z najszybszymi komputerami w instytucie', number='110', building='Instytut Informatyki', capacity=20, floor=1, can_reserve=True ) room.full_clean() return room
def events_report(request): from .forms import ReportForm if request.method == 'POST': form = ReportForm(request.POST) form.fields["rooms"].choices = [(x.pk, x.number) for x in Classroom.get_in_institute(reservation=True)] if form.is_valid(): beg_date = form.cleaned_data["beg_date"] end_date = form.cleaned_data["end_date"] rooms = form.cleaned_data["rooms"] return events_raport_pdf(request, beg_date, end_date, rooms) else: form = ReportForm() form.fields["rooms"].choices = [(x.pk, x.number) for x in Classroom.get_in_institute(reservation=True)] return TemplateResponse(request, 'schedule/events_report.html', locals())
def test_reservation_created_terms(self): terms = EventTerm.get_terms_for_dates( [date(2016, 5, 12)], Classroom.get_by_number('110'), time(15), time(16) ) '''
def test_clean__overlapping_term(self): event = Event.objects.all()[0] room110 = Classroom.get_by_number('110') term = EventTerm( event=event, day=date(2016, 5, 20), start=time(15), end=time(17), room=room110 ) self.assertRaises(ValidationError, term.full_clean)
def test_clean_on_overlapping_reservation_where_both_are_same(self): semester = Semester.get_semester(date(2016, 5, 12)) # summer20152016 room = Classroom.get_by_number('110') reservation = SpecialReservation( semester=semester, title='overlapping', classroom=room, dayOfWeek=common.WEDNESDAY, start_time=time(15), end_time=time(16) )
def test_try_clean_on_overlapping_reservation(self): semester = Semester.get_semester(date(2016, 5, 12)) room = Classroom.get_by_number('110') reservation = SpecialReservation( semester=semester, title='overlapping', classroom=room, dayOfWeek=common.THURSDAY, start_time=time(14), end_time=time(16) )
def test_add_event_on_changed_day(self): classroom = Classroom.get_by_number('25') reservation = SpecialReservation.objects.in_classroom(classroom)[0] self.assertRaises( ValidationError, factories.TermThisYearFactory( day=self.thursday, start=reservation.start_time, end=reservation.end_time, room=classroom ).full_clean )
def test_check_theres_no_original_reservation_on_changed_day(self): classroom = Classroom.get_by_number('25') reservation = SpecialReservation.objects.in_classroom(classroom)[0] reserv_thursday = factories.SpecialReservationFactory.build( semester=reservation.semester, classroom=classroom, start_time=time(16, 15), end_time=time(18), dayOfWeek=common.THURSDAY ) reserv_thursday.full_clean() reserv_thursday.save(author_id=self.reservation_author.pk) ev = EventTerm.get_terms_for_dates( [self.thursday], classroom, start_time=reserv_thursday.start_time, end_time=reserv_thursday.end_time ) self.assertFalse(ev)
def classrooms(request): # Avoids lookup of non existing variable during template rendering room = None rooms = Classroom.get_in_institute(reservation=True) return TemplateResponse(request, 'schedule/classrooms.html', locals())
def ajax_get_terms(request, year, month, day): from apps.enrollment.courses.models.classroom import Classroom time = datetime.date(int(year), int(month), int(day)) terms = Classroom.get_terms_in_day(time, ajax=True) return HttpResponse(terms, content_type="application/json")
def test_event_is_present(self): room = Classroom.get_by_number('110') terms = EventTerm.get_terms_for_dates(dates=[date(2016, 5, 20)], classroom=room) self.assertTrue(terms)