Skip to content

Commit

Permalink
feat: audit log employee in applicant form
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke committed Jan 10, 2024
1 parent adaa86b commit 69fe3e1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion backend/benefit/applications/api/v1/serializers/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
from companies.api.v1.serializers import CompanySerializer
from companies.models import Company
from messages.automatic_messages import send_application_reopened_message
from shared.audit_log import audit_logging
from shared.audit_log.enums import Operation
from terms.api.v1.serializers import (
ApplicantTermsApprovalSerializer,
ApproveTermsSerializer,
Expand Down Expand Up @@ -1247,9 +1249,22 @@ def create(self, validated_data):
return application

def _update_or_create_employee(self, application, employee_data):
employee, _ = Employee.objects.update_or_create(
employee, was_created = Employee.objects.update_or_create(
application=application, defaults=employee_data
)
user = self.get_logged_in_user()

if was_created:
audit_log_operation = Operation.CREATE
else:
audit_log_operation = Operation.UPDATE

audit_logging.log(
user,
"",
audit_log_operation,
employee,
)
return employee

def get_company(self, validated_data):
Expand Down

0 comments on commit 69fe3e1

Please sign in to comment.