Fixed issues reported by flake
This commit is contained in:
parent
c8cf166571
commit
8fb4607bdd
2 changed files with 23 additions and 27 deletions
|
@ -21,6 +21,7 @@ def change_lang(context, lang=None, *args, **kwargs):
|
|||
|
||||
return "%s" % url
|
||||
|
||||
|
||||
@register.filter('get_value_from_dict')
|
||||
def get_value_from_dict(dict_data, key):
|
||||
"""
|
||||
|
@ -28,5 +29,5 @@ def get_value_from_dict(dict_data, key):
|
|||
"""
|
||||
if key:
|
||||
return dict_data.get(key)
|
||||
else :
|
||||
else:
|
||||
return ""
|
||||
|
|
|
@ -14,12 +14,10 @@ from django.views.decorators.cache import cache_control
|
|||
from django.conf import settings
|
||||
from utils.forms import BillingAddressForm, UserBillingAddressForm
|
||||
from utils.models import BillingAddress
|
||||
from membership.models import StripeCustomer
|
||||
from hosting.models import HostingOrder, HostingBill
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from datetime import datetime
|
||||
from membership.models import CustomUser, StripeCustomer
|
||||
from oca.pool import WrongIdError
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer
|
||||
|
||||
|
@ -39,11 +37,13 @@ class SuccessView(TemplateView):
|
|||
elif 'order_confirmation' not in request.session:
|
||||
return HttpResponseRedirect(reverse('datacenterlight:order_confirmation'))
|
||||
else:
|
||||
for session_var in ['specs', 'user', 'template', 'billing_address', 'billing_address_data', 'token', 'customer']:
|
||||
for session_var in ['specs', 'user', 'template', 'billing_address', 'billing_address_data',
|
||||
'token', 'customer']:
|
||||
if session_var in request.session:
|
||||
del request.session[session_var]
|
||||
return render(request, self.template_name)
|
||||
|
||||
|
||||
class PricingView(TemplateView):
|
||||
template_name = "datacenterlight/pricing.html"
|
||||
|
||||
|
@ -74,7 +74,6 @@ class PricingView(TemplateView):
|
|||
price = request.POST.get('total')
|
||||
|
||||
template_id = int(request.POST.get('config'))
|
||||
|
||||
manager = OpenNebulaManager()
|
||||
template = manager.get_template(template_id)
|
||||
|
||||
|
@ -199,7 +198,7 @@ class IndexView(CreateView):
|
|||
del request.session['specs']
|
||||
if 'user' in request.session:
|
||||
del request.session['user']
|
||||
if 'billing_address_data' in request.session :
|
||||
if 'billing_address_data' in request.session:
|
||||
del request.session['billing_address_data']
|
||||
try:
|
||||
manager = OpenNebulaManager()
|
||||
|
@ -327,7 +326,6 @@ class PaymentOrderView(FormView):
|
|||
})
|
||||
return form_kwargs
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(PaymentOrderView, self).get_context_data(**kwargs)
|
||||
context.update({
|
||||
|
@ -349,9 +347,8 @@ class PaymentOrderView(FormView):
|
|||
billing_address_data = form.cleaned_data
|
||||
token = form.cleaned_data.get('token')
|
||||
user = request.session.get('user')
|
||||
|
||||
try:
|
||||
custom_user = CustomUser.objects.get(email=user.get('email'))
|
||||
CustomUser.objects.get(email=user.get('email'))
|
||||
except CustomUser.DoesNotExist:
|
||||
password = CustomUser.get_random_password()
|
||||
# Register the user, and do not send emails
|
||||
|
@ -397,8 +394,8 @@ class OrderConfirmationView(DetailView):
|
|||
card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token'))
|
||||
context = {
|
||||
'site_url': reverse('datacenterlight:index'),
|
||||
'cc_last4' : card_details.get('response_object').get('last4'),
|
||||
'cc_brand' : card_details.get('response_object').get('brand')
|
||||
'cc_last4': card_details.get('response_object').get('last4'),
|
||||
'cc_brand': card_details.get('response_object').get('brand')
|
||||
}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
@ -411,7 +408,6 @@ class OrderConfirmationView(DetailView):
|
|||
billing_address_data = request.session.get('billing_address_data')
|
||||
billing_address_id = request.session.get('billing_address')
|
||||
billing_address = BillingAddress.objects.filter(id=billing_address_id).first()
|
||||
token = request.session.get('token')
|
||||
vm_template_id = template.get('id', 1)
|
||||
final_price = specs.get('price')
|
||||
|
||||
|
@ -423,10 +419,9 @@ class OrderConfirmationView(DetailView):
|
|||
|
||||
# Check if the payment was approved
|
||||
if not charge:
|
||||
context = {}
|
||||
context.update({
|
||||
'paymentError': charge_response.get('error')
|
||||
# TODO add logic in payment form to autofill data
|
||||
#'form': form
|
||||
})
|
||||
return render(request, self.payment_template_name, context)
|
||||
|
||||
|
@ -455,7 +450,7 @@ class OrderConfirmationView(DetailView):
|
|||
)
|
||||
|
||||
# Create a Hosting Bill
|
||||
bill = HostingBill.create(
|
||||
HostingBill.create(
|
||||
customer=customer, billing_address=billing_address)
|
||||
|
||||
# Create Billing Address for User if he does not have one
|
||||
|
|
Loading…
Reference in a new issue