def moderation_status(request, post=None):
    """Returns a status for the post; None if the post is not permitted at all.

    This routine can be called without a post to attempt to determine the
    moderation status of the user in context (whether they are blocked or not)."""

    # don't moderate admins or featured users. ever.
    if request.typepad_user.is_superuser or request.typepad_user.is_featured_member:
        return Queue.APPROVED

    moderate_everything = True

    user_moderation = False
    if hasattr(settings, 'MODERATE_BY_USER') and settings.MODERATE_BY_USER:
        user_moderation = True
        moderate_everything = False

    type_moderation = False
    post_type = (post and post.type_id) or request.GET.get('post_type')
    if hasattr(settings, 'MODERATE_TYPES'):
        if (settings.MODERATE_TYPES is not None) and \
            len(settings.MODERATE_TYPES) > 0:
            type_moderation = True
        moderate_everything = False

    # if neither MODERATE_BY_USER or MODERATE_TYPES is specified, we presume to
    # moderate everything
    if moderate_everything:
        return Queue.MODERATED

    # OK, we are NOT moderating everything; so now we have to prove moderation
    # by testing if this post type and/or user is moderated
    moderate = False

    # check for user/ip blocks
    if user_moderation:
        can_post, moderate = user_can_post(request.typepad_user, request.META['REMOTE_ADDR'])
        if not can_post:
            if not request.is_ajax():
                request.flash.add('notices', _('Sorry; you are not allowed to post to this site.'))
            # we can't allow this user, so no post status
            return None

    if (not moderate) and type_moderation and (post_type is not None):
        # if this setting is available, only moderate for specified types;
        # otherwise, moderate everything
        moderate = post_type in settings.MODERATE_TYPES

    # this means that even types unspecified in MODERATE_TYPES will
    # be subject to keyword moderation
    if (not moderate) and keyword_moderation(request, post):
        moderate = True

    # this means that even types unspecified in MODERATE_TYPES will
    # be subject to post throttling (except comments; we specifically
    # permit comments to be posted without throttling)
    if (not moderate) and ((post_type is not None) and (post_type != 'comment')):
        moderate = post_throttle(request)

    return (moderate and Queue.MODERATED) or Queue.APPROVED
 def user_is_blocked(self):
     if self.request.typepad_user.is_authenticated() and self.request.typepad_user.is_superuser:
         return False
     user_can_post, moderated = models.user_can_post(self.request.typepad_user,
         self.request.META['REMOTE_ADDR'])
     return not user_can_post