From 332e7d662461d8d794962aaaaaa5f4dc03f3fc5e Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 23 Sep 2018 12:34:13 +0200 Subject: [PATCH] Add generic_payment_id field to HostingOrder migration and reflect generic payments in adminsite --- .../0048_hostingorder_generic_payment_id.py | 20 +++++++++++++++++++ hosting/models.py | 16 ++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 hosting/migrations/0048_hostingorder_generic_payment_id.py diff --git a/hosting/migrations/0048_hostingorder_generic_payment_id.py b/hosting/migrations/0048_hostingorder_generic_payment_id.py new file mode 100644 index 00000000..36488efb --- /dev/null +++ b/hosting/migrations/0048_hostingorder_generic_payment_id.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-09-23 09:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0047_auto_20180821_1240'), + ] + + operations = [ + migrations.AddField( + model_name='hostingorder', + name='generic_payment_id', + field=models.CharField(editable=False, max_length=128, null=True), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index abc4c428..15ebb07c 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -9,8 +9,8 @@ from django.utils.functional import cached_property from datacenterlight.models import VMPricing, VMTemplate from membership.models import StripeCustomer, CustomUser -from utils.models import BillingAddress from utils.mixins import AssignPermissionsMixin +from utils.models import BillingAddress from utils.stripe_utils import StripeUtils logger = logging.getLogger(__name__) @@ -80,6 +80,9 @@ class HostingOrder(AssignPermissionsMixin, models.Model): OrderDetail, null=True, blank=True, default=None, on_delete=models.SET_NULL ) + generic_payment_id = models.CharField( + max_length=128, null=True, editable=False + ) permissions = ('view_hostingorder',) @@ -89,11 +92,18 @@ class HostingOrder(AssignPermissionsMixin, models.Model): ) def __str__(self): - return ("Order Nr: #{} - VM_ID: {} - {} - {} - " - "Specs: {} - Price: {}").format( + hosting_order_str = ("Order Nr: #{} - VM_ID: {} - {} - {} - " + "Specs: {} - Price: {}").format( self.id, self.vm_id, self.customer.user.email, self.created_at, self.order_detail, self.price ) + if self.generic_payment_id is not None: + hosting_order_str += " - Generic Payment" + if self.stripe_charge_id is not None: + hosting_order_str += " - One time charge" + else: + hosting_order_str += " - Recurring" + return hosting_order_str @cached_property def status(self):