diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2015-10-01 19:58:20 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2015-10-01 19:58:20 -0500 |
commit | 35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f (patch) | |
tree | a451a77147bc9fabce6e224e2038eedc78e27969 /src/lib/Bcfg2/Server/models.py | |
parent | 061bd6abbb598659554f28a1a5bba45fd6eca6da (diff) | |
parent | a505fb3b2df0d1eddfe7a92afb080b016e951a43 (diff) | |
download | bcfg2-35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f.tar.gz bcfg2-35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f.tar.bz2 bcfg2-35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f.zip |
Merge branch 'fix/django1.7' of https://github.com/AlexanderS/bcfg2
Diffstat (limited to 'src/lib/Bcfg2/Server/models.py')
-rw-r--r-- | src/lib/Bcfg2/Server/models.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/lib/Bcfg2/Server/models.py b/src/lib/Bcfg2/Server/models.py index 8d6642a25..9c0153c74 100644 --- a/src/lib/Bcfg2/Server/models.py +++ b/src/lib/Bcfg2/Server/models.py @@ -8,6 +8,7 @@ import Bcfg2.Server.Plugins LOGGER = logging.getLogger(__name__) MODELS = [] +INTERNAL_DATABASE_VERSION = None class _OptionContainer(object): @@ -56,15 +57,23 @@ def load_models(plugins=None): setattr(sys.modules[__name__], sym, obj) MODELS.append(sym) - class InternalDatabaseVersion(models.Model): - """ Object that tell us to which version the database is """ - version = models.IntegerField() - updated = models.DateTimeField(auto_now_add=True) +def internal_database_version(): + global INTERNAL_DATABASE_VERSION - def __str__(self): - return "version %d updated %s" % (self.version, - self.updated.isoformat()) + if INTERNAL_DATABASE_VERSION is None: + from django.db import models + class InternalDatabaseVersion(models.Model): + """ Object that tell us to which version the database is """ + version = models.IntegerField() + updated = models.DateTimeField(auto_now_add=True) - class Meta: # pylint: disable=C0111,W0232 - app_label = "reports" - get_latest_by = "version" + def __str__(self): + return "version %d updated %s" % (self.version, + self.updated.isoformat()) + + class Meta: # pylint: disable=C0111,W0232 + app_label = "reports" + get_latest_by = "version" + INTERNAL_DATABASE_VERSION = InternalDatabaseVersion + + return INTERNAL_DATABASE_VERSION.objects |