Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/opencloud.spec b/opencloud.spec
index 4d72a55..5831006 100644
--- a/opencloud.spec
+++ b/opencloud.spec
@@ -1,7 +1,7 @@
Summary: OpenCloud core services
Name: opencloud
-Version: 1.0.25
-Release: 8
+Version: 1.0.26
+Release: 7
License: GPL+
Group: Development/Tools
Source0: %{_tmppath}/%{name}-%{version}.tar.gz
@@ -29,7 +29,7 @@
# Empty section.
%pre
-#pip-python install django==1.5
+pip-python install django==1.7
pip-python install djangorestframework
pip-python install markdown # Markdown support for the browseable API.
pip-python install pyyaml # YAML content-type support.
@@ -119,10 +119,9 @@
echo "NEW INSTALL - initializing database"
/opt/planetstack/scripts/opencloud initdb
else
- echo "UPGRADE - doing evolution"
+ # scripts/opencloud will choose evolve or migrate depending on django version
+ echo "UPGRADE - doing evolution/migration"
/opt/planetstack/scripts/opencloud evolvedb
- #echo "UPGRADE - doing migration"
- #/opt/planetstack/scripts/opencloud migratedb
fi
# start the server
diff --git a/planetstack/core/models/billing.py b/planetstack/core/models/billing.py
index 6d1c331..8c61418 100644
--- a/planetstack/core/models/billing.py
+++ b/planetstack/core/models/billing.py
@@ -6,6 +6,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.db.models import Sum
+from django.utils import timezone
class Account(PlCoreBase):
site = models.ForeignKey(Site, related_name="accounts", help_text="Site for this account")
@@ -51,7 +52,7 @@
class Payment(PlCoreBase):
account = models.ForeignKey(Account, related_name="payments")
amount = models.FloatField(default=0.0)
- date = models.DateTimeField(default=datetime.datetime.now)
+ date = models.DateTimeField(default=timezone.now)
def __unicode__(self): return u'%s-%0.2f-%s' % (self.account.site.name, self.amount, str(self.date))
diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py
index d1784cd..d461c9d 100644
--- a/planetstack/core/models/plcorebase.py
+++ b/planetstack/core/models/plcorebase.py
@@ -1,10 +1,10 @@
-import datetime
import os
import sys
from django.db import models
from django.forms.models import model_to_dict
from django.core.urlresolvers import reverse
from django.forms.models import model_to_dict
+from django.utils import timezone
import model_policy
try:
@@ -23,9 +23,13 @@
# the core model is abstract.
class PlCoreBaseDeletionManager(models.Manager):
def get_queryset(self):
- return super(PlCoreBaseDeletionManager, self).get_query_set().filter(deleted=True)
+ parent=super(PlCoreBaseDeletionManager, self)
+ if hasattr(parent, "get_queryset"):
+ return parent.get_queryset().filter(deleted=True)
+ else:
+ return parent.get_query_set().filter(deleted=True)
- # deprecated in django 1.7 in favor of get_queryset()
+ # deprecated in django 1.7 in favor of get_queryset().
def get_query_set(self):
return self.get_queryset()
@@ -33,9 +37,13 @@
# the core model is abstract.
class PlCoreBaseManager(models.Manager):
def get_queryset(self):
- return super(PlCoreBaseManager, self).get_query_set().filter(deleted=False)
+ parent=super(PlCoreBaseManager, self)
+ if hasattr(parent, "get_queryset"):
+ return parent.get_queryset().filter(deleted=False)
+ else:
+ return parent.get_query_set().filter(deleted=False)
- # deprecated in django 1.7 in favor of get_queryset()
+ # deprecated in django 1.7 in favor of get_queryset().
def get_query_set(self):
return self.get_queryset()
@@ -45,8 +53,8 @@
# default values for created and updated are only there to keep evolution
# from failing.
- created = models.DateTimeField(auto_now_add=True, default=datetime.datetime.now)
- updated = models.DateTimeField(auto_now=True, default=datetime.datetime.now)
+ created = models.DateTimeField(auto_now_add=True, default=timezone.now)
+ updated = models.DateTimeField(auto_now=True, default=timezone.now)
enacted = models.DateTimeField(null=True, default=None)
backend_status = models.CharField(max_length=140,
default="Provisioning in progress")
diff --git a/planetstack/scripts/opencloud b/planetstack/scripts/opencloud
index ff6eefc..b307e66 100755
--- a/planetstack/scripts/opencloud
+++ b/planetstack/scripts/opencloud
@@ -134,15 +134,14 @@
createdb
syncdb
fi
-if [ "$COMMAND" = "evolvedb" ]; then
+if [ "$COMMAND" = "evolvedb" -o "$COMMAND" = "migratedb" ]; then
stopserver
ensure_postgres_running
- evolvedb
-fi
-if [ "$COMMAND" = "migratedb" ]; then
- stopserver
- ensure_postgres_running
- migratedb
+ if [[ $DJANGO_17 ]]; then
+ migratedb
+ else
+ evolvedb
+ fi
fi
if [ "$COMMAND" = "resetdb" ]; then
stopserver