Exemple #1
0
def boot_passenger(request):
	netid = request.session['netid'];
	current_user = User.objects.filter(netid=netid)[0]; # assume unique netids

	this_ride = Ride.objects.filter(id=request.GET.get('ride_id'))[0];
	this_user = Passenger.objects.filter(id=request.GET.get('user_id'))[0];


	# boot the passenger
	this_ride.passengers.remove(this_user);

	# send that passenger a message
	boot_title = "Removal: Automatically Generated Message";
	boot_content = "Hello! " + str(current_user) + " has rudely discareded you from their ride from " + str(this_ride.start) + " to " + str(this_ride.end) + " on " + str(this_ride.start_date) + ". Our server is sending you this message, which is pretty cool, yo!"
	boot_sender = current_user;
	boot_recipients = [this_user.person];
	message_make(boot_title, boot_content, boot_sender, boot_recipients);


	request = HttpResponse();
	request.path = '/driver_future/'
	request.method = 'GET';
	request.session = {'netid': netid};
	request.GET = {"id": this_ride.id,};
	request.META = {};
	return driver_future(request); 
Exemple #2
0
def choose_passenger(request):
	netid = request.session['netid'];
	current_user = User.objects.filter(netid=netid)[0]; # assume unique netids

	this_ride = Ride.objects.filter(id=request.GET.get('ride_id'))[0];
	this_user = Passenger.objects.filter(id=request.GET.get('user_id'))[0];

	option_approve = request.GET.get('Approve', False);
	option_decline = request.GET.get('Decline', False);

	if option_approve:
		this_ride.pending_passengers.remove(this_user);
		this_ride.passengers.add(this_user);
		# send message
		accept_title = "Accepted To Ride: Automatically Generated Message";
		accept_content = "Hello! " + str(current_user) + " has begrudgingly accepted you to their ride from " + str(this_ride.start) + " to " + str(this_ride.end) + " on " + str(this_ride.start_date) + ". Our server is sending you this message, which is pretty cool, yo!"
		accept_recipients = [this_user.person];
		accept_sender = current_user;
		message_make(accept_title, accept_content, accept_sender, accept_recipients);

	if option_decline:
		this_ride.pending_passengers.remove(this_user);
		# send message
		decline_title = "Declined From Ride: Automatically Generated Message";
		decline_content = "Hello! " + str(current_user) + " has cruelly declined your request to join their ride from " + str(this_ride.start) + " to " + str(this_ride.end) + " on " + str(this_ride.start_date) + ". Our server is sending you this message, which is pretty cool, yo!"
		decline_sender = current_user;
		decline_recipients = [this_user.person];
		message_make(decline_title, decline_content, decline_sender, decline_recipients);



	request = HttpResponse();
	request.path = '/driver_future/'
	request.method = 'GET';
	request.session = {'netid': netid};
	request.GET = {"id": this_ride.id,};
	request.META = {};
	return driver_future(request);