Пример #1
0
 def mutate(self, info, **kwargs):
     validate_empty_fields(**kwargs)
     verify_location_id(kwargs)
     query = RoomModel.query
     validate_room_labels(**kwargs, query=query)
     validate_structure_id(**kwargs)
     admin_roles.create_rooms_update_delete_location(kwargs)
     query = Room.get_query(info)
     active_rooms = query.filter(RoomModel.state == "active")
     query_result = [room for room in active_rooms
                     if room.calendar_id == kwargs.get('calendar_id')]
     if query_result:
         ErrorHandler.check_conflict(
             self, kwargs['calendar_id'], 'CalenderId')
     exact_query = room_join_location(active_rooms)
     result = exact_query.filter(
         RoomModel.name == kwargs.get('name'),
         RoomModel.state == "active",
         RoomModel.location_id == kwargs.get('location_id')
     )
     if result.count():
         ErrorHandler.check_conflict(self, kwargs['name'], 'Room')
     room_tags = []
     if kwargs.get('room_tags'):
         room_tags = kwargs.pop('room_tags')
     room = RoomModel(**kwargs)
     save_room_tags(room, room_tags)
     requests.get(url=Config.MRM_PUSH_URL + "/add_room",
                  params={"calendar_id": room.calendar_id,
                          "firebase_token": room.firebase_token})
     return CreateRoom(room=room)
Пример #2
0
 def mutate(self, info, **kwargs):
     validate_structure_id(**kwargs)
     office_structure = []
     for each_structure in kwargs['data']:
         node = create_structure(**each_structure)
         office_structure.append(node)
     return CreateOfficeStructure(structure=office_structure)
Пример #3
0
 def mutate(self, info, room_id, **kwargs):
     validate_empty_fields(**kwargs)
     if kwargs.get('structure_id'):
         validate_structure_id(**kwargs)
     query_room = Room.get_query(info)
     active_rooms = query_room.filter(RoomModel.state == "active")
     room = active_rooms.filter(RoomModel.id == room_id).first()
     if not room:
         raise GraphQLError("Room not found")
     admin_roles.update_delete_rooms_create_resource(room_id)
     room_tags = []
     if kwargs.get('room_tags'):
         room_tags = kwargs.pop('room_tags')
     update_entity_fields(room, **kwargs)
     previous_tags = room.room_tags
     previous_tags.clear()
     save_room_tags(room, room_tags)
     return UpdateRoom(room=room)