From ac37349aefd4b25a972bdfb6ba3531e33beef90a Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Fri, 29 Sep 2017 08:50:03 +0200 Subject: [PATCH] Refactor code and pass subscription_id instead of obj --- hosting/views.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index facc8c01..3804cb0b 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -80,8 +80,6 @@ class DjangoHostingView(ProcessVMSelectionMixin, View): templates = OpenNebulaManager().get_templates() data = VirtualMachineTemplateSerializer(templates, many=True).data configuration_options = HostingPlan.get_serialized_configs() - - # configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING) context = { 'hosting': HOSTING, 'hosting_long': "Django", @@ -134,7 +132,6 @@ class NodeJSHostingView(ProcessVMSelectionMixin, View): def get_context_data(self, **kwargs): HOSTING = 'nodejs' - # configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING) templates = OpenNebulaManager().get_templates() configuration_options = HostingPlan.get_serialized_configs() @@ -249,7 +246,8 @@ class SignupValidateView(TemplateView):
{go_back} {hurl}.'.format( signup_success_message=_( 'Thank you for signing up. We have sent an email to you. ' - 'Please follow the instructions in it to activate your account. Once activated, you can login using'), + 'Please follow the instructions in it to activate your ' + 'account. Once activated, you can login using'), go_back=_('Go back to'), lurl=login_url, hurl=home_url @@ -269,7 +267,8 @@ class SignupValidatedView(SignupValidateView): reverse('hosting:login') + '">' + str(_('login')) + '' section_title = _('Account activation') if validated: - message = '{account_activation_string}
{login_string} {lurl}.'.format( + message = ('{account_activation_string}
' + ' {login_string} {lurl}.').format( account_activation_string=_( "Your account has been activated."), login_string=_("You can now"), @@ -687,7 +686,8 @@ class OrdersHostingDetailView(LoginRequiredMixin, try: vm_detail = VMDetail.objects.get(vm_id=obj.vm_id) context['vm'] = vm_detail.__dict__ - context['vm']['name'] = '{}-{}'.format(context['vm']['configuration'], context['vm']['vm_id']) + context['vm']['name'] = '{}-{}'.format( + context['vm']['configuration'], context['vm']['vm_id']) except VMDetail.DoesNotExist: try: manager = OpenNebulaManager( @@ -788,7 +788,8 @@ class OrdersHostingDetailView(LoginRequiredMixin, 'response_object').stripe_plan_id}]) stripe_subscription_obj = subscription_result.get('response_object') # Check if the subscription was approved and is active - if stripe_subscription_obj is None or stripe_subscription_obj.status != 'active': + if (stripe_subscription_obj is None or + stripe_subscription_obj.status != 'active'): msg = subscription_result.get('error') messages.add_message(self.request, messages.ERROR, msg, extra_tags='failed_payment') @@ -805,7 +806,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, create_vm_task.delay(vm_template_id, user, specs, template, stripe_customer_id, billing_address_data, billing_address_id, - stripe_subscription_obj, card_details_dict) + stripe_subscription_obj.id, card_details_dict) for session_var in ['specs', 'template', 'billing_address', 'billing_address_data',