dates.py 598 B

123456789101112131415161718192021222324252627
  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(
  6. days=settings.MISAGO_READTRACKER_CUTOFF,
  7. )
  8. if user and user.is_authenticated and user.joined_on > cutoff_date:
  9. return user.joined_on
  10. return cutoff_date
  11. def is_date_tracked(date, user):
  12. if date:
  13. cutoff_date = get_cutoff_date()
  14. if cutoff_date < user.joined_on:
  15. cutoff_date = user.joined_on
  16. return date > cutoff_date
  17. else:
  18. return False