From 849c5a227013ecb27ef154af0d19af2ef66f50f1 Mon Sep 17 00:00:00 2001 From: Efstratios Goudelis Date: Wed, 11 May 2016 13:02:35 +0300 Subject: [PATCH] Added human readable representations of hosting order models to better manage order from the admin interface. Related ticket: https://redmine.ungleich.ch/issues/1715 --- hosting/admin.py | 6 ++++-- hosting/models.py | 11 +++++++++++ membership/admin.py | 3 ++- membership/models.py | 7 +++++++ utils/admin.py | 3 ++- utils/models.py | 8 ++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/hosting/admin.py b/hosting/admin.py index 84067ff9..a8db9537 100644 --- a/hosting/admin.py +++ b/hosting/admin.py @@ -1,6 +1,8 @@ from django.contrib import admin -from .models import RailsBetaUser, VirtualMachineType - +from .models import RailsBetaUser, VirtualMachineType, HostingOrder, VirtualMachinePlan admin.site.register(RailsBetaUser) admin.site.register(VirtualMachineType) +admin.site.register(HostingOrder) +admin.site.register(VirtualMachinePlan) + diff --git a/hosting/models.py b/hosting/models.py index dd686312..34a0ebc3 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -100,6 +100,12 @@ class VirtualMachinePlan(models.Model): instance = cls.objects.create(**data) return instance + def __str__(self): + """ + str cast with a friendly representation of the ContactMessage object + """ + return "Cores: %s, mem: %s, type: %s" % (self.cores, self.memory, self.vm_type) + class HostingOrder(models.Model): @@ -135,6 +141,11 @@ class HostingOrder(models.Model): self.cc_brand = stripe_charge.source.brand self.save() + def __str__(self): + """ + str cast with a friendly representation of the ContactMessage object + """ + return "Plan: %s, customer: %s, approved: %s" % (self.VMPlan, self.customer, self.approved) diff --git a/membership/admin.py b/membership/admin.py index 8c38f3f3..df173a09 100644 --- a/membership/admin.py +++ b/membership/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from .models import StripeCustomer -# Register your models here. +admin.site.register(StripeCustomer) diff --git a/membership/models.py b/membership/models.py index 75962660..aa9bc10a 100644 --- a/membership/models.py +++ b/membership/models.py @@ -151,6 +151,13 @@ class StripeCustomer(models.Model): return stripe_customer + def __str__(self): + """ + str cast with a friendly representation of the ContactMessage object + """ + return "User: %s, Stripe_id: %s" % (self.user, self.stripe_id) + + class CreditCards(models.Model): name = models.CharField(max_length=50) diff --git a/utils/admin.py b/utils/admin.py index 8c38f3f3..df4fe052 100644 --- a/utils/admin.py +++ b/utils/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from utils.models import BillingAddress -# Register your models here. +admin.site.register(BillingAddress) diff --git a/utils/models.py b/utils/models.py index 045a7604..49b6be3f 100644 --- a/utils/models.py +++ b/utils/models.py @@ -11,6 +11,11 @@ class BillingAddress(models.Model): postal_code = models.CharField(max_length=50) country = CountryField() + def __str__(self): + """ + str cast with a friendly representation of the BillingAddress object + """ + return "%s %s %s %s" % (self.street_address, self.city, self.postal_code, self.country) class ContactMessage(models.Model): @@ -21,4 +26,7 @@ class ContactMessage(models.Model): received_date = models.DateTimeField(auto_now_add=True) def __str__(self): + """ + str cast with a friendly representation of the ContactMessage object + """ return "%s - %s - %s" % (self.name, self.email, self.received_date)