From f9584b4c829a47586366d1f541cb87dfd896eff5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 23 Aug 2018 09:06:31 +0200 Subject: [PATCH 1/3] Fix a bug when vm_template is None --- hosting/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hosting/models.py b/hosting/models.py index e9fcdc7e..601568c5 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -53,9 +53,11 @@ class OrderDetail(AssignPermissionsMixin, models.Model): ssd_size = models.IntegerField(default=0) def __str__(self): - return "%s - %s, %s cores, %s GB RAM, %s GB SSD" % ( - self.vm_template.name, self.vm_template.vm_type, self.cores, - self.memory, self.ssd_size + return "Not available" if self.vm_template is None else ( + "%s - %s, %s cores, %s GB RAM, %s GB SSD" % ( + self.vm_template.name, self.vm_template.vm_type, self.cores, + self.memory, self.ssd_size + ) ) From 4a1434c514db700a5b7e25d733429ba5f9abc86a Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 23 Aug 2018 09:07:07 +0200 Subject: [PATCH 2/3] Make string representation of HostingOrder more readable --- hosting/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hosting/models.py b/hosting/models.py index 601568c5..c4de453f 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -89,7 +89,9 @@ class HostingOrder(AssignPermissionsMixin, models.Model): ) def __str__(self): - return "%s" % (self.id) + return "Order Nr: #{} - VM_ID: {} - {} - {}".format( + self.id, self.vm_id, self.customer.user.email, self.created_at + ) @cached_property def status(self): From 4baa3a709543bc72fd00741a27315b1db9004488 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 23 Aug 2018 09:18:55 +0200 Subject: [PATCH 3/3] Improve HostingOrder str representation --- hosting/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hosting/models.py b/hosting/models.py index c4de453f..abc4c428 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -89,8 +89,10 @@ class HostingOrder(AssignPermissionsMixin, models.Model): ) def __str__(self): - return "Order Nr: #{} - VM_ID: {} - {} - {}".format( - self.id, self.vm_id, self.customer.user.email, self.created_at + return ("Order Nr: #{} - VM_ID: {} - {} - {} - " + "Specs: {} - Price: {}").format( + self.id, self.vm_id, self.customer.user.email, self.created_at, + self.order_detail, self.price ) @cached_property