Commit f49d9b52 authored by Daniel Klaffenbach's avatar Daniel Klaffenbach

Drop legacy imports

We now require Python 3

Closes #1
parent fd0ab5a4
......@@ -10,11 +10,10 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models import Q
from django.utils.encoding import python_2_unicode_compatible
from django.utils.formats import date_format
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, ugettext
from django.utils.translation import gettext_lazy as _, gettext
from jsonfield import JSONField
from . import _thread_local_storage
......@@ -77,7 +76,6 @@ class JournalEntryManager(models.Manager):
return self.model.objects.filter(object_id=self.instance.pk).filter(content_type_filter)
@python_2_unicode_compatible
class JournalEntry(models.Model):
"""
Contains all logs for all models. The objects are referenced through a
......@@ -158,18 +156,18 @@ 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.instance._meta.verbose_name)
return gettext('%s was saved without any changes.' % self.instance._meta.verbose_name)
else:
return ugettext('Changed attributes: %s' % attrs)
return gettext('Changed attributes: %s' % attrs)
elif self.operation == self.OPERATION_ADD:
return ugettext('%s was added.' % self.instance._meta.verbose_name)
return gettext('%s was added.' % self.instance._meta.verbose_name)
else:
return ugettext('%s was deleted.' % self.instance._meta.verbose_name)
return gettext('%s was deleted.' % self.instance._meta.verbose_name)
def get_display_full(self):
verbose_name = self.instance._meta.verbose_name
if self.operation == self.OPERATION_ADD:
label = ugettext('%s was added.' % verbose_name)
label = gettext('%s was added.' % verbose_name)
li = ''
for attr in self.attrs:
if self.attrs[attr]:
......@@ -180,9 +178,9 @@ 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.instance._meta.verbose_name)
return gettext('%s was saved without any changes.' % self.instance._meta.verbose_name)
else:
label = ugettext('%s was changed:' % verbose_name)
label = gettext('%s was changed:' % verbose_name)
li = ''
for i in diff:
li += format_html('<li><strong>{}:</strong> "{}" &rarr; "{}"</li>', i, diff[i][0], diff[i][1])
......@@ -190,7 +188,7 @@ class JournalEntry(models.Model):
label += '<ul>%s</ul>' % li
return mark_safe(label)
else:
return ugettext('%s was deleted.' % verbose_name)
return gettext('%s was deleted.' % verbose_name)
class Journal(GenericRelation):
......
......@@ -3,7 +3,7 @@
from setuptools import setup, find_packages
setup(name='django-model-journal',
version='0.1',
version='0.2',
description='Provides a simple model history, including all changed attributes. Does not require schema changes, just one additional database table.',
author='Daniel Klaffenbach',
author_email='daniel.klaffenbach@hrz.tu-chemnitz.de',
......@@ -16,6 +16,7 @@ setup(name='django-model-journal',
},
install_requires=[
'django>=1.11',
'jsonfield>=1.0.3',
'jsonfield>=2',
],
python_requires='>=3.6',
)
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