Skip to content
Snippets Groups Projects
Select Git revision
  • bcdd84c0f53ad0f6e262d8c2d45502f4229e04b3
  • master default
  • clement
  • fix_requirements
  • new_signup
  • interface_admin
  • hamza
  • dev
  • test
  • melissa
  • context_sheet
  • sorties_new
  • Seon82-patch-2
  • export_bdd
  • refactor/participation-user-link
15 results

utils.py

Blame
  • utils.py 1.03 KiB
    """Profile utilities."""
    
    import datetime
    from .settings import settings
    
    
    def get_promotion_range(date=None):
        """Return the range of possible promotions.
    
        The new promotion arrival date (NPAD) is defined in settings by:
            NEW_PROMOTION_ARRIVAL_DAY
            NEW_PROMOTION_ARRIVAL_MONTH
    
        Before NPAD :
            - maximum promotion is 3 years ahead of today's year
            - minimum promotion is 2 years behind today's year
        After NPAD :
            - maximum promotion is 4 years ahead of today's year
            - minimum promotion is 1 year behind today's year
    
        Parameters
        ----------
        date : datetime.date or datetime.datetime, optional
            If not given, datetime.datetime.today() is used.
        """
        if date is None:
            date = datetime.datetime.today()
        year = date.year
        month, day = date.month, date.day
        if month >= settings.NEW_PROMOTION_ARRIVAL_MONTH:
            if day >= settings.NEW_PROMOTION_ARRIVAL_DAY:
                year += 1
        return range(year + 2, year + 2 - settings.NUMBER_OF_PROMOTIONS, -1)