diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py
index 69e708d2..9d64dc60 100644
--- a/dynamicweb/settings/base.py
+++ b/dynamicweb/settings/base.py
@@ -446,8 +446,8 @@ AUTH_USER_MODEL = 'membership.CustomUser'
# PAYMENT
-STRIPE_API_PUBLIC_KEY = 'pk_test_ZRg6P8g5ybiHE6l2RW5pSaYV' # used in frontend to call from user browser
-STRIPE_API_PRIVATE_KEY = 'sk_test_uIPMdgXoRGydrcD7fkwcn7dj' # used in backend payment
+STRIPE_API_PUBLIC_KEY = 'pk_test_QqBZ50Am8KOxaAlOxbcm9Psl' # used in frontend to call from user browser
+STRIPE_API_PRIVATE_KEY = 'sk_test_dqAmbKAij12QCGfkYZ3poGt2' # used in backend payment
STRIPE_DESCRIPTION_ON_PAYMENT = "Payment for ungleich GmbH services"
# EMAIL MESSAGES
diff --git a/hosting/managers.py b/hosting/managers.py
index 961b2c6f..c474d61e 100644
--- a/hosting/managers.py
+++ b/hosting/managers.py
@@ -4,5 +4,6 @@ from django.db import models
class VMPlansManager(models.Manager):
def active(self, user, **kwargs):
- return self.select_related('hostingorder__customer__user').\
- filter(hostingorder__customer__user=user, hostingorder__approved=True, **kwargs)
+ return self.prefetch_related('hosting_orders__customer__user').\
+ filter(hosting_orders__customer__user=user, hosting_orders__approved=True, **kwargs)\
+ .distinct()
diff --git a/hosting/migrations/0014_auto_20160505_0541.py b/hosting/migrations/0014_auto_20160505_0541.py
new file mode 100644
index 00000000..532b25e8
--- /dev/null
+++ b/hosting/migrations/0014_auto_20160505_0541.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2016-05-05 05:41
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('hosting', '0013_auto_20160505_0302'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='hostingorder',
+ name='VMPlan',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hosting_orders', to='hosting.VirtualMachinePlan'),
+ ),
+ ]
diff --git a/hosting/models.py b/hosting/models.py
index 51930a12..dd686312 100644
--- a/hosting/models.py
+++ b/hosting/models.py
@@ -95,10 +95,6 @@ class VirtualMachinePlan(models.Model):
name = 'vm-%s' % self.id
return name
- @cached_property
- def orders(self):
- return [self.hostingorder]
-
@classmethod
def create(cls, data, user):
instance = cls.objects.create(**data)
@@ -110,7 +106,7 @@ class HostingOrder(models.Model):
ORDER_APPROVED_STATUS = 'Approved'
ORDER_DECLINED_STATUS = 'Declined'
- VMPlan = models.ForeignKey(VirtualMachinePlan)
+ VMPlan = models.ForeignKey(VirtualMachinePlan, related_name='hosting_orders')
customer = models.ForeignKey(StripeCustomer)
billing_address = models.ForeignKey(BillingAddress)
created_at = models.DateTimeField(auto_now_add=True)
diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html
index 4d5dcc18..74b8d5bb 100644
--- a/hosting/templates/hosting/order_detail.html
+++ b/hosting/templates/hosting/order_detail.html
@@ -23,7 +23,10 @@
Order Date:
{{object.created_at}}
Status:
- {{object.status}}
+ {{object.status}}
+
diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html
index 87edd71f..e51e1d4e 100644
--- a/hosting/templates/hosting/virtual_machine_detail.html
+++ b/hosting/templates/hosting/virtual_machine_detail.html
@@ -100,7 +100,7 @@