def ride_request_dtos(): riderequestdtos = [ RideRequestDto( user_id= 1, source= "hyderabad", destination= "bangloor", is_flexible= False, from_datetime= "", to_datetime= "", datetime= "", no_of_seats= 2, luggage_quantity= 2, accepted_person_id= 2, ), RideRequestDto( user_id= 1, source= "Mumbai", destination="Delhi", is_flexible= False, from_datetime= "", to_datetime= "", datetime= "", no_of_seats= 2, luggage_quantity= 2, accepted_person_id= 1 ) ] return riderequestdtos
def ride_request_dtos(): riderequestdtos = [ RideRequestDto(user_id=1, source="Mumbai", destination="Delhi", flexible=False, from_datetime='None', to_datetime='None', datetime="2020-09-04 14:00:00+00:00", no_of_seats=2, luggage_quantity=2, accepted_person_id=1), RideRequestDto( user_id=1, source="hyderabad", destination="bangloor", flexible=True, from_datetime="2020-09-05 14:00:00+00:00", to_datetime="2020-09-05 14:00:00+00:00", datetime='None', no_of_seats=2, luggage_quantity=2, accepted_person_id=2, ) ] return riderequestdtos
def get_matching_ride_requests_dto_with_flexible_timings( self, ride_share_to_datetime: datetime, ride_share_from_datetime: datetime, ride_share_source: str,ride_share_destination: str): matching_ride_request_objs = RideRequestDto.objects.filter( from_datetime__lt=ride_share_ to_datetime,from_datetime__gte=from_datetime, to_datetime__lt=to_datetime,from_datetime__gte=from_datetime, source=ride_share_source,destination=ride_share_destination ) list_of_ride_requests=[] for request in matching_ride_request_objs: ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=str(request.datetime), from_datetime=str(request.from_datetime), to_datetime=str(request.to_datetime), no_of_seats=request.no_of_seats, luggage_quantity=request.luggage_quantity, accepted_person_id=request.accepted_person_id ) list_of_ride_requests.append(ride_request_dto) return list_of_ride_requests
def ride_request_dto2(): riderequestdto = RideRequestDto( user_id= 1, source= "Mumbai", destination= "delhi", is_flexible= False, from_datetime=None, to_datetime= None, datetime= datetime(2020, 9, 4, 0, 3), no_of_seats= 2, luggage_quantity= 2, accepted_person_id= 2, ) return riderequestdto
def ride_request_dto1_with_accepted_person_none(): riderequestdto =RideRequestDto( user_id= 1, source= "hyderabad", destination= "bangloor", is_flexible= True, from_datetime= datetime(2020, 9, 4, 0, 3), to_datetime= datetime(2020, 9, 5, 0, 3), datetime= "", no_of_seats= 2, luggage_quantity= 2, accepted_person_id= None, ) return riderequestdto
def matched_ride_request_dto(): ride_request_dto = [ RideRequestDto(user_id=3, source='hyderabad', destination='kurnool', is_flexible=False, from_datetime='None', to_datetime='None', datetime='2020-08-02 16:22:48.548978+00:00', no_of_seats=2, luggage_quantity=5, accepted_person_id=None) ] return ride_request_dto
def convert_ride_request_obj_to_dto_without_flexible_timings(self, request): ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=request.datetime.replace(tzinfo=None), from_datetime=request.from_datetime, to_datetime=request.to_datetime, no_of_seats=request.no_of_seats, luggage_quantity=request.luggage_quantity, accepted_person_id=request.accepted_person_id ) return ride_request_dto
def get_ride_request_dtos_for_given_ride_request_objects( self, list_of_ride_request_objs): list_of_ride_requests = [] print("***************list_of_ride_request_objs*******************", list_of_ride_request_objs) for requests in list_of_ride_request_objs: for request in requests: if request: if request.flexible: ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=request.datetime, from_datetime=request.from_datetime.replace( tzinfo=None), to_datetime=request.to_datetime.replace( tzinfo=None), no_of_seats=request.no_of_seats, luggage_quantity=request.luggage_quantity, accepted_person_id=request.accepted_person_id) list_of_ride_requests.append(ride_request_dto) else: ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=request.datetime.replace(tzinfo=None), from_datetime=request.from_datetime, to_datetime=request.to_datetime, no_of_seats=request.no_of_seats, luggage_quantity=request.luggage_quantity, accepted_person_id=request.accepted_person_id) list_of_ride_requests.append(ride_request_dto) return list_of_ride_requests
def ride_request_dto1(): riderequestdto = [ RideRequestDto( user_id=1, source="hyderabad", destination="bangloor", is_flexible=True, from_datetime="2020-09-04 06:00:00.000000", to_datetime="2020-09-05 06:00:00.000000", datetime="", no_of_seats=2, luggage_quantity=2, accepted_person_id=1, ), ] return riderequestdto
def ride_request_dto2(): riderequestdto = [ RideRequestDto( user_id=1, source="Mumbai", destination="delhi", flexible=False, from_datetime=None, to_datetime=None, datetime="2020-09-05 06:00:00", no_of_seats=2, luggage_quantity=2, accepted_person_id=2, ), ] return riderequestdto
def ride_request_dtos(): riderequestdtos = [ RideRequestDto( user_id=1, source="hyderabad", destination="bangloor", is_flexible=True, from_datetime=datetime(2020, 9, 3, 13, 30), to_datetime=datetime(2020, 9, 4, 13, 30), datetime=None, no_of_seats=2, luggage_quantity=2, accepted_person_id=2, ) ] return riderequestdtos
def get_my_ride_requests_dto(self, user_id: int, limit: int, offset: int): list_of_ride_request_objs = RideRequest.objects.filter(user_id=user_id)[offset:limit] list_of_ride_requests=[] for request in list_of_ride_request_objs: ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=str(request.datetime), from_datetime=str(request.from_datetime), to_datetime=str(request.to_datetime), no_of_seats=request.no_of_seats, luggage_quantity=request.luggage_quantity, accepted_person_id=request.accepted_person_id ) list_of_ride_requests.append(ride_request_dto) return list_of_ride_requests
def get_my_ride_requests_dto(self, user_id: int)->int: list_of_ride_requests = RideRequest.objects.get(user_id=user_id) list_of_ for request in list_of_ride_requests: ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=request.datetime, from_datetime=request.from_datetime, to_datetime=request.to_datetime, no_of_seats=request.no_of_seats, assets_quantity=request.assets_quantity, return def
def get_ride_request_dtos_for_given_ride_request_objects( self, list_of_ride_request_objs): list_of_ride_requests = [] for queryset in list_of_ride_request_objs: for request in queryset: print("******", request) ride_request_dto = RideRequestDto( user_id=request.user_id, source=request.source, destination=request.destination, flexible=request.flexible, datetime=request.datetime, from_datetime=request.from_datetime, to_datetime=request.to_datetime, no_of_seats=request.no_of_seats, luggage_quantity=request.luggage_quantity, accepted_person_id=request.accepted_person_id) list_of_ride_requests.append(ride_request_dto) return list_of_ride_requests