Commits

Jacco Flenter committed 51edacf

refactor of the LiveManager, now overrides the get_query_set method instead of all the other methods.
also: get_random is working

Comments (0)

Files changed (1)

scm_core/managers.py

        using common sense while developing!
     """
 
-    def filter(self, *args, **kwargs):
-        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
-        kwargs['publish_date__lte'] = timezone.now
+    def get_query_set(self):
+        return super(LiveManager, self).get_query_set().filter(publish_state=PUBLISH_STATE_PUBLISHED, publish_date__lte=timezone.now)
 
-        return super(LiveManager, self).filter(*args, **kwargs)
-
-    def all(self, *args, **kwargs):
-        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
-        kwargs['publish_date__lte'] = timezone.now
-        return self.filter(*args, **kwargs)
-
-    def count(self, *args, **kwargs):
-        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
-        kwargs['publish_date__lte'] = timezone.now
-        return self.filter(*args, **kwargs).count()
-
-    def get(self, *args, **kwargs):
-        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
-        kwargs['publish_date__lte'] = timezone.now
-
-        return super(LiveManager, self).get(*args, **kwargs)
-
-    def exclude(self, *args, **kwargs):
-        return self.filter().exclude(*args, **kwargs)
-
-    def get_random(self):
-
-        items = self.get_query_set().filter(category=category)
+#    def filter(self, *args, **kwargs):
+#        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
+#        kwargs['publish_date__lte'] = timezone.now
+#
+#        return super(LiveManager, self).filter(*args, **kwargs)
+#
+#    def all(self, *args, **kwargs):
+#        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
+#        kwargs['publish_date__lte'] = timezone.now
+#        return self.filter(*args, **kwargs)
+#
+#    def count(self, *args, **kwargs):
+#        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
+#        kwargs['publish_date__lte'] = timezone.now
+#        return self.filter(*args, **kwargs).count()
+#
+#    def get(self, *args, **kwargs):
+#        kwargs['publish_state'] = PUBLISH_STATE_PUBLISHED
+#        kwargs['publish_date__lte'] = timezone.now
+#
+#        return super(LiveManager, self).get(*args, **kwargs)
+#
+#    def exclude(self, *args, **kwargs):
+#        return self.filter().exclude(*args, **kwargs)
+#
+    def get_random(self, *args, **kwargs):
+        items = self.get_query_set().filter(*args, **kwargs)
         
         count = items.count()