From 903ef48c758e5882ac74b514aa6f3865136568b8 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 9 Jul 2019 19:03:09 +0530 Subject: [PATCH] Format cc month to 2 decimal places --- datacenterlight/views.py | 4 ++-- hosting/models.py | 2 +- hosting/views.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 60938ac8..ae649623 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -569,14 +569,14 @@ class OrderConfirmationView(DetailView, FormView): context['cc_last4'] = card_details_response['last4'] context['cc_brand'] = card_details_response['brand'] context['cc_exp_year'] = card_details_response['exp_year'] - context['cc_exp_month'] = card_details_response['exp_month'] + context['cc_exp_month'] = '{:02d}'.format(card_details_response['exp_month']) else: card_id = self.request.session.get('card_id') card_detail = UserCardDetail.objects.get(id=card_id) context['cc_last4'] = card_detail.last4 context['cc_brand'] = card_detail.brand context['cc_exp_year'] = card_detail.exp_year - context['cc_exp_month'] = card_detail.exp_month + context['cc_exp_month'] ='{:02d}'.format(card_detail.exp_month) if ('generic_payment_type' in request.session and self.request.session['generic_payment_type'] == 'generic'): diff --git a/hosting/models.py b/hosting/models.py index e6e29cbe..7b08948e 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -598,7 +598,7 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): cards_list.append({ 'last4': card.last4, 'brand': card.brand, 'id': card.id, 'exp_year': card.exp_year, - 'exp_month': card.exp_month, + 'exp_month': '{:02d}'.format(card.exp_month), 'preferred': card.preferred }) return cards_list diff --git a/hosting/views.py b/hosting/views.py index 9a2e5b19..87cb948c 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -914,7 +914,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView, FormView): context['cc_last4'] = card_detail.last4 context['cc_brand'] = card_detail.brand context['cc_exp_year'] = card_detail.exp_year - context['cc_exp_month'] = card_detail.exp_month + context['cc_exp_month'] = '{:02d}'.format(card_detail.exp_month) context['site_url'] = reverse('hosting:create_virtual_machine') context['vm'] = self.request.session.get('specs') return context