Commit graph

279 commits

Author SHA1 Message Date
Alieh Rymašeŭski
df2bf0a05c Replace timestamp index with timestamp+id index
This change is supposed to improve performance of admin view.
2019-08-22 18:05:39 +03:00
Alieh Rymašeŭski
05e6b179fd Bump version to 0.6.0 2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
07b38a9345 Update references to the maintainer 2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
5784247180 Update requirements section in the docs
We've dropped support for Python2 and unsupported versions of Python
and Django.
2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
2a43cff96f Add python3.7 to tox and classifiers 2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
b16b1a0df3 Drop Django 1.9 compatibility 2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
9152d225bb Remove obsolete versions from setup and tox 2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
c53b766132 Drop python2.7 support
Our dependency jsonfield broke compatibility with python2.7 recently,
and having no real reasons to support python2.7 we just drop it now.
2019-08-22 16:31:08 +03:00
Alieh Rymašeŭski
e35d0f4194 Bump version to 0.5.3 2019-08-21 19:41:02 +03:00
Alieh Rymašeŭski
e60876ae14 Add index for timestamp 2019-08-21 19:30:25 +03:00
Alieh Rymašeŭski
5dbea8a9a1 Bump version to 0.5.2 2019-05-17 12:41:31 +03:00
Alieh Rymašeŭski
cfbc588cc1 Query ContentTypes instead of distinct LogEntry
SELECT DISTINCT app_label, model FROM log_entry is a very expensive
request for longer logs, while we can always get the list of all
tracked models straight from the registry.

