예제 #1
0
def CurrentUserCard (request):
	if request.method == 'GET':
		if request.user.is_authenticated():
			helper = BalancedPaymentsHelper()
			card = helper.getBuyerCreditCardInfo(account_uri=request.user.appuser.bp_account)
			response_card = {}
			if card is not None:
				response_card = {'last_four': card.last_four, 'expiration_year': card.expiration_year,
				                 'expiration_month': card.expiration_month, 'card_type': card.card_type}
			else:
				response_card = {'card_type': 'none', }
			response = json.dumps(response_card)
			return HttpResponse(response, mimetype="application/json")
예제 #2
0
def send_order_receipt_email (order):
	from BarApp.models import BarDrinkOrdered, BarOrder

	html_email = ''
	with open(settings.SETTINGS_PATH + "/resources/user_receipt.html", "r") as receipt_html:
		html_email = receipt_html.read().replace('\n', '')

	receipt_template = template.Template(html_email)
	drinks_ordered = BarDrinkOrdered.objects.filter(order=order)
	helper = BalancedPaymentsHelper()
	card = helper.getBuyerCreditCardInfo(account_uri=order.appuser.bp_account)

	receipt_context = template.Context({'order': order, 'drinks_list':drinks_ordered, 'card':card})

	email_args = {'user': order.appuser.user,
	              'subject': 'Your receipt for order {order_id}'.format(order_id=order.pk),
	              'content': 'This is where the order information will be given.',
	              'html_content': receipt_template.render(receipt_context)}
	send_email_to_user(email_args)