mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 07:51:09 -05:00
Add history tracking functionality using django-pghistory; implement views, templates, and middleware for event serialization and context management
This commit is contained in:
14
core/middleware.py
Normal file
14
core/middleware.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import pghistory
|
||||
|
||||
def setup_pghistory_context():
|
||||
"""
|
||||
Set up pghistory context middleware to track request information.
|
||||
This function configures what contextual information is stored
|
||||
with each history record.
|
||||
"""
|
||||
pghistory.context(lambda request: {
|
||||
'user': str(request.user) if request.user.is_authenticated else None,
|
||||
'ip': request.META.get('REMOTE_ADDR'),
|
||||
'user_agent': request.META.get('HTTP_USER_AGENT'),
|
||||
'session_key': request.session.session_key
|
||||
})
|
||||
Reference in New Issue
Block a user