Exemplo n.º 1
0
def check_event_in_db(instance, info, event_check, **kwargs):
    room_id = RoomSchedules().check_event_status(info, **kwargs)
    event = EventsModel.query.filter_by(
        start_time=kwargs['start_time'],
        event_id=kwargs['event_id']).scalar()
    if event and event_check == 'cancelled':
        event.cancelled = True
        event.auto_cancelled = True
        event.save()
        return room_id, event
    elif event and event_check == 'checked_in':
        event.checked_in = True
        if 'check_in_time' in kwargs:
            event.check_in_time = kwargs['check_in_time']
        else:
            event.check_in_time = None
        event.save()
        return room_id, event
    elif event and event_check == 'ended':
        if event.meeting_end_time:
            raise GraphQLError("Event has already ended")
        event.meeting_end_time = kwargs['meeting_end_time']
        event.save()
        return room_id, event
    return room_id, event
Exemplo n.º 2
0
 def test_response_event(self):
     """ This function tests for type of response
     of the response to see if its a googleapi object
     RoomSchedule function
     """
     calendarId = '*****@*****.**'  # noqa: E501
     response = RoomSchedules.get_room_schedules(self, calendarId, 7)
     assert type(response) is list
     self.assertNotEquals(response, [])
Exemplo n.º 3
0
 def resolve_room_schedule(self, info, calendar_id, days):
     query = Room.get_query(info)
     Query.check_valid_calendar_id(self, query, calendar_id)
     room_schedule = RoomSchedules.get_room_schedules(
         self,
         calendar_id,
         days)
     return Calendar(
         events=room_schedule[1]
     )
Exemplo n.º 4
0
 def resolve_analytics_for_daily_room_events(self, info, **kwargs):
     start_date = kwargs.get('start_date')
     end_date = kwargs.get('end_date')
     location_id = admin_roles.user_location_for_analytics_view()
     start_date, end_date = CommonAnalytics().convert_dates(
         start_date, end_date)
     query = Room.get_query(info)
     all_events, all_dates = RoomSchedules().get_all_room_schedules(
         query, start_date, end_date, location_id)
     all_days_events = []
     for date in set(all_dates):
         daily_events = []
         for event in all_events:
             if date == event["date_of_event"]:
                 current_event = CalendarEvent(
                     no_of_participants=event["no_of_participants"],
                     event_summary=event["event_summary"],
                     start_time=event["start_time"],
                     end_time=event["end_time"],
                     room_name=event["room_name"],
                     event_id=event["event_id"],
                     cancelled=event["cancelled"],
                     state=event["state"],
                     checked_in=event["checked_in"],
                     check_in_time=event["check_in_time"],
                     meeting_end_time=event["meeting_end_time"])
                 daily_events.append(current_event)
         all_days_events.append(DailyEvents(day=date, events=daily_events))
     page = kwargs.get('page')
     per_page = kwargs.get('per_page')
     if page and per_page:
         paginated_results = ListPaginate(iterable=all_days_events,
                                          per_page=per_page,
                                          page=page)
         current_page = paginated_results.current_page
         has_previous = paginated_results.has_previous
         has_next = paginated_results.has_next
         pages = paginated_results.pages
         return PaginatedEvents(DailyRoomEvents=current_page,
                                has_next=has_next,
                                has_previous=has_previous,
                                pages=pages)
     return PaginatedEvents(DailyRoomEvents=all_days_events)
Exemplo n.º 5
0
 def room_occupants_room_schedule(self, info, calender_id, days):
     query = Room.get_query(info)
     Query.check_valid_calendar_id(self, query, calender_id)
     resource = RoomSchedules.get_room_schedules(self, calender_id, days)
     return resource