Commit f9ea424b authored by Daniel Klaffenbach's avatar Daniel Klaffenbach 🐍

Change instance field and object_id type

parent 6374753b
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-31 06:33
# Generated by Django 1.9.6 on 2016-06-17 13:54
from __future__ import unicode_literals
from django.db import migrations, models
......@@ -23,7 +23,7 @@ class Migration(migrations.Migration):
('user', models.CharField(db_index=True, editable=False, max_length=100)),
('time', models.DateTimeField(auto_now_add=True)),
('operation', models.PositiveSmallIntegerField(choices=[(1, 'Created'), (2, 'Changed'), (3, 'Deleted')], db_index=True, editable=False)),
('object_id', models.TextField(db_index=True, editable=False)),
('object_id', models.CharField(db_index=True, editable=False, max_length=255)),
('attrs', jsonfield.fields.JSONField(editable=False)),
('content_type', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
],
......
......@@ -91,8 +91,8 @@ class JournalEntry(models.Model):
operation = models.PositiveSmallIntegerField(choices=OPERATION_CHOICES, db_index=True, editable=False)
content_type = models.ForeignKey(ContentType, editable=False)
object_id = models.TextField(db_index=True, editable=False)
obj = GenericForeignKey('content_type', 'object_id')
object_id = models.CharField(db_index=True, editable=False, max_length=255)
instance = GenericForeignKey('content_type', 'object_id')
attrs = JSONField(editable=False)
......@@ -147,16 +147,16 @@ class JournalEntry(models.Model):
if self.operation == self.OPERATION_CHANGE:
attrs = ', '.join(self.get_changed_attributes())
if not attrs:
return ugettext('%s was saved without any changes.' %self.obj._meta.verbose_name)
return ugettext('%s was saved without any changes.' %self.instance._meta.verbose_name)
else:
return ugettext('Changed attributes: %s' %attrs)
elif self.operation == self.OPERATION_ADD:
return ugettext('%s was added.' %self.obj._meta.verbose_name)
return ugettext('%s was added.' %self.instance._meta.verbose_name)
else:
return ugettext('%s was deleted.' %self.obj._meta.verbose_name)
return ugettext('%s was deleted.' %self.instance._meta.verbose_name)
def get_display_full(self):
verbose_name = self.obj._meta.verbose_name
verbose_name = self.instance._meta.verbose_name
if self.operation == self.OPERATION_ADD:
label = ugettext('%s was added.' %verbose_name)
li = ''
......@@ -169,7 +169,7 @@ class JournalEntry(models.Model):
elif self.operation == self.OPERATION_CHANGE:
diff = self.get_diff()
if not diff:
return ugettext('%s was saved without any changes.' %self.obj._meta.verbose_name)
return ugettext('%s was saved without any changes.' %self.instance._meta.verbose_name)
else:
label = ugettext('%s was changed:' %verbose_name)
li = ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment