-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKG-INFO
133 lines (84 loc) · 5.64 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Metadata-Version: 2.1
Name: drf-history
Version: 1.0.0
Summary: A simple Django app to track create,update and delete actions.
Home-page: https://github.com/kenneth051/drf-history
Author: Ddumba Kenneth
Author-email: [email protected]
License: UNKNOWN
Description: [![Build Status](https://travis-ci.org/kenneth051/drf-history.svg?branch=develop)](https://travis-ci.org/kenneth051/drf-history) [![Coverage Status](https://coveralls.io/repos/github/kenneth051/django-track-actions/badge.svg?branch=develop)](https://coveralls.io/github/kenneth051/django-track-actions?branch=develop) [![Maintainability](https://api.codeclimate.com/v1/badges/fc8a5a15c480d2ad117d/maintainability)](https://codeclimate.com/github/kenneth051/django-track-actions/maintainability) [![Downloads](https://pepy.tech/badge/drf-history)](https://pepy.tech/project/drf-history) [![Downloads](https://pepy.tech/badge/drf-history/month)](https://pepy.tech/project/drf-history/month) [![Downloads](https://pepy.tech/badge/drf-history/week)](https://pepy.tech/project/drf-history/week) [![PyPI version](https://badge.fury.io/py/drf-history.svg)](https://badge.fury.io/py/drf-history)
**DRF-HISTORY**
---------------------------------
drf-history is a simple django rest framework app to track actions performed in a django app and to also gets the current request.
The actions being tracked are **POST**, **DELETE**, **PUT** and **PATCH**
Data being captured is
-----------------------
| Data | Description|
| --- | --- |
| user | The current loggedin user making the request|
| request data(body) | Data being sent (POST, PATCH and PUT)|
| response data | response data after the request is complete |
| table_name | name of the model the request is affecting |
| instance_id | The id of the created, updated or deleted model instance |
| method | The request method i.e POST, DELETE, PUT or PATCH |
| created_at | Date time object for when the request is being carried out |
| path | path the request is coming from |
| | |
Quick start
-------------
1. Add `track_actions` to your INSTALLED_APPS setting
INSTALLED_APPS = [
...,
'track_actions',
]
2. Add `track_actions.requestMiddleware.RequestMiddleware` in settings under middlewares
MIDDLEWARE = [
... ,
'track_actions.requestMiddleware.RequestMiddleware',
]
3. Run `python manage.py migrate track_actions` to create the History model.
`python manage.py migrate track_actions`
After this every POST, UPDATE and DELETE action will be recorded in your database under the history model.
**To prevent sensitive fields from being saved**
For example `passwords`.
You will have to create a yaml file called `drf_history.yaml` on the root of your django project.
In this file add the following.
`fields_to_exclude: ["password","another key here"]`
You can then add all sensitve fields in the list separated by commas. These fields will be removed from the saved request data. This will apply to all tables.
This is only for data sent in the request.
**To get the current request**
To get the current request in progress anywhere in the application.
1. Import the relevant class.
from track_actions.requestMiddleware import RequestMiddleware
2 Get the current request object.
current_request = RequestMiddleware.get_request_data()[1]
**To access the get history endpoint**
1. In your project's url file
`import track_actions`
2. Register the url in the urlpattern
`path('track_actions/', include('track_actions.urls'))`
3. visit the url in the browser or on postman
`http://127.0.0.1:8000/track_actions/history/`
you should be able to see all the recorded history if you have `admin` priveleges and you are authenticated.
**Alternatively**
You can create your own endpoint to view all history from the History model by importing it in your views or serializers.
`from track_actions.models import History`
**NOTE**
This package will only work if you have a user in a request and a user model in your database.
Keywords: djangorestframework drf history django audit tracking
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Framework :: Django :: 2.2
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: License :: OSI Approved :: BSD License
Description-Content-Type: text/markdown