Commits

Matthew Schinckel committed 02d3068

Allow passing in a country or a code.
Allow fetching all holidays after a specified date.

Comments (0)

Files changed (1)

public_holidays/models.py

 from model_utils.managers import PassThroughManager
 
 class PublicHolidayQuerySet(models.query.QuerySet):
+    def after(self, date):
+        return self.filter(date__gte=date)
+    
     def between(self, start, finish):
         return self.filter(date__gte=start, date__lte=finish)
     
     def for_country(self, country, province=None):
+        if getattr(country, 'code', None):
+            country = country.code
+        
         qs = self.filter(country=country)
         if province:
             qs = qs.filter(models.Q(provinces=None) | models.Q(provinces=[]) | models.Q(provinces__contains=province))