fix ld management
This commit is contained in:
parent
cff748ccbe
commit
1ecb96f520
@ -113,21 +113,26 @@ def process_location_data():
|
|||||||
cli = Client.objects.filter(uuid=ld.client_id, desks__desk_no=ld.desk_no)
|
cli = Client.objects.filter(uuid=ld.client_id, desks__desk_no=ld.desk_no)
|
||||||
if cli.count() < 1:
|
if cli.count() < 1:
|
||||||
ld.processed = True
|
ld.processed = True
|
||||||
ld.error_msg = 'No location object found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no)
|
ld.error_msg = 'No client object found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no)
|
||||||
ld.save()
|
ld.save()
|
||||||
mail_admins(subject=ld.error_msg, message=ld.error_msg)
|
mail_admins(subject=ld.error_msg, message=ld.error_msg)
|
||||||
# TODO Send error eMail to Admin
|
|
||||||
else:
|
else:
|
||||||
cli = cli[0]
|
cli = cli[0]
|
||||||
desk = cli.desks.filter(desk_no=ld.desk_no)[0]
|
desk = cli.desks.filter(desk_no=ld.desk_no, enabled=True)
|
||||||
|
if desk.count() != 1:
|
||||||
|
ld.processed = True
|
||||||
|
ld.error_msg = 'No desk object found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no)
|
||||||
|
ld.save()
|
||||||
|
mail_admins(subject=ld.error_msg, message=ld.error_msg)
|
||||||
|
desk = desk[0]
|
||||||
ac = desk.accounting_set.order_by('time_from').reverse()
|
ac = desk.accounting_set.order_by('time_from').reverse()
|
||||||
if ld.on_off:
|
if ld.on_off:
|
||||||
if ac.count() > 0 and ac[0].time_to is None:
|
if ac.count() > 0 and ac[0].time_to is None:
|
||||||
ac[0].time_to = datetime.now()
|
ac[0].time_to = ld.tst
|
||||||
ac[0].save()
|
ac[0].save()
|
||||||
mail_admins(subject='Accounting passt nicht',
|
mail_admins(subject='Accounting passt nicht',
|
||||||
message='Vorheriges Accounting nicht abgeschlossen: Accounting_id {}'.format(ac[0].id))
|
message='Vorheriges Accounting nicht abgeschlossen: Desk_id {}, Accounting_id {}'
|
||||||
# TODO Send error eMail to Admin
|
.format(desk.id, ac[0].id))
|
||||||
acc = Accounting(
|
acc = Accounting(
|
||||||
desk=desk,
|
desk=desk,
|
||||||
time_from=ld.tst,
|
time_from=ld.tst,
|
||||||
|
Loading…
Reference in New Issue
Block a user