Commit graph

22 commits

Author SHA1 Message Date
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
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
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
isszul
25ca523301 implemented suggested fix in #72 2016-11-02 13:30:05 +00:00
Jan-Jelle Kester
7824fb27f1 Update middleware for Django 1.10 2016-08-17 22:45:02 +02:00
jay7958
655e02e806 Changed import to use the new apps module for get_model, this removes
the Django warning:
site-packages/auditlog/middleware.py:9: RemovedInDjango19Warning: The utilities in django.db.models.loading are deprecated in favor of the new application loading system.
  from django.db.models.loading import get_model
2015-08-20 13:49:22 -05:00
Scott Adams
4dc11ab6fb Fixes #31 2015-07-29 13:27:15 +02:00
Jan-Jelle Kester
0c0d1dffe1 Only set remote_addr in set_actor method 2015-06-03 16:49:04 +02:00
Jan-Jelle Kester
6e74d41268 Use threadlocals to store middleware data instead of the request 2015-06-03 16:29:40 +02:00
Jan-Jelle Kester
e97c601038 First try at making Auditlog work with Python 3
Issue #15
2015-02-16 22:17:22 +01:00
Jan-Jelle Kester
41d3948606 Progress with tests 2014-03-14 17:15:31 +01:00
Vitor Figueiro
b453a4a9d5 quick fix for AttributeError at admin urls 2014-02-12 21:54:46 +00:00
Vitor Figueiro
c22bd6b61e process_exception returns None 2014-02-07 20:02:03 +00:00
Vitor Figueiro
ecd53b7a07 ensure signal disconnection 2014-02-07 19:59:16 +00:00
Jan-Jelle Kester
3e3282392d Make the set_actor method from the middleware static. Also, catch only the relevant exception. 2013-12-18 17:16:39 +01:00
Jan-Jelle Kester
ec051d11f0 Merge remote-tracking branch 'origin/master'
Conflicts:
	src/auditlog/middleware.py
2013-12-11 16:55:05 +01:00
Francisco Pérez Ferrer
1a0959d8ab make AUTH_USER_MODEL to work with 'app_label.model_name' format 2013-11-27 17:35:34 -05:00
Jan-Jelle Kester
bd61008bd7 Rename 'AuditLog' to 'Auditlog' in class names 2013-11-07 17:02:31 +01:00
Jan-Jelle Kester
1b2503d371 Extend inline documentation 2013-11-06 20:48:16 +01:00
Jan-Jelle Kester
b66ada0baa Only set the actor when it was not set explicitly 2013-10-23 17:20:21 +02:00
Jan-Jelle Kester
81098cd179 Big commit: testproject, bugfixes, changed directory structure 2013-10-21 21:46:31 +02:00
Renamed from auditlog/middleware.py (Browse further)