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):