def put(self, new_data, meeting_id): """Update a Meeting [Protected] Args: new_data ([type]): [description] meeting_id (int): The Meeting id Only send what has changed """ user_id = get_jwt_identity() user = user_crud.get(user_id) meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort( 401, message="You don't have permission to update this Meeting") if not meeting: abort(404, message="Meeting does not exist") meeting = meeting_crud.get(meeting_id) meeting = meeting_crud.update(meeting, new_data) if not meeting['added']: abort(409, message="Meeting with this name exits for this user") meeting = meeting['db_obj'] return meeting
def put(self, new_data, agenda_id): """Marks an Agenda as Completeted Args: new_data ([type]): [description] agenda_id (int): The agenda unique id Returns: Agenda: an agenda object """ user_id = get_jwt_identity() user = user_crud.get(user_id) agenda = agenda_crud.get(agenda_id) meeting_id = agenda_crud.get_meeting_id(agenda=agenda) if not user.is_superuser: meeting = meeting_crud.get(meeting_id) if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort( 401, message="You don't have permission to complete this agenda" ) _meeting = meeting_crud.get(meeting_id) if not meeting_crud.is_meeting_started(_meeting): abort(409, message="Start the meeting first") if agenda.completed: abort(409, message="Agenda Already Completed") agenda = agenda_crud.completed(agenda, new_data['final_duration']) meeting_crud.update_meeting_final_endtime(_meeting, new_data['final_duration']) if agenda_crud.is_all_agenda_completed(meeting_id=meeting_id): meeting_crud.completed(meeting_id=meeting_id) return agenda
def post(self, new_data): """Create a new Agenda - [PROTECTED] Args: new_data ([type]): [description] """ user_id = get_jwt_identity() meeting = meeting_crud.get(new_data['meeting_id']) if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort(401, message="You don't have permission to add agenda to meeting") if not meeting: abort(404, message="Meeting does not exist") if meeting_crud.is_meeting_started(meeting): abort(409, message="Can not add agenda to an ungoing meeting") agenda = agenda_crud.create(new_data) if not agenda['added']: abort(409, message="Agenda with same name exits in this meeting") agenda = agenda['db_obj'] meeting_crud.update_meeting_endtime(new_data['meeting_id'], agenda.set_duration) return agenda
def delete(self, agenda_id): """Delete an Agenda [Protected] Args: new_data ([type]): [description] agenda_id (int): The Agenda id """ user_id = get_jwt_identity() user = user_crud.get(user_id) agenda = agenda_crud.get(agenda_id) if not agenda: abort(404, message="Agenda does not exist") meeting_id = agenda_crud.get_meeting_id(agenda=agenda) if not user.is_superuser: meeting_id = agenda_crud.get_meeting_id(agenda=agenda) meeting = meeting_crud.get(meeting_id) if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort( 401, message="You don't have permission to remove this agenda") meeting_crud.update_meeting_endtime(meeting_id, -(agenda.set_duration)) agenda_crud.remove(agenda_id) return {'msg': 'Agenda Removed'}
def post(self, new_data): """End A Meeting [Protected] Args: new_data ([type]): [description] Returns: [type]: [description] """ user_id = get_jwt_identity() user = user_crud.get(user_id) meeting_id = new_data['meeting_id'] meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort(401, message="You don't have permission to get agendas") if not meeting: abort(404, message="Meeting does not exist") if not meeting_crud.is_meeting_started(meeting): abort(409, message="This meeting has not started") if meeting.completed: abort(409, message="This meeting has ended") meeting = meeting_crud.end_meeting(meeting_id, new_data['end_time']) return meeting
def post(self, new_data): """Start A Meeting [Protected] Args: new_data ([type]): [description] Returns: [type]: [description] """ user_id = get_jwt_identity() user = user_crud.get(user_id) meeting_id = new_data['meeting_id'] meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort( 401, message="You don't have permission to start this meeting") if not meeting: abort(404, message="Meeting does not exist") if meeting_crud.is_meeting_started(meeting): abort(409, message="You already started the meeting") meeting = meeting_crud.start_meeting(new_data) return meeting
def get(self, meeting_id: int): """Get A Meeting Agenda(s) [Protected] """ user_id = get_jwt_identity() user = user_crud.get(user_id) meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort(401, message="You don't have permission to get agendas") if not meeting: abort(404, message="Meeting does not exist") agendas = meeting_crud.get_meeting_agendas(meeting=meeting) return agendas
def put(self, new_data, agenda_id): """Update an Agenda [Protected] Args: new_data ([type]): [description] agenda_id (int): The Agenda id Only send what has changed """ user_id = get_jwt_identity() user = user_crud.get(user_id) agenda = agenda_crud.get(agenda_id) set_duration = agenda.set_duration meeting_id = agenda_crud.get_meeting_id(agenda=agenda) meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort( 401, message="You don't have permission to update this agenda") if not agenda: abort(404, message="Agenda does not exist") if meeting_crud.is_meeting_started(meeting): abort(409, message="Can't update an agenda in an ungoing meeting") new_agenda = agenda_crud.update(agenda, new_data) if not new_agenda['added']: abort(409, message="Agenda with same name exits in this meeting") new_agenda = new_agenda['db_obj'] if new_data['set_duration']: data = { "set_duration": ((meeting.set_duration - set_duration) + new_agenda.set_duration), "set_end_time": time_plus(time_subtract(meeting.set_end_time, set_duration), new_agenda.set_duration) } meeting_crud.update(meeting, data) return new_agenda
def get(self, meeting_id): """Get a Meeting [Protected] Args: new_data ([type]): [description] meeting_id (int): The Meeting id """ user_id = get_jwt_identity() user = user_crud.get(user_id) meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort(401, message="You don't have permission to view this Meeting") if not meeting: abort(404, message="Meeting does not exist") return meeting
def get(self, agenda_id): """Get an Agenda [Protected] Args: new_data ([type]): [description] agenda_id (int): The Agenda id """ user_id = get_jwt_identity() user = user_crud.get(user_id) agenda = agenda_crud.get(agenda_id) if not agenda: abort(404, message="Agenda does not exist") if not user.is_superuser: meeting_id = agenda_crud.get_meeting_id(agenda=agenda) meeting = meeting_crud.get(meeting_id) if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort(401, message="You don't have permission to view this agenda") return agenda
def delete(self, meeting_id): """Delete a Meeting [Protected] Args: new_data ([type]): [description] meeting_id (int): The Meeting id """ user_id = get_jwt_identity() user = user_crud.get(user_id) meeting = meeting_crud.get(meeting_id) if not user.is_superuser: if not meeting_crud.is_user_meeting(user_id=user_id, meeting=meeting): abort( 401, message="You don't have permission to remove this Meeting") if not meeting: abort(404, message="Meeting does not exist") meeting_crud.remove(meeting_id) return {'msg': 'User Removed'}