main[ADD]attendance_flask:Codigos QR para asistencias
This commit is contained in:
parent
9852f162d4
commit
b57e7e4128
@ -11,7 +11,6 @@ def get_db_connection():
|
|||||||
|
|
||||||
conn = 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()
|
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:
|
for d in data:
|
||||||
params ={
|
params ={
|
||||||
'access': 'YXR0ZW5kYW5jZXMvYWdvZmVy',
|
'access': 'YXR0ZW5kYW5jZXMvYWdvZmVy',
|
||||||
@ -20,9 +19,9 @@ for d in data:
|
|||||||
'check_out': d[2],
|
'check_out': d[2],
|
||||||
'ip_branch': d[3],
|
'ip_branch': d[3],
|
||||||
}
|
}
|
||||||
response = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json()
|
# response = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json()
|
||||||
print(response)
|
response = requests.post('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/', json = params).json()
|
||||||
if response["message"]:
|
if response["message"] == "Attendance successfully":
|
||||||
time = datetime.now(pytz.timezone('America/Bogota')).strftime("%Y-%m-%d %H:%M:%S")
|
time = datetime.now(pytz.timezone('America/Bogota')).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
if d[1] != '' and d[5] == '':
|
if d[1] != '' and d[5] == '':
|
||||||
conn.execute("UPDATE hits SET inspein = ? WHERE id = ?", (time, d[4]))
|
conn.execute("UPDATE hits SET inspein = ? WHERE id = ?", (time, d[4]))
|
||||||
|
|||||||
8
main.py
8
main.py
@ -67,7 +67,8 @@ def generate_next_url(type, ip_branch):
|
|||||||
@app.route('/')
|
@app.route('/')
|
||||||
def show_qr_and_list():
|
def show_qr_and_list():
|
||||||
# TODO: reject direct connections to server; allow access only via proxy
|
# 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"]
|
list_ips = get_list["list_ips"]
|
||||||
ip_branch = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
|
ip_branch = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
|
||||||
if ip_branch in list_ips:
|
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()
|
'SELECT * FROM hits WHERE uuid1 = ?', (str(id),)).fetchone()
|
||||||
existing2 = conn.execute(
|
existing2 = conn.execute(
|
||||||
'SELECT * FROM hits WHERE uuid2 = ?', (str(id),)).fetchone()
|
'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:
|
if not user:
|
||||||
error = 'NO_USERNAME'
|
error = 'NO_USERNAME'
|
||||||
elif existing1:
|
elif existing1:
|
||||||
@ -99,6 +103,8 @@ def catch_uuids(id, hashed, type, ip_branch):
|
|||||||
error = 'ALREADY_USED'
|
error = 'ALREADY_USED'
|
||||||
elif not check_hash(str(id), str(hashed)):
|
elif not check_hash(str(id), str(hashed)):
|
||||||
error = 'DIFFERENT_NODE'
|
error = 'DIFFERENT_NODE'
|
||||||
|
elif employee["message"] == "Not registered":
|
||||||
|
error = 'NO_EMPLOYEE'
|
||||||
else:
|
else:
|
||||||
if type_check == 'mistake':
|
if type_check == 'mistake':
|
||||||
error = 'DIFFERENT_TYPE'
|
error = 'DIFFERENT_TYPE'
|
||||||
|
|||||||
@ -57,6 +57,9 @@
|
|||||||
<h1>Error</h1>
|
<h1>Error</h1>
|
||||||
<p>No se encontró el tipo de entrada.<br /><br /><a href='https://attendance.agofer.net'>inténteta de nuevo
|
<p>No se encontró el tipo de entrada.<br /><br /><a href='https://attendance.agofer.net'>inténteta de nuevo
|
||||||
AQUI</a>.</p>
|
AQUI</a>.</p>
|
||||||
|
{% elif error == 'NO_EMPLOYEE' %}
|
||||||
|
<h1>Error</h1>
|
||||||
|
<p>No se encontró el empleado.<br /> Comuniquese con area de Software y Automatización para resolver el error.<br /></p>
|
||||||
{% elif error == 'MISSING_EXIT' %}
|
{% elif error == 'MISSING_EXIT' %}
|
||||||
<h1>!Olvidaste la Salida!</h1>
|
<h1>!Olvidaste la Salida!</h1>
|
||||||
<p>Para registrar la entrada es necesario terminar la jornada de trabajo anterior.<br /><br /><a
|
<p>Para registrar la entrada es necesario terminar la jornada de trabajo anterior.<br /><br /><a
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user