from comment_utils.managers import CommentedObjectManager
from django.db import models


class LiveEntryManager(CommentedObjectManager):
    """
    Custom manager for the Entry model, providing shortcuts for
    filtering by entry status.
    
    """
    def featured(self):
        """
        Returns a ``QuerySet`` of featured Entries.
        
        """
        return self.filter(featured__exact=True)
        
    def get_query_set(self):
        """
        Overrides the default ``QuerySet`` to only include Entries
        with a status of 'live'.
        
        """
        return super(LiveEntryManager, self).get_query_set().filter(status__exact=1)

    def latest_featured(self):
        """
        Returns the latest featured Entry if there is one, or ``None``
        if there isn't.
        
        """
        try:
            return self.featured()[0]
        except IndexError:
            return None

from comment_utils.managers import CommentedObjectManager
from django.db import models


class LiveEntryManager(CommentedObjectManager):
    """
    Custom manager for the Entry model, providing shortcuts for
    filtering by entry status.
    
    """
    def featured(self):
        """
        Returns a ``QuerySet`` of featured Entries.
        
        """
        return self.filter(featured__exact=True)
        
    def get_query_set(self):
        """
        Overrides the default ``QuerySet`` to only include Entries
        with a status of 'live'.
        
        """
        return super(LiveEntryManager, self).get_query_set().filter(status__exact=self.model.LIVE_STATUS)

    def latest_featured(self):
        """
        Returns the latest featured Entry if there is one, or ``None``
        if there isn't.
        
        """
        try:
            return self.featured()[0]
        except IndexError:
            return None

Add the support for the new module constants to the LiveEntryManager
Add the support for the new module constants to the LiveEntryManager


git-svn-id: 9770886a22906f523ce26b0ad22db0fc46e41232@71 5f8205a5-902a-0410-8b63-8f478ce83d95

  from comment_utils.managers import CommentedObjectManager
  from django.db import models
  
  
  class LiveEntryManager(CommentedObjectManager):
      """
      Custom manager for the Entry model, providing shortcuts for
      filtering by entry status.
      
      """
      def featured(self):
          """
          Returns a ``QuerySet`` of featured Entries.
          
          """
          return self.filter(featured__exact=True)
          
      def get_query_set(self):
          """
          Overrides the default ``QuerySet`` to only include Entries
          with a status of 'live'.
          
          """
-         return super(LiveEntryManager, self).get_query_set().filter(status__exact=1)
+         return super(LiveEntryManager, self).get_query_set().filter(status__exact=self.model.LIVE_STATUS)
  
      def latest_featured(self):
          """
          Returns the latest featured Entry if there is one, or ``None``
          if there isn't.
          
          """
          try:
              return self.featured()[0]
          except IndexError:
              return None
  
Add the support for the new module constants to the LiveEntryManager
## Code Before:
from comment_utils.managers import CommentedObjectManager
from django.db import models


class LiveEntryManager(CommentedObjectManager):
    """
    Custom manager for the Entry model, providing shortcuts for
    filtering by entry status.
    
    """
    def featured(self):
        """
        Returns a ``QuerySet`` of featured Entries.
        
        """
        return self.filter(featured__exact=True)
        
    def get_query_set(self):
        """
        Overrides the default ``QuerySet`` to only include Entries
        with a status of 'live'.
        
        """
        return super(LiveEntryManager, self).get_query_set().filter(status__exact=1)

    def latest_featured(self):
        """
        Returns the latest featured Entry if there is one, or ``None``
        if there isn't.
        
        """
        try:
            return self.featured()[0]
        except IndexError:
            return None

## Instruction:
Add the support for the new module constants to the LiveEntryManager
## Code After:
from comment_utils.managers import CommentedObjectManager
from django.db import models


class LiveEntryManager(CommentedObjectManager):
    """
    Custom manager for the Entry model, providing shortcuts for
    filtering by entry status.
    
    """
    def featured(self):
        """
        Returns a ``QuerySet`` of featured Entries.
        
        """
        return self.filter(featured__exact=True)
        
    def get_query_set(self):
        """
        Overrides the default ``QuerySet`` to only include Entries
        with a status of 'live'.
        
        """
        return super(LiveEntryManager, self).get_query_set().filter(status__exact=self.model.LIVE_STATUS)

    def latest_featured(self):
        """
        Returns the latest featured Entry if there is one, or ``None``
        if there isn't.
        
        """
        try:
            return self.featured()[0]
        except IndexError:
            return None