This new approach has two downsides:
1. It only provides filters for currently tracked models.
2. It can list such filter options that don't have any log entries.
2019-05-17 12:38:39 +03:00
Alieh Rymašeŭski
ee6bb33bc9 Bump version to 0.5.1 2019-05-16 17:24:13 +03:00
Alieh Rymašeŭski
c9c97b6861 Improve admin list performance 2019-05-16 17:23:28 +03:00
Alieh Rymašeŭski
5f5cc7f7e9 Bump version to 0.5.0 2019-05-11 18:43:36 +03:00
Alieh Rymašeŭski
a5381b6195 Move signal management to a context manager
This change allows setting the same signals when the request is not
present, i.e. in a celery task.
2019-05-11 18:25:08 +03:00
Alieh Rymašeŭski
2dc0ac43b5 Use get_user_model 2019-05-11 18:16:00 +03:00
Alieh Rymašeŭski
aa28009d3b Configure tests for Django 2.2 2019-05-11 18:16:00 +03:00
Alieh Rymašeŭski
03b8616dac Configure tests for Django 2.1 2019-05-11 18:15:58 +03:00
Alieh Rymašeŭski
62c1e676cc Bump version 2019-03-28 14:29:31 +03:00
Ryan Castner
a22978e05b
(docs) Update README to include steps to release (#185) 2018-09-17 14:56:44 -04:00
Jan-Jelle Kester
aab8f47f97 Add deploy config for Travis CI (#183)
* Add deploy config for Travis CI

* Use binary psycopg2 distribution

* Remove group to get newer postgres version

* Revert "Remove group to get newer postgres version"

This reverts commit 2c22ae3248.

* Default to Postgres 9.4, Django 2.0 dropped support for <=9.3.

https://docs.travis-ci.com/user/database-setup/#using-a-different-postgresql-version
2018-09-17 14:30:08 -04:00
David D Lowe
bcf1dbf0bf Indicate Python 3 support in metadata (#176) 2018-05-30 14:12:25 -04:00
Keith Bussell
3a82338e59 (feature) Allow AuditlogHistoryField to block cascading deletes (#172)
Fixes #108

Thanks to @andrewwatts for suggesting and researching the approach.
2018-03-27 14:42:36 -04:00
Jethro Muller
bc886fa01d Mark LogEntryAdminMixin methods output as safe where required (#167)
* Mark LogEntryAdminMixin method output as safe where required

Use format_html to provide conditional escaping and mark_safe functionality

* Unwrap function call to prevent py27 and py34 errors
2018-03-01 11:24:00 -05:00
Afsalms
fced0a6dd8 Corrected the issue when audit log when using django Django==2.0.1 (#166)
* Corrected the issue when audit log when using django Django==2.0.1

* Quick fix
2018-02-28 09:47:27 -05:00
Jan-Jelle Kester
1c8d60b596
Merge pull request #160 from jjkester/v0.4.5
v0.4.5
2018-01-12 23:44:07 +01:00
Jan-Jelle Kester
eaa02e6f38 Version bump 2018-01-12 23:39:44 +01:00
Jan-Jelle Kester
b51b942348
Merge pull request #155 from audiolion/bugfix/changes-display-dict-errors
(bugfix) changes_display_dict errors
2018-01-11 17:30:45 +01:00
Ryan Castner
d9ead64eab
Change syntax to be more terse 2018-01-11 11:18:59 -05:00
Ryan Castner
7fea1c59a1
Merge branch 'master' into bugfix/changes-display-dict-errors 2018-01-11 10:57:16 -05:00
Ryan Castner
e22c2f7d6b Fix crash when verbose_name is not defined on a model and field is not defined in mapping_fields. Defaults to field.name as a fallback 2018-01-11 10:56:31 -05:00
Ryan Castner
b410b40597
Add missing django 2.0 tox tests (#156) 2018-01-08 09:39:45 -05:00
AmirAli Akbari
560e2028c6 (bugfix) Fall back on actor repr when reverse url fails 2018-01-04 14:26:52 -05:00
Stephen Mc Guinness
881b7326bd (bugfix) Adds hasattr check before threadlocal.auditlog access in set_actor
middleware.set_actor was inconsistent with other methods in checking for
hasattr(threadlocal, 'auditlog')
2018-01-04 14:07:13 -05:00
sven
31db99497a (bugfix) Naive Datetimes Crashing (#107)
* Timezone naive fix
2018-01-04 13:43:23 -05:00
Denis
96f2f3d93e Fixed resource_url to work with non-id models (#147)
* Fixed resource_url to work with non-id models

* Add tests for auditlog admin
2018-01-04 11:49:39 -05:00
Ryan Castner
f6ade2078b
Merge branch 'master' into bugfix/changes-display-dict-errors 2018-01-04 09:14:55 -05:00
Rod Manning
4dee03497c Add Django 2.0 Support (#154)
* Add changes for django 2.0

Made the following changes to ensure compatibility with django 2.0:

1. Replaced function calls to `is_authenticated()` with reference to
   property `is_authenticated`.

2. Added try/except call to import `django.core.urlresolvers` (now
   called `django.urls`.

   Also added an `... as ...` statement to ensure that references in the
   code to `urlresolvers` don't need to be changed.

3. Fixed calls statement of `on_delete` arg to all ForeignKey
   fields.

   Note that previously a kwarg was acceptable, but this is now a
   positional arg, and the selected `on_delete` method has been
   retained.

* Update tox tests and consequentual changes

Updated tox.ini to also test django 2.0 on python 3+. Some changes made
to previous commits required to ensure all tests passed:

- Added `compat.py` to have a `is_authenticated()` function to check
  authentication.

  This was necessary as the property/method call for `is_authenticated`
  is no compatible between django 1.8 (LTS) and 2.0.

  Changed AuditLogMiddleware to call this compatibility function instead
  of the django built-ins as a result.

- Changes made to `auditlog/models.py` to apply kwargs to both `to=` and
  `on_delete=` for consistency of handling in all version tested.

Incorrect django version specified for tox.ini. Now fixed.

* Add 'on_delete' kwarg to initial migration

Added and re-arranged 'on_delete' and 'to' kwargs in initial migration
to ensure compatbility with later versions of Django.

Also included updated manifest with changes required due to django 2.0
work.

* Add TestCase for compat.py

Added simple test case for compat.py file.

* Changes follow code review 2017-12-21

* More changes following code review 2017-12-28

1. Added detailed commentary to `compat.py` to ensure reason why
   `is_authenticated()` compatibility function is needed

2. Changed `hasattr` to `callable` in compat.is_authenticated()

3. Fixed typo in migration 0001 to use correct `on_delete` function
2018-01-02 13:50:45 -05:00
Ryan Castner
13d3eba674 Update tests to reflect testing against the localized timestamp 2018-01-02 13:13:10 -05:00
Ryan Castner
76a4ea0f95 Fix issue where base_field.choices has options but we short circuit on an empty field.choices 2018-01-02 13:12:44 -05:00
Ryan Castner
a94ca4d5fd Use django's timezone to provide utc tzinfo 2018-01-02 12:34:52 -05:00
Ryan Castner
6cb9a27dca Exclude fields with no internal type, e.g. relationships like foreign keys and reverse foreign keys, from the changes_display_dict output. 2018-01-02 12:28:37 -05:00
Ryan Castner
a98bf9d7a5 The previous conditional did not work as expected, when field.choices returns an empty dict the boolean is False and the operator does not shortcircuit as expected. This causes field.base_field.choices to be evaluated which crashes as it does not exist and field.choices was supposed to be the input. The updated version fixes this bug. 2018-01-02 12:28:02 -05:00
Ryan Castner
2105366379 Datetimes are stored without tzinfo, but as UTC. changes_display_dict now adds in UTC tzinfo then casts DateTimes to the server's settings.TIME_ZONE. 2018-01-02 12:24:49 -05:00
Jan-Jelle Kester
e33aef85d5
Merge pull request #150 from jjkester/v0.4.4
Version 0.4.4
2017-11-18 16:04:01 +01:00
Jan-Jelle Kester
f45fb55c81 Version bump 2017-11-18 15:48:00 +01:00
Ryan Castner
45760c6316 Fixes #93 - Add 'changes_display_dict' property to 'LogEntry' model to display diff in a more human readable format (#94)
Fixes #93 - Add 'changes_display_dict' property to 'LogEntry' model to display diff in a more human readable format

'changes_display_dict' currently handles fields with choices, long textfields and charfields, datefields, timefields, and datetimefields. Supports `django-multiselectfield` with choices and Postgres's ArrayField with choices.

Textfields and Charfields longer than 140 characters are truncated with an ellipsis appended.
Date, Time and DateTime fields are rendered according to `L10N`, or if turned off fall back on Django settings defaults for DATE_FORMAT, TIME_FORMAT and DATETIME_FORMAT.

A new kwarg was added to 'AuditlogModelRegistry' called 'mapping_fields'. The kwarg allows the user to map the fields in the model to a more human readable or intuitive name. If a field isn't mapped it will default to the `verbose_name` as defined on the model or the Django default `verbose_name`. Partial mapping is supported, all fields do not need to be mapped to use the feature.

* Add django-multiselectfield test dep

* Add psycopg2 test dep

* Add postgres testing database and router

* Add postgres support to travis builds

* Add support for multiple databases. LogEntry saves to same database of the model its associated to

* If any literal evals fail default to None

* Add support for Postgres ArrayField in changes_display_dict

* Revert to old travis image while they are fixing issues with it

* Update docs

* Add full test coverage
2017-09-13 10:57:47 -04:00
Ryan Castner
ac8638dadd Chore -- Update testing (#126)
* Ignore new testing related files

* Add tox testing, coverage and codecov integration.
Drop Django 1.9 testing as support officially ended in April,
Add Django 1.11 testing, the new LTS version of Django
Add testing against Django for each versions supported python versions.
Remove Django from requirements, install handled through tox for tests and
regular repositories do not need us to install Django for them or enforce
a django version, they can choose to use a supported version or not.

* Update for python 3.6 tests
2017-07-05 09:32:27 -04:00
Ryan Castner
7736f40dd1 Add management commands package to setup.py (#130)
We weren't actually packaging up the management command when we published to PyPI
2017-07-05 08:50:38 -04:00