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
 | 
					    return "%s" % url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@register.filter('get_value_from_dict')
 | 
					@register.filter('get_value_from_dict')
 | 
				
			||||||
def get_value_from_dict(dict_data, key):
 | 
					def get_value_from_dict(dict_data, key):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,12 +14,10 @@ from django.views.decorators.cache import cache_control
 | 
				
			||||||
from django.conf import settings
 | 
					from django.conf import settings
 | 
				
			||||||
from utils.forms import BillingAddressForm, UserBillingAddressForm
 | 
					from utils.forms import BillingAddressForm, UserBillingAddressForm
 | 
				
			||||||
from utils.models import BillingAddress
 | 
					from utils.models import BillingAddress
 | 
				
			||||||
from membership.models import StripeCustomer
 | 
					 | 
				
			||||||
from hosting.models import HostingOrder, HostingBill
 | 
					from hosting.models import HostingOrder, HostingBill
 | 
				
			||||||
from utils.stripe_utils import StripeUtils
 | 
					from utils.stripe_utils import StripeUtils
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
from membership.models import CustomUser, StripeCustomer
 | 
					from membership.models import CustomUser, StripeCustomer
 | 
				
			||||||
from oca.pool import WrongIdError
 | 
					 | 
				
			||||||
from opennebula_api.models import OpenNebulaManager
 | 
					from opennebula_api.models import OpenNebulaManager
 | 
				
			||||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer
 | 
					from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,11 +37,13 @@ class SuccessView(TemplateView):
 | 
				
			||||||
        elif 'order_confirmation' not in request.session:
 | 
					        elif 'order_confirmation' not in request.session:
 | 
				
			||||||
            return HttpResponseRedirect(reverse('datacenterlight:order_confirmation'))
 | 
					            return HttpResponseRedirect(reverse('datacenterlight:order_confirmation'))
 | 
				
			||||||
        else:
 | 
					        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:
 | 
					                if session_var in request.session:
 | 
				
			||||||
                    del request.session[session_var]
 | 
					                    del request.session[session_var]
 | 
				
			||||||
        return render(request, self.template_name)
 | 
					        return render(request, self.template_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PricingView(TemplateView):
 | 
					class PricingView(TemplateView):
 | 
				
			||||||
    template_name = "datacenterlight/pricing.html"
 | 
					    template_name = "datacenterlight/pricing.html"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,6 @@ class PricingView(TemplateView):
 | 
				
			||||||
        price = request.POST.get('total')
 | 
					        price = request.POST.get('total')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        template_id = int(request.POST.get('config'))
 | 
					        template_id = int(request.POST.get('config'))
 | 
				
			||||||
 | 
					 | 
				
			||||||
        manager = OpenNebulaManager()
 | 
					        manager = OpenNebulaManager()
 | 
				
			||||||
        template = manager.get_template(template_id)
 | 
					        template = manager.get_template(template_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -327,7 +326,6 @@ class PaymentOrderView(FormView):
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
        return form_kwargs
 | 
					        return form_kwargs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def get_context_data(self, **kwargs):
 | 
					    def get_context_data(self, **kwargs):
 | 
				
			||||||
        context = super(PaymentOrderView, self).get_context_data(**kwargs)
 | 
					        context = super(PaymentOrderView, self).get_context_data(**kwargs)
 | 
				
			||||||
        context.update({
 | 
					        context.update({
 | 
				
			||||||
| 
						 | 
					@ -349,9 +347,8 @@ class PaymentOrderView(FormView):
 | 
				
			||||||
            billing_address_data = form.cleaned_data
 | 
					            billing_address_data = form.cleaned_data
 | 
				
			||||||
            token = form.cleaned_data.get('token')
 | 
					            token = form.cleaned_data.get('token')
 | 
				
			||||||
            user = request.session.get('user')
 | 
					            user = request.session.get('user')
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                custom_user = CustomUser.objects.get(email=user.get('email'))
 | 
					                CustomUser.objects.get(email=user.get('email'))
 | 
				
			||||||
            except CustomUser.DoesNotExist:
 | 
					            except CustomUser.DoesNotExist:
 | 
				
			||||||
                password = CustomUser.get_random_password()
 | 
					                password = CustomUser.get_random_password()
 | 
				
			||||||
                # Register the user, and do not send emails
 | 
					                # Register the user, and do not send emails
 | 
				
			||||||
| 
						 | 
					@ -411,7 +408,6 @@ class OrderConfirmationView(DetailView):
 | 
				
			||||||
        billing_address_data = request.session.get('billing_address_data')
 | 
					        billing_address_data = request.session.get('billing_address_data')
 | 
				
			||||||
        billing_address_id = request.session.get('billing_address')
 | 
					        billing_address_id = request.session.get('billing_address')
 | 
				
			||||||
        billing_address = BillingAddress.objects.filter(id=billing_address_id).first()
 | 
					        billing_address = BillingAddress.objects.filter(id=billing_address_id).first()
 | 
				
			||||||
        token = request.session.get('token')
 | 
					 | 
				
			||||||
        vm_template_id = template.get('id', 1)
 | 
					        vm_template_id = template.get('id', 1)
 | 
				
			||||||
        final_price = specs.get('price')
 | 
					        final_price = specs.get('price')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -423,10 +419,9 @@ class OrderConfirmationView(DetailView):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Check if the payment was approved
 | 
					        # Check if the payment was approved
 | 
				
			||||||
        if not charge:
 | 
					        if not charge:
 | 
				
			||||||
 | 
					            context = {}
 | 
				
			||||||
            context.update({
 | 
					            context.update({
 | 
				
			||||||
                'paymentError': charge_response.get('error')
 | 
					                'paymentError': charge_response.get('error')
 | 
				
			||||||
                # TODO add logic in payment form to autofill data 
 | 
					 | 
				
			||||||
                #'form': form
 | 
					 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
            return render(request, self.payment_template_name, context)
 | 
					            return render(request, self.payment_template_name, context)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -455,7 +450,7 @@ class OrderConfirmationView(DetailView):
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Create a Hosting Bill
 | 
					        # Create a Hosting Bill
 | 
				
			||||||
        bill = HostingBill.create(
 | 
					        HostingBill.create(
 | 
				
			||||||
            customer=customer, billing_address=billing_address)
 | 
					            customer=customer, billing_address=billing_address)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Create Billing Address for User if he does not have one
 | 
					        # Create Billing Address for User if he does not have one
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue