Ejemplo n.º 1
0
# the specific language governing rights and limitations under the License.
#
# The Original Code is reddit.
#
# The Original Developer is the Initial Developer.  The Initial Developer of
# the Original Code is reddit Inc.
#
# All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
# Inc. All Rights Reserved.
###############################################################################

from r2.config.feature.state import FeatureState
from r2.config.feature.world import World
from r2.lib.hooks import HookRegistrar

feature_hooks = HookRegistrar()

_world = World()
_featurestate_cache = {}


def is_enabled(name, user=None, subreddit=None):
    """Test and return whether a given feature is enabled for this request.

    If `feature` is not found, returns False.

    The optional arguments allow overriding that you generally don't want, but
    is useful outside of request contexts - cron jobs and the like.

    :param name string - a given feature name
    :param user - (optional) an Account
Ejemplo n.º 2
0
)
from r2.models.award import Award
from r2.models.gold import append_random_bottlecap_phrase, creddits_lock
from r2.models.token import AwardClaimToken
from r2.models.wiki import WikiPage

from _pylibmc import MemcachedError
from pylons import config
from pylons import tmpl_context as c
from pylons import app_globals as g
from pylons.i18n import _

from datetime import datetime, timedelta
from copy import copy

admintools_hooks = HookRegistrar()


class AdminTools(object):
    def spam(self,
             things,
             auto=True,
             moderator_banned=False,
             banner=None,
             date=None,
             train_spam=True,
             **kw):
        from r2.lib.db import queries

        all_things = tup(things)
        new_things = [x for x in all_things if not x._spam]
Ejemplo n.º 3
0
from r2.controllers import add_controller
from r2.controllers.reddit_base import (
    RedditController,
    DELETE as DELETE_COOKIE,
)
from r2.lib import authentication
from r2.lib.base import abort
from r2.lib.hooks import HookRegistrar
from r2.lib.pages import Reddit, BoringPage
from r2.lib.template_helpers import get_domain
from r2.lib.utils import UrlParser
from r2.lib.validator import validate, VPrintable, VUser
from pages import BetaNotice, BetaSettings, BetaDisable

hooks = HookRegistrar()


def beta_user_exempt(user):
    """Check if the current user is exempt from beta access restrictions."""
    if user.name in g.beta_allowed_users:
        return True

    if user.name in g.admins:
        return True


def beta_user_allowed(user):
    """Check if the current user is permitted to access the beta."""

    if beta_user_exempt(user):
Ejemplo n.º 4
0
# the specific language governing rights and limitations under the License.
#
# The Original Code is reddit.
#
# The Original Developer is the Initial Developer.  The Initial Developer of
# the Original Code is reddit Inc.
#
# All portions of the code written by reddit are Copyright (c) 2006-2014 reddit
# Inc. All Rights Reserved.
###############################################################################

from r2.config.feature.state import FeatureState
from r2.config.feature.world import World
from r2.lib.hooks import HookRegistrar

hooks = HookRegistrar()

_world = World()
_featurestate_cache = {}


def is_enabled(name):
    """Test and return whether a given feature is enabled for this request.

    If `feature` is not found, returns False.

    :param name string - a given feature name
    :return bool
    """
    return _get_featurestate(name).is_enabled(_world.current_user())