Example #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); 
Example #2
0
def getChemicalSpeciationData(request_dict):
    """
	CTS web service endpoint for getting
	chemical speciation data through  the
	chemspec model/class
	:param request - chemspec_model
	:return: chemical speciation data response json
	"""

    try:

        logging.info(
            "Incoming request for speciation data: {}".format(request_dict))

        filtered_smiles = SMILESFilter().filterSMILES(
            request_dict.get('chemical'))
        logging.info("Speciation filtered SMILES: {}".format(filtered_smiles))
        request_dict['chemical'] = filtered_smiles

        django_request = HttpResponse()
        django_request.POST = request_dict
        django_request.method = 'POST'

        chemspec_obj = chemspec_output.chemspecOutputPage(django_request)

        wrapped_post = {
            'status': True,  # 'metadata': '',
            'data': chemspec_obj.run_data
        }
        json_data = json.dumps(wrapped_post)

        logging.info("chemspec model data: {}".format(chemspec_obj))

        return HttpResponse(json_data, content_type='application/json')

    except Exception as error:
        logging.warning(
            "Error in cts_rest, getChemicalSpecation(): {}".format(error))
        return HttpResponse("Error getting speciation data")
Example #3
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);