dates.py 583 B

12345678910111213141516171819202122232425
  1. from datetime import timedelta
  2. from django.utils import timezone
  3. from misago.conf import settings
  4. def get_cutoff_date(user=None):
  5. cutoff_date = timezone.now() - timedelta(days=settings.MISAGO_READTRACKER_CUTOFF)
  6. if user and user.is_authenticated and user.joined_on > cutoff_date:
  7. return user.joined_on
  8. return cutoff_date
  9. def is_date_tracked(date, user):
  10. if date:
  11. cutoff_date = get_cutoff_date()
  12. if cutoff_date < user.joined_on:
  13. cutoff_date = user.joined_on
  14. return date > cutoff_date
  15. else:
  16. return False