Refactor code and pass subscription_id instead of obj
This commit is contained in:
parent
313ba9d502
commit
ac37349aef
1 changed files with 9 additions and 8 deletions
|
@ -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):
|
|||
<br />{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')) + '</a>'
|
||||
section_title = _('Account activation')
|
||||
if validated:
|
||||
message = '{account_activation_string} <br /> {login_string} {lurl}.'.format(
|
||||
message = ('{account_activation_string} <br />'
|
||||
' {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',
|
||||
|
|
Loading…
Reference in a new issue