[CORD-1356] Using new config in core/models
Change-Id: I46e2c3ce954b1d0240549f60efc5e0a8668a42e1
diff --git a/xos/core/models/.gitignore b/xos/core/models/.gitignore
index 8dff515..2c710d6 100644
--- a/xos/core/models/.gitignore
+++ b/xos/core/models/.gitignore
@@ -2,7 +2,6 @@
Makefile
!contenttype.py
!header.py
-!journal.py
!network_header.py
!plcorebase.py
!service_header.py
diff --git a/xos/core/models/attic/header.py b/xos/core/models/attic/header.py
index 122b6a0..b6b8d31 100644
--- a/xos/core/models/attic/header.py
+++ b/xos/core/models/attic/header.py
@@ -17,9 +17,6 @@
from django.core.validators import URLValidator
from xos.exceptions import *
import urlparse
-from xos.config import Config
-
-config = Config()
def ParseNatList(ports):
""" Support a list of ports in the format "protocol:port, protocol:port, ..."
diff --git a/xos/core/models/attic/service_header.py b/xos/core/models/attic/service_header.py
index 09019b8..7cfef6f 100644
--- a/xos/core/models/attic/service_header.py
+++ b/xos/core/models/attic/service_header.py
@@ -9,7 +9,6 @@
from distutils.version import LooseVersion
from django.core.validators import URLValidator
from xos.exceptions import *
-from xos.config import Config
COARSE_KIND = "coarse"
diff --git a/xos/core/models/attic/xosbase_header.py b/xos/core/models/attic/xosbase_header.py
index d67b56a..08de602 100644
--- a/xos/core/models/attic/xosbase_header.py
+++ b/xos/core/models/attic/xosbase_header.py
@@ -12,7 +12,6 @@
from django.utils import timezone
from django.core.exceptions import PermissionDenied
from cgi import escape as html_escape
-from journal import journal_object
from django.db.models.deletion import Collector
from django.db import router
from django.contrib.contenttypes.models import ContentType
diff --git a/xos/core/models/attic/xosbase_model.py b/xos/core/models/attic/xosbase_model.py
index 624426e..26197fa 100644
--- a/xos/core/models/attic/xosbase_model.py
+++ b/xos/core/models/attic/xosbase_model.py
@@ -32,14 +32,12 @@
pass
if (purge):
- journal_object(self, "delete.purge")
super(XOSBase, self).delete(*args, **kwds)
else:
if (not self.write_protect ):
self.deleted = True
self.enacted=None
self.policed=None
- journal_object(self, "delete.mark_deleted")
self.save(update_fields=['enacted','deleted','policed'], silent=silent)
collector = XOSCollector(using=router.db_for_write(self.__class__, instance=self))
@@ -53,11 +51,9 @@
model.deleted = True
model.enacted=None
model.policed=None
- journal_object(model, "delete.cascade.mark_deleted", msg="root = %r" % self)
model.save(update_fields=['enacted','deleted','policed'], silent=silent)
def save(self, *args, **kwargs):
- journal_object(self, "xosbase.save")
# let the user specify silence as either a kwarg or an instance varible
silent = self.silent
@@ -89,11 +85,9 @@
if (caller_kind!="synchronizer") or always_update_timestamp:
self.updated = timezone.now()
- journal_object(self, "xosbase.save.super_save")
super(XOSBase, self).save(*args, **kwargs)
- journal_object(self, "xosbase.save.super_save_returned")
self.push_redis_event()
diff --git a/xos/core/models/journal.py b/xos/core/models/journal.py
deleted file mode 100644
index 9d60f2a..0000000
--- a/xos/core/models/journal.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from __future__ import absolute_import
-
-from django.db import models
-from django.utils import timezone
-
-from xos.config import Config
-from xos.exceptions import *
-from operator import attrgetter
-import json
-
-class JournalEntry(models.Model):
- objClassName = models.CharField(max_length=64)
- objId = models.CharField(max_length=64, null=True, blank=True) # null=True, for objects journaled before save
- objUnicode = models.CharField(max_length=1024)
- operation = models.CharField(max_length=64)
- msg = models.TextField(blank=True, null=True)
- timestamp = models.DateTimeField(default=timezone.now)
-
- def __unicode__(self): return u'%s' % (self.name)
-
- def can_update(self, user):
- return True
-
-
-def journal_object(o, operation, msg=None, timestamp=None):
- # do not journal unless it has been explicitly enabled
- if not getattr(Config(), "debug_enable_journal", None):
- return
-
- # ignore objects that generate too much noise
- if o.__class__.__name__ in ["Diag"]:
- return
-
- if not timestamp:
- timestamp = timezone.now()
-
- j = JournalEntry(objClassName = o.__class__.__name__,
- objId = o.id,
- objUnicode = str(o),
- operation = operation,
- msg= msg)
- j.save()
-
-
-
diff --git a/xos/core/models/user.py b/xos/core/models/user.py
index 8a191f5..8f06cb3 100644
--- a/xos/core/models/user.py
+++ b/xos/core/models/user.py
@@ -19,7 +19,6 @@
from django.forms.models import model_to_dict
from django.utils import timezone
from timezones.fields import TimeZoneField
-from journal import journal_object
from django.contrib.contenttypes.models import ContentType
import redis
@@ -252,14 +251,12 @@
pass
if (purge):
- journal_object(self, "delete.purge")
super(User, self).delete(*args, **kwds)
else:
if (not self.write_protect ):
self.deleted = True
self.enacted=None
self.policed=None
- journal_object(self, "delete.mark_deleted")
self.save(update_fields=['enacted','deleted','policed'], silent=silent)
collector = XOSCollector(using=router.db_for_write(self.__class__, instance=self))
@@ -273,11 +270,9 @@
model.deleted = True
model.enacted=None
model.policed=None
- journal_object(model, "delete.cascade.mark_deleted", msg="root = %r" % self)
model.save(update_fields=['enacted','deleted','policed'], silent=silent)
def save(self, *args, **kwargs):
- journal_object(self, "xosbase.save")
if not self.id:
self.set_password(self.password)
@@ -317,12 +312,8 @@
self.username = self.email
- journal_object(self, "xosbase.save.super_save")
-
super(User, self).save(*args, **kwargs)
- journal_object(self, "xosbase.save.super_save_returned")
-
self.push_redis_event()
# This is a no-op if observer_disabled is set
diff --git a/xos/genx/targets/init.xtarget b/xos/genx/targets/init.xtarget
index 1ecc071..78d0bdb 100644
--- a/xos/genx/targets/init.xtarget
+++ b/xos/genx/targets/init.xtarget
@@ -7,7 +7,6 @@
from .dashboardview import DashboardView
from .user import User
from .user import UserDashboardView
-from .journal import JournalEntry, journal_object
{% for m in proto.messages -%}
{% if not m.options.skip -%}