Exemplo n.º 1
0
 def handle(self, *args, **options):
     today = date.today()
     print('Creating user test with password test')
     self._create_user('test', '*****@*****.**', 'test')
     # Create a hotel
     hotel = Venue(name='HotelABC', address='1 Lane', city='Los Angeles',
                   zipcode='90000')
     hotel.save()
     print('Created Hotel: %s' % hotel)
     # Create Rooms
     room1 = Room(venue=hotel, room_number='1')
     room1.save()
     print('Created Room: %s' % room1)
     room2 = Room(venue=hotel, room_number='2')
     room2.save()
     print('Created Room: %s' % room2)
     room3 = Room(venue=hotel, room_number='3')
     room3.save()
     print('Created Room: %s' % room3)
     # Create Guests
     guest1 = Guest(name='Guest 1', address='ABC', city='Los Angeles',
                    zipcode='90000')
     guest1.save()
     print('Created Guest: %s' % guest1)
     guest2 = Guest(name='Guest 2', address='BOS', city='Boston',
                    zipcode='40000')
     guest2.save()
     print('Created Guest: %s' % guest2)
     # Create a Reservation
     # Guest 1 for 3 days starting today
     three_days = timedelta(days=3)
     reservation1 = Reservation(venue=hotel, room=room1, guest=guest1,
                                amount=300, checkin=today,
                                checkout=today + three_days)
     reservation1.save()
     print('Created Reservation #1: %s' % reservation1)
     # Guest 2 for 5 days starting today
     checkin = today + timedelta(days=2)
     five_days = timedelta(days=5)
     reservation2 = Reservation(venue=hotel, room=room2, guest=guest2,
                                amount=500, checkin=today,
                                checkout=today + five_days)
     reservation2.save()
     print('Created Reservation #2: %s' % reservation2)
     # Save the reservation in Calendar for future in 30 days
     self._create_calendar(today, today + timedelta(days=30))
Exemplo n.º 2
0
 def save(cls, data, instance=None):
     try:
         room = instance if instance else Room()
         for key, value in data.items():
             setattr(room, key, value)
         room.save()
         return room
     except Exception as ex:
         # todo: handle log
         raise ex
Exemplo n.º 3
0
    def setUp(self):
        first_room = Room(room_number=1, room_name="Deluxe")
        first_room.save()
        second_room = Room(room_number=2, room_name="Combo")
        second_room.save()
        first_reservation = Reservation(first_name="Bat",
                                        last_name="Dorj",
                                        e_mail_address="*****@*****.**",
                                        country_name="MN",
                                        address="this_address",
                                        phone_number="C12345678")
        first_reservation.save()

        second_reservation = Reservation(first_name="Bayar",
                                         last_name="Bold",
                                         e_mail_address="*****@*****.**",
                                         country_name="MN",
                                         address="this_address",
                                         phone_number="C9999999")
        second_reservation.save()
Exemplo n.º 4
0
def rooms_create(request):
    name = request.POST.get('roomName')
    floor_id = request.POST.get('floorId')
    room = Room()
    room.name = name
    room.floor_id = floor_id
    room.latitude = request.POST.get('roomLatitude')
    room.longitude = request.POST.get('roomLongitude')
    room.feature_collection = request.POST.get('roomFeatureCollection')
    room.save()
    return redirect('/')
Exemplo n.º 5
0
    def post(self, request):
        type = request.POST["type"]
        service = request.POST["service"]
        images = request.POST["image"]
        description = request.POST["description"]
        price = request.POST["price"]

        # print(type,service,images,description,price)

        data = Room(type=type,
                    service=service,
                    images=images,
                    description=description,
                    price=price)
        data.save()
        return render(request, 'core/room.html')
Exemplo n.º 6
0
def _get_parsed_schedule_param(param_collection) -> ScheduleParam:
    def _str_to_array(str_values):
        values = []
        for i in str_values.split(","):
            if i != '':
                values.append(int(i))
        return array(values)

    ROOMS, TIMESLOTS, COURSES, INSTRUCTORS, COURSE_GROUPS = param_collection
    all_theory_courses = list(filter(lambda x: x[4] == "Theory", COURSES))
    all_theory_course_indices = [c[0] for c in all_theory_courses]

    # Rooms - col 3: allowed_courses
    for i in range(len(ROOMS)):
        allowed_course_idxs = ROOMS[i][3]
        if allowed_course_idxs == "ALL_THEORY":
            allowed_course_idxs = all_theory_course_indices
        elif allowed_course_idxs[:4] == "NOT:":
            not_allowed_courses = [
                int(i) for i in allowed_course_idxs[4:].split(',')
            ]
            allowed_course_idxs = []
            for c in range(len(COURSES)):
                if c not in not_allowed_courses:
                    allowed_course_idxs.append(c)
        else:
            allowed_course_idxs = [
                int(i) for i in allowed_course_idxs.split(',')
            ]
        ROOMS[i][3] = allowed_course_idxs

    # Instructors - col 2, 3
    for i in range(len(INSTRUCTORS)):
        INSTRUCTORS[i][2] = _str_to_array(INSTRUCTORS[i][2])
        INSTRUCTORS[i][3] = _str_to_array(INSTRUCTORS[i][3])

    # CourseGroups - col 2, 3
    for i in range(len(COURSE_GROUPS)):
        COURSE_GROUPS[i][2] = _str_to_array(COURSE_GROUPS[i][2])
        COURSE_GROUPS[i][3] = _str_to_array(COURSE_GROUPS[i][3])
    '''
    NOTE: the following sanity check can be deduced: (if NUM_OF_LECS_BEING_OFFERED > MAX_LECS_THAT_CAN_BE_OFFERED)
    '''

    for i in range(len(TIMESLOTS)):
        if TIMESLOTS[i][3] == '-':
            TIMESLOTS[i][3] = []
        elif len(TIMESLOTS[i][3]) == 1:
            TIMESLOTS[i][3] = [int(TIMESLOTS[i][3])]
        else:
            TIMESLOTS[i][3] = _str_to_array(TIMESLOTS[i][3])

    Rooms = [Room(r[0], r[1], r[2], r[3]) for r in ROOMS]
    Timeslots = [Timeslot(t[0], t[1], t[2], t[3]) for t in TIMESLOTS]
    Courses = [Course(c[0], c[1], c[2], c[3], c[4]) for c in COURSES]
    Instructors = [
        Instructor(i[0], i[1], i[2], i[3], i[4]) for i in INSTRUCTORS
    ]
    CourseGroups = [
        CourseGroup(cg[0], cg[1], cg[2], cg[3]) for cg in COURSE_GROUPS
    ]

    sections = _get_all_sections(Courses)
    daily_slots = _get_all_daily_slots(Timeslots)
    day_codes = _get_all_day_codes(Timeslots)

    return ScheduleParam(Rooms, Timeslots, Courses, Instructors, CourseGroups,
                         sections, daily_slots, day_codes)