diff --git a/get_query.py b/get_query.py index 6c76385..c2a48ec 100644 --- a/get_query.py +++ b/get_query.py @@ -11,7 +11,6 @@ def get_db_connection(): conn = get_db_connection() data = conn.execute('SELECT user, datein, dateout, ip_branch, id, inspein, inspeout FROM hits WHERE datein != ? AND inspein = ? OR dateout != ? AND inspeout = ? ', ('', '', '', '')).fetchall() - for d in data: params ={ 'access': 'YXR0ZW5kYW5jZXMvYWdvZmVy', @@ -20,9 +19,9 @@ for d in data: 'check_out': d[2], 'ip_branch': d[3], } - response = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json() - print(response) - if response["message"]: + # response = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json() + response = requests.post('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/', json = params).json() + if response["message"] == "Attendance successfully": time = datetime.now(pytz.timezone('America/Bogota')).strftime("%Y-%m-%d %H:%M:%S") if d[1] != '' and d[5] == '': conn.execute("UPDATE hits SET inspein = ? WHERE id = ?", (time, d[4])) diff --git a/main.py b/main.py index e8f582d..965c126 100755 --- a/main.py +++ b/main.py @@ -67,7 +67,8 @@ def generate_next_url(type, ip_branch): @app.route('/') def show_qr_and_list(): # TODO: reject direct connections to server; allow access only via proxy - get_list = requests.get('https://erp.agofer.com/hr_attendance_extended/public/attendance/').json() + # get_list = requests.get('https://erp.agofer.com/hr_attendance_extended/public/attendance/').json() + get_list = requests.get('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/').json() list_ips = get_list["list_ips"] ip_branch = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) if ip_branch in list_ips: @@ -91,6 +92,9 @@ def catch_uuids(id, hashed, type, ip_branch): 'SELECT * FROM hits WHERE uuid1 = ?', (str(id),)).fetchone() existing2 = conn.execute( 'SELECT * FROM hits WHERE uuid2 = ?', (str(id),)).fetchone() + params ={'access': 'YXR0ZW5kYW5jZXMvYWdvZmVy','employee_id': user,'check_in': '','check_out': '','ip_branch': '',} + # employee = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json() + employee = requests.post('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/', json = params).json() if not user: error = 'NO_USERNAME' elif existing1: @@ -99,6 +103,8 @@ def catch_uuids(id, hashed, type, ip_branch): error = 'ALREADY_USED' elif not check_hash(str(id), str(hashed)): error = 'DIFFERENT_NODE' + elif employee["message"] == "Not registered": + error = 'NO_EMPLOYEE' else: if type_check == 'mistake': error = 'DIFFERENT_TYPE' diff --git a/templates/thanks.html b/templates/thanks.html index 70a321d..f022f4a 100644 --- a/templates/thanks.html +++ b/templates/thanks.html @@ -57,6 +57,9 @@
No se encontró el tipo de entrada.
inténteta de nuevo
AQUI.
No se encontró el empleado.
Comuniquese con area de Software y Automatización para resolver el error.
Para registrar la entrada es necesario terminar la jornada de trabajo anterior.