From ab6da32d434cfd88ee53246b723937654f691ae3 Mon Sep 17 00:00:00 2001 From: maniamartial Date: Tue, 23 Jul 2024 17:08:26 +0300 Subject: [PATCH] fix - remove file and write data directly in employee checkin --- .../cams_biometric/controllers/cams_call.py | 27 +++++++++---------- navari_cams_biometric/hooks.py | 17 ++++++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/navari_cams_biometric/cams_biometric/controllers/cams_call.py b/navari_cams_biometric/cams_biometric/controllers/cams_call.py index 65159f1..b39715f 100644 --- a/navari_cams_biometric/cams_biometric/controllers/cams_call.py +++ b/navari_cams_biometric/cams_biometric/controllers/cams_call.py @@ -1,7 +1,6 @@ import json import frappe from frappe import _ -from datetime import datetime from dateutil import parser @frappe.whitelist(allow_guest=True) @@ -35,18 +34,6 @@ def attendance(): def handle_attendance_log(stgid, rawdata): request_data = json.loads(rawdata) - print(str(request_data)) - - content = f'ServiceTagId: {stgid},\t' - content += f'UserId: {request_data["RealTime"]["PunchLog"]["UserId"]},\t' - content += f'AttendanceTime: {request_data["RealTime"]["PunchLog"]["LogTime"]},\t' - content += f'AttendanceType: {request_data["RealTime"]["PunchLog"]["Type"]},\t' - content += f'InputType: {request_data["RealTime"]["PunchLog"]["InputType"]},\t' - content += f'Operation: RealTime->PunchLog,\t' - content += f'AuthToken: {request_data["RealTime"]["AuthToken"]}\n' - - with open("cams-attendance-record.txt", "a") as file: - file.write(content) log_type_punch = request_data["RealTime"]["PunchLog"]["Type"] log_type = 'OUT' if log_type_punch == 'CheckOut' else 'IN' @@ -55,7 +42,6 @@ def handle_attendance_log(stgid, rawdata): log_time = request_data["RealTime"]["PunchLog"]["LogTime"] log_time_dt = parser.parse(log_time) formatted_log_time = log_time_dt.strftime("%Y-%m-%d %H:%M:%S") - print("Time is", str(formatted_log_time)) # Storing the values in Employee Checking doctype employee_checking = frappe.get_doc({ @@ -63,9 +49,22 @@ def handle_attendance_log(stgid, rawdata): "employee": request_data["RealTime"]["PunchLog"]["UserId"], "time": formatted_log_time, "log_type": log_type, + "custom_input_type":request_data["RealTime"]["PunchLog"]["InputType"] }) employee_checking.insert(ignore_permissions=True) frappe.db.commit() return "done" + +'''I dont see the need to write to a file''' + # content = f'ServiceTagId: {stgid},\t' + # content += f'UserId: {request_data["RealTime"]["PunchLog"]["UserId"]},\t' + # content += f'AttendanceTime: {request_data["RealTime"]["PunchLog"]["LogTime"]},\t' + # content += f'AttendanceType: {request_data["RealTime"]["PunchLog"]["Type"]},\t' + # content += f'InputType: {request_data["RealTime"]["PunchLog"]["InputType"]},\t' + # content += f'Operation: RealTime->PunchLog,\t' + # content += f'AuthToken: {request_data["RealTime"]["AuthToken"]}\n' + + # with open("cams-attendance-record.txt", "a") as file: + # file.write(content) \ No newline at end of file diff --git a/navari_cams_biometric/hooks.py b/navari_cams_biometric/hooks.py index a2e5f0a..aacd3af 100644 --- a/navari_cams_biometric/hooks.py +++ b/navari_cams_biometric/hooks.py @@ -4,6 +4,23 @@ app_description = "///\'.\'" app_email = "mania@navari.co.ke" app_license = "agpl-3.0" + + +fixtures = [ + { + "doctype": "Custom Field", + "filters": [ + [ + "name", + "in", + ( + "Employee Checkin-custom_input_type", + + ), + ] + ], + }, +] # required_apps = [] # Includes in