Ejemplo n.º 1
0
	def check_employee_exists(self, username):
		employees = session.query(Employee).filter(
			Employee.username == username
			).all()
		if len(employees) == 0:
			return True
		return False
Ejemplo n.º 2
0
	def check_username(self, username):
		employees = session.query(Employee).filter(
			Employee.username == username
			).all()
		if len(employees) == 1:
			return True 
		else:
			return False		
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
	def get_meetings_by_date_and_user(self, date, employee):
		meetings = session.query(Meeting).join(
			EmployeeMeeting).filter(
			Meeting.date == date).filter(
			EmployeeMeeting.employee == employee).filter(
			or_(
				EmployeeMeeting.pending == True,
				EmployeeMeeting.accepted == True
				)).all()
		return meetings
Ejemplo n.º 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
Ejemplo n.º 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()
Ejemplo n.º 7
0
	def get_all_employees(self):
		return session.query(Employee).all()
Ejemplo n.º 8
0
	def get_employee_by_username(self, username):
		employee = session.query(Employee).filter(Employee.username == username).one()
		return employee
Ejemplo n.º 9
0
	def get_employee(self, employee_id):
		employee = session.query(Employee).filter(Employee.id == employee_id).one()
		return employee
Ejemplo n.º 10
0
	def get_room_meetings_by_date(self, room, date):
		return session.query(Meeting).filter(Meeting.room == room.id).filter(Meeting.date == date).all()
Ejemplo n.º 11
0
	def get_room_by_name(self, roomname):
		room = session.query(Room).filter(Room.roomname == roomname).first()
		return room
Ejemplo n.º 12
0
	def get_all_rooms(self):
		return session.query(Room).all()
Ejemplo n.º 13
0
	def delete_employee(self, employee_id):
		employee = session.query(Employee).filter(Employee.id == employee_id).one()
		session.delete(employee)
		session.commit()
Ejemplo n.º 14
0
	def get_timeslot(self, timeslot_id):
		return session.query(TimeSlot).filter(TimeSlot.id == timeslot_id).one()
Ejemplo n.º 15
0
	def get_owned_meetings(self, owner_id):
		meetings = session.query(Meeting).filter(
			Meeting.owner == owner_id
			).all()
		return meetings
Ejemplo n.º 16
0
	def get_meetings_by_user(self, employee):
		meetings = session.query(Meeting).join(
			EmployeeMeeting).filter(
			EmployeeMeeting.employee == employee).all()
		return meetings	
Ejemplo n.º 17
0
	def get_employee_meeting(self, meeting_id, employee_id):
		return session.query(EmployeeMeeting).filter(
			EmployeeMeeting.meeting_id == meeting_id).filter(
			EmployeeMeeting.employee_id == employee_id).one()
Ejemplo n.º 18
0
	def get_room_by_id(self, room_id):
		room = session.query(Room).filter(Room.id == room_id).one()
		return room