Manual merge

This commit is contained in:
M.Ravi 2017-10-15 16:14:33 +02:00
commit e6f92d9ae4
6 changed files with 130 additions and 188 deletions

View file

@ -551,17 +551,16 @@ class SettingsView(LoginRequiredMixin, FormView):
context = super(SettingsView, self).get_context_data(**kwargs)
# Get user
user = self.request.user
# Get user last order
last_hosting_order = HostingOrder.objects.filter(
customer__user=user).last()
# If user has already an hosting order, get the credit card data from
# it
if last_hosting_order:
credit_card_data = last_hosting_order.get_cc_data()
context.update({
'credit_card_data': credit_card_data if credit_card_data else None,
})
# Get user's all orders
hosting_orders = HostingOrder.objects.filter(customer__user=user)
# If user has hosting orders, get the credit card data from it
cards_list = []
for order in hosting_orders:
credit_card_data = order.get_cc_data()
if credit_card_data and (credit_card_data not in cards_list):
cards_list.append(credit_card_data)
context.update({
'cards_list': cards_list,
'stripe_key': settings.STRIPE_API_PUBLIC_KEY
})