Commit graph

238 commits

Author SHA1 Message Date
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
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
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
Grant McConnaughey
cf190fce7a Support models with UUID primary keys (#111)
Fixes #110 to add support for UUID primary keys in related many to many querysets in the `get_for_objects()` method.

Forces queryset evaluation in `get_for_objects()` to cache the queryset, reducing additional db queries.
2017-06-29 10:19:33 -04:00
Jan-Jelle Kester
511816afc2 Merge pull request #117 from chris-griffin/master
Deprecate the use of field.rel except for django 1.8
2017-06-14 10:29:46 +02:00
Chris Griffin
ee8bd9bbef
Deprecate the use of field.rel except for django 1.8 2017-06-13 15:15:27 -04:00
Jan-Jelle Kester
cd662fc529 Merge pull request #105 from jjkester/v0.4.3
Fix import error on NoReverseMatch
2017-02-16 22:29:13 +01:00
Jan-Jelle Kester
d97160f0c8 Version bump 2017-02-16 22:24:35 +01:00
Jan-Jelle Kester
22997ded2f Fix import error
Issue #104
2017-02-16 22:24:24 +01:00
Jan-Jelle Kester
c6dfdb6f68 Merge pull request #103 from jjkester/django-1.11
Django 1.11 compatibility
2017-02-16 15:45:55 +01:00
Jan-Jelle Kester
4f5a889ea9 Fix Django 1.11 Travis config 2017-02-16 15:43:25 +01:00
Jan-Jelle Kester
1fb64752d9 Merge pull request #101 from jjkester/v0.4.2
v0.4.2
2017-02-16 15:29:19 +01:00
Jan-Jelle Kester
6acab3809b Bump version to 0.4.2 2017-02-16 15:17:59 +01:00
Jan-Jelle Kester
c0c858391f Add test configuration for Django 1.11
Allow for alpha releases and release candidates for now
2017-02-16 15:17:07 +01:00
Jan-Jelle Kester
1cb1d98827 Merge pull request #100 from skorokithakis/master
Don't crash if the linked object is not in the admin (fixes #99)
2017-02-16 15:14:54 +01:00
Stavros Korokithakis
71ba5b9d92 Merge branch 'master' into master 2017-02-16 05:07:21 +02:00
Stavros Korokithakis
03def6cdb3
Don't crash if the linked object is not in the admin (fixes #99) 2017-02-16 05:06:12 +02:00
Jan-Jelle Kester
d0aefa55a4 Merge pull request #98 from skorokithakis/master
Allow register() to be called as a decorator (closes #88)
2017-02-13 19:59:26 +01:00
Stavros Korokithakis
c127415a25
Allow register() to be called as a decorator (closes #88) 2017-02-11 05:02:22 +02:00
Jan-Jelle Kester
c1d042b5a1 Merge pull request #87 from fsniper/patch-1
LogEntryAdminMixin throws Attribute error If a user misses full_name
2017-02-09 20:20:32 +01:00
Jan-Jelle Kester
9bbb77bcda Merge branch 'master' into patch-1 2017-02-09 20:14:26 +01:00
Jan-Jelle Kester
99f8604e3f Merge pull request #90 from fernandoe/resource_url
Fix the resource_url method when a model primary key is a models.UUIDField
2017-02-09 20:14:17 +01:00
Jan-Jelle Kester
d870f290f7 Merge branch 'master' into resource_url 2017-02-09 20:10:39 +01:00
Jan-Jelle Kester
3cd0ced81a Merge pull request #91 from fernandoe/use_tz_disabled
Use make_naive only if settings.USE_TZ is True.
2017-02-09 20:10:24 +01:00
Jan-Jelle Kester
e967d44bbc Merge branch 'master' into patch-1 2017-02-09 20:10:15 +01:00
Jan-Jelle Kester
2595d6ea64 Merge branch 'master' into use_tz_disabled 2017-02-09 20:06:00 +01:00
Jan-Jelle Kester
c17d45a13c Merge pull request #92 from goodmase/master
Fixed autologflush for django 1.10
2017-02-09 20:03:27 +01:00
Stephen Goodman
62a0d82042 Fixed autologflush for django 1.10 2017-01-26 13:19:23 -06:00
Fernando Espíndola
e6ef7c5319 Use make_naive only if settings.USE_TZ is True. 2017-01-26 01:52:04 -02:00
Fernando Espíndola
38ec7de585 Fix the resource_url method when a model primary key is a models.UUIDField, we need to consider use the object_pk in this case. 2017-01-26 01:21:13 -02:00
Onur YALAZI
eef4a14cd3 Changed to actor's string represantation
Depending on actor's attributes is error prone, developers can extend the user model without the needed attributes.
2017-01-22 11:32:44 +02:00
Jan-Jelle Kester
f456dedb5f Merge pull request #86 from Inter-Actief/ticket-82-datetimefields
Properly check timezone-aware DateTimeFields for changes
2017-01-21 20:17:03 +01:00
Jan-Jelle Kester
210143e34c Merge branch 'master' into ticket-82-datetimefields 2017-01-21 20:15:46 +01:00
Onur YALAZI
56a9ab6ab8 LogEntryAdminMixin throws Attribute error If a user misses full_name 2017-01-18 13:40:22 +02:00
Kevin Alberts
80bd115012 Move the value retrieval process to a separate function to make the diff code more DRY. 2017-01-18 09:36:16 +01:00
Jan-Jelle Kester
2cf1cde264 Merge pull request #85 from Inter-Actief/ticket-83-full_name
Django Admin full_name fix
2017-01-12 19:58:57 +01:00
Kevin Alberts
6f4c6eb8a2 Make it so Django's timezone-aware DateTimeFields remain unchanged when Django resets the timezone. DateFields are not timezone-aware, so they do not need fixing.
Django converts the timezone of DateTimeFields to UTC when the field gets saved. This makes it so when you update a model which includes a DateTimeField, and your server is running in another timezone, the AuditLog will think you changed the timestamp, while it actually is the same time, but in another timezone. This commit adds a specific check in the model_instance_diff function for DateTimeField models (and any subclasses of it), which converts the old and new values to UTC before comparing them to see if they've actually changed. It also adds tests to see if the code works properly.

The extra test_setting (USE_TZ) is added because timezone support is disabled if it is not specified, this setting enables it.
2017-01-11 20:07:10 +01:00
Kevin Alberts
1c28dbb0d6 Updated LogEntryAdmin to use first_name and last_name fields instead of full_name from the actor 2017-01-11 00:12:54 +01:00
Kevin Alberts
f498f740ee Updated LogEntryAdminMixin to use get_full_name() method from Django Auth.User model 2017-01-10 16:55:06 +01:00
Jan-Jelle Kester
7458e44669 Merge pull request #79 from jjkester/v0.4.1
Update manifest after release
2016-12-27 11:24:57 +01:00
Jan-Jelle Kester
d50554f8a6 Update manifest after release 2016-12-27 11:22:10 +01:00
Jan-Jelle Kester
890dbb041b Merge pull request #78 from jjkester/v0.4.1
Version bump and slight doc changes for 0.4.1
2016-12-27 11:16:33 +01:00
Jan-Jelle Kester
12d8c4d84d Version bump and slight doc changes for 0.4.1 2016-12-27 11:08:12 +01:00
Jan-Jelle Kester
0c8c189af5 Merge pull request #74 from Isszul/master
implemented suggested fix in #72
2016-12-27 10:50:34 +01:00