Fix: Updated to match the fingerprint uploader to the new attendance machine

This commit is contained in:
tanshu 2016-02-29 23:41:08 +05:30
parent 33b14b1ec0
commit 2e670c06ec
2 changed files with 11 additions and 14 deletions

View File

@ -351,15 +351,6 @@ class Fingerprint(Base):
def query(cls):
return DBSession.query(cls)
def create(self):
old = DBSession.query(Fingerprint).filter(Fingerprint.date == self.date) \
.filter(Fingerprint.employee_id == self.employee_id).first()
if old is None:
DBSession.add(self)
return self
else:
return old
class DbImage(Base):
__tablename__ = 'images'

View File

@ -15,7 +15,7 @@ __author__ = 'tanshu'
def show_list(request):
filename = request.POST['uploadedFile'].filename
input_file = request.POST['uploadedFile'].file
reader = csv.reader(read_file(input_file), delimiter=";")
reader = csv.reader(read_file(input_file), delimiter="\t")
for row in reader:
add_fingerprint(row)
transaction.commit()
@ -35,12 +35,18 @@ def read_file(input_file):
def add_fingerprint(row):
try:
employee_code = int(row[0])
date = datetime.datetime.strptime(row[3] + ' ' + row[4], '%m/%d/%Y %H:%M')
employee_code = int(row[2])
date = datetime.datetime.strptime(row[6], '%Y/%m/%d %H:%M:%S')
except ValueError:
return
employee_id = Employee.by_code(employee_code).id
Fingerprint(employee_id=employee_id, date=date).create()
employee = Employee.by_code(employee_code)
if employee is not None:
fp = Fingerprint(employee_id=employee.id, date=date)
old = DBSession.query(Fingerprint).filter(Fingerprint.date == date) \
.filter(Fingerprint.employee_id == employee.id).first()
if old is None:
DBSession.add(fp)
def get_prints(employee_id, date):