Skip to content

Commit

Permalink
Merge pull request #9 from navariltd/devlop1
Browse files Browse the repository at this point in the history
feat - bypass the permission by querying db directly
  • Loading branch information
maniamartial authored Oct 28, 2024
2 parents 238e811 + 9ca432f commit 96caf5f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions navari_cams_biometric/cams_biometric/controllers/cams_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import frappe
from frappe import _
from dateutil import parser
from flask import Response
from flask import Response

@frappe.whitelist(allow_guest=True)
def attendance():
Expand Down Expand Up @@ -76,6 +76,7 @@ def handle_attendance_log(stgid, rawdata):

return "done"

@frappe.whitelist(allow_guest=True)
def handle_punch_logs(stgid, punch_logs):
for punch_log in punch_logs:
log_type_punch = punch_log["Type"]
Expand Down Expand Up @@ -130,14 +131,17 @@ def load_punch_logs():
pass

def get_shift(biometric_id):
frappe.flags.ignore_permissions = True
user = frappe.get_list("Employee", filters={"attendance_device_id": biometric_id}, fields=["name", "default_shift"])
user = frappe.db.sql("""
SELECT name, default_shift
FROM `tabEmployee`
WHERE attendance_device_id = %s
""", (biometric_id,), as_dict=True)
frappe.flags.ignore_permissions = False # Reset permissions

if user:
first_user = user[0]
user_doc=frappe.get_doc("Employee",first_user["name"])
return user_doc.default_shift
else:
return None
return user[0].get("default_shift")
return None


def update_last_sync_time(shift, time):
frappe.db.set_value("Shift Type", shift, "last_sync_of_checkin", time, update_modified=False)
Expand Down

0 comments on commit 96caf5f

Please sign in to comment.