Files
ihrm/horilla_audit/context_processors.py
Ashwanth Balakrishnan 58be33a8d7 Added Pre-Commit Hooks (#175)
* Added pre commit hook

* Run pre commit hook on all files

---------

Co-authored-by: Horilla <131998600+horilla-opensource@users.noreply.github.com>
2024-05-07 12:23:36 +05:30

34 lines
773 B
Python

"""
context_processor.py
This module is used to register context processor`
"""
from django.http import JsonResponse
from django.urls import include, path
from horilla.urls import urlpatterns
from horilla_audit.forms import HistoryForm
from horilla_audit.models import AuditTag
def history_form(request):
"""
This method will return the history additional field form
"""
form = HistoryForm()
return {"history_form": form}
def dynamic_tag(request):
"""
This method is used to dynamically create history tags
"""
title = request.POST["title"]
title = AuditTag.objects.get_or_create(title=title)
return JsonResponse({"id": title[0].id})
urlpatterns.append(path("horilla-audit-log", dynamic_tag, name="horilla-audit-log"))