Matthew Schinckel avatar 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))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.