Luke Plant avatar Luke Plant committed 5676a4a

Simplified some code

Comments (0)

Files changed (1)

django_easyfilters/filters.py

 
     @property
     def dateattr(self):
-        """
-        The attribute of a date object that we truncate to when collapsing
-        results.
-        """
+        # The attribute of a date object that we truncate to when collapsing results.
         return self.label
 
     @property
     def relativedeltaattr(self):
-        """
-        The attribute to use for calculations using relativedelta
-        """
+        # The attribute to use for calculations using relativedelta
         return self.label + 's'
 
-    def to_single(self):
-        """
-        Return the same but with 'single=True'
-        """
-        return DateRangeType.get(self.level, True)
-
-    def to_multi(self):
-        """
-        Return the same but with 'single=False'
-        """
-        return DateRangeType.get(self.level, False)
-
     def drilldown(self):
         if self is DAY:
             return None
         if not self.single:
-            return self.to_single()
+            return DateRangeType.get(self.level, True)
         else:
             # We always drill down to 'single', and then generate
             # ranges (i.e. multi) if appropriate.
             elif self.range_type == DAY:
                 return str(int(parts[-1]))
         else:
-            return u'-'.join([DateChoice(self.range_type.to_single(),
+            return u'-'.join([DateChoice(DateRangeType.get(self.range_type.level, True),
                                          [val]).display()
                               for val in self.values])
 
 
     @staticmethod
     def from_datetime_range(range_type, dt1, dt2):
-        return DateChoice(range_type.to_multi(),
+        return DateChoice(DateRangeType.get(range_type.level, False),
                           [DateChoice.datetime_to_value(range_type, dt1),
                            DateChoice.datetime_to_value(range_type, dt2)])
 
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.