Browse Source

[FIX] can unsubscribe

delta is between date in the future and now not the opposite
To get the full timedelta in hours we should get the days number and the seconds
12.0-macavrac-prod
Thibault Francois 4 years ago
committed by GitHub
parent
commit
30a5fc707e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      macavrac_base/models/planning.py

3
macavrac_base/models/planning.py

@ -64,7 +64,8 @@ class Task(models.Model):
if now > rec.start_time or rec.state != 'open': if now > rec.start_time or rec.state != 'open':
rec.can_unsubscribe = False rec.can_unsubscribe = False
else: else:
delta = (now - rec.start_time).seconds / 3600.0
delta = (rec.start_time - now)
delta = delta.seconds / 3600.0 + delta.days * 24
rec.can_unsubscribe = delta >= max_hours rec.can_unsubscribe = delta >= max_hours

Loading…
Cancel
Save