예제 #1
0
	def delete_room(self, room):
		meetings = session.query(Meeting).filter(Meeting.room == room.id).all()
		for m in meetings:
			for em in m.employees:
				session.delete(em)
			session.delete(m)
		session.delete(room)
		session.commit()
예제 #2
0
	def update_employee_by_obj(self, employee):
		try:
			employee_id = employee.id 
			session.commit()
			return self.get_employee(employee_id)
		except Exception as e:
			session.rollback()
			handle_exception()
			return False
예제 #3
0
	def update_room_by_object(self, room_obj):
		try:
			room_id = room_obj.id 
			session.commit()
			return self.get_room_by_id(room_id)
		except Exception as e:
			session.rollback()
			handle_exception()
			return False
예제 #4
0
	def bulk_create_timeslots(self, times):
		_times = []
		for time in times:
			timeslot = TimeSlot(begin_time=time)
			session.add(timeslot)
			session.flush()
			_times.append(self.get_timeslot(timeslot.id))
		session.commit()
		return _times
예제 #5
0
	def add_room(self, roomname, number, building, capacity=None):
		try:
			if capacity:
				room = Room(roomname=roomname, number=number, building=building, capacity=capacity)
			else:
				room = Room(roomname=roomname, number=number, building=building)
			session.add(room)
			session.commit()
			room = session.query(Room).filter(Room.number == number).filter(Room.building == building).one()
			return room
		except Exception as e:
			session.rollback()
			handle_exception()
			return False
예제 #6
0
	def create_meeting(self, title, room_id, owner_id, date, timeslots=None, employees=None):
		meeting = Meeting(title=title, room=room_id, owner=owner_id, date=date)
		
		if employees:
			for employee in employees:
				rel = EmployeeMeeting()
				rel.employee = employee
				meeting.employees.append(rel)


		if timeslots:
			meeting.timeslots = timeslots

		session.add(meeting)
		session.flush()
		meeting_id = meeting.id
		session.commit()
		return session.query(Meeting).filter(Meeting.id == meeting_id).one()
예제 #7
0
	def decline_meeting(self, employee_meeting):
		employee_meeting.pending = False
		employee_meeting.accepted = False
		session.delete(employee_meeting)
		session.commit()			
예제 #8
0
	def add_employee(self, username, password):
		employee = Employee(username=username, password=password)
		session.add(employee)
		session.commit()
		return self.get_employee_by_username(username)
예제 #9
0
	def accept_meeting(self, employee_meeting):
		employee_meeting.pending = False
		employee_meeting.accepted = True
		session.commit()
예제 #10
0
	def update_employee_meeting(self, emp_meet, kwargs):
		for kwarg, value in kwargs.items():
			setattr(emp_meet, kwarg, value)
		session.commit()
예제 #11
0
	def update_employee(self, employee_id, kwargs):
		employee = self.get_employee(employee_id)
		for kwarg, value in kwargs.items():
			setattr(employee, kwarg, value)
		session.commit()
		return self.get_employee(employee_id)
예제 #12
0
	def delete_employee_obj(self, employee):
		for em in employee.meetings:
			session.delete(em)
		session.delete(employee)
		session.commit()
예제 #13
0
	def delete_employee(self, employee_id):
		employee = session.query(Employee).filter(Employee.id == employee_id).one()
		session.delete(employee)
		session.commit()
예제 #14
0
	def delete_meeting(self, meeting):
		for em in meeting.employees:
			session.delete(em)
		session.delete(meeting)
		session.commit()