Exemplo n.º 1
0
 def create_meeting(self,
                    start_time,
                    end_time,
                    order_id,
                    room_id,
                    date=datetime.utcnow().strftime('%d/%m/%y'),
                    participants=[]):
     if self.email not in participants:
         participants.append(self.email)
     Schedule.assign_all(date, participants, start_time, end_time, order_id,
                         room_id)
Exemplo n.º 2
0
 def aux_backtracking(cls, all_conflict_orders, index_order, all_rooms,
                      num_rooms, date, start_time, end_time):
     if index_order > len(all_conflict_orders) - 1:
         return True
     for i in range(num_rooms):
         if all_conflict_orders[index_order] <= all_rooms[i]:
             room = all_rooms[i]
             room_occupation_current = room.occupation_room(
                 date, start_time, end_time)
             order = all_conflict_orders[index_order]
             order_id = order.get_id()
             demanded_space = order.get_num_parctipents()
             participents_order = order.get_participents()
             after_occupency_room = room_occupation_current - demanded_space
             room_id = room.get_id_room()
             Schedule.assign_all(date, participents_order, start_time,
                                 end_time, order_id, room_id)
             #all_rooms[i] = room_occupation_current  - all_conflict_orders[index_order].
             return cls.aux_backtracking(all_conflict_orders,
                                         index_order + 1, all_rooms,
                                         num_rooms)
     return False
Exemplo n.º 3
0
 def simple_algo(cls, all_conflict_orders, all_rooms, date, start_time,
                 end_time):
     index_room = 0
     already_scheduled = []
     for order in all_conflict_orders:
         order_id = order.get_id()
         participents_order = order.get_participents()
         index_room = Room.get_next_room_from_list(all_rooms, index_room,
                                                   len(participents_order),
                                                   date, start_time,
                                                   end_time)
         if index_room == -1:
             cls.remove_conflict_schedule(already_scheduled, date,
                                          start_time, end_time)
             return False, "There is no room"
         room = all_rooms[index_room]
         room_id = room.get_id_room()
         Schedule.assign_all(date, participents_order, start_time, end_time,
                             order_id, room_id)
         scheds_by_order = Schedule.get_by_order(order_id)
         already_scheduled.append(scheds_by_order[0])
     return True, room_id
Exemplo n.º 4
0
    def new_order(self, date, participants, start_time, end_time, company,
                  facility):

        if self.email not in participants:
            participants.append(self.email)
        problematic_participants = Schedule.all_participants_are_free(
            date, participants, start_time, end_time)

        if len(problematic_participants) > 0:
            return False, problematic_participants
        min_permission = User.min_permission(participants)
        _id = self.email + ' ' + date + ' ' + str(start_time) + ' ' + str(
            end_time)
        status, order_id, room_id = Order.new_order(_id, self.email, date,
                                                    participants, start_time,
                                                    end_time, company,
                                                    facility, min_permission)

        if status:
            # not finish yet
            Schedule.assign_all(date, participants, start_time, end_time,
                                order_id, room_id)
            # self.create_meeting(start_time, end_time, order_id, room_id, date, participants)
        return status, order_id