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()
 
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.