<commit_before># Copyright 2012 <NAME>
# Copyright 2012 Other contributers as noted in the CONTRIBUTERS file
#
# This file is part of Galah.
#
# Galah is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Galah is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Galah.  If not, see <http://www.gnu.org/licenses/>.

# Wrapper around User to allow Flask-Login to work with it
from types import MethodType
def FlaskUser(user):
    "Decorates a given User instance with the methods in the UserMixin class"
    
    methodize = lambda func: MethodType(func, user)
    
    # Too many problems were occuring transplanting the UserMixin class so I
    # remade the methods here.
    user.is_active = methodize(lambda self: True)
    user.is_authenticated = methodize(lambda self: True)
    user.is_anonymous = methodize(lambda self: True)
    user.get_id = methodize(lambda self: self.id)
    
    return user

# All users must have an account_type variable in order for the 
# account_type_required decorator to work
from flask.ext.login import AnonymousUser
class Anonymous(AnonymousUser):
    account_type = None

## Decorator that enforces account_type based permissions ##
from functools import wraps
from flask.ext.login import current_user
from flask import current_app, flash
from types import StringType
from galah.base.pretty import pretty_list
from galah.web import app
def account_type_required(account_type):
    """
    A decorator that can be applied to views to only allow access to users with
    certain account types.<commit_msg>FlaskUser is_anonymous no longer returns true.<commit_after># Copyright 2012 <NAME>
# Copyright 2012 Other contributers as noted in the CONTRIBUTERS file
#
# This file is part of Galah.
#
# Galah is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Galah is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Galah.  If not, see <http://www.gnu.org/licenses/>.

# Wrapper around User to allow Flask-Login to work with it
from types import MethodType
def FlaskUser(user):
    "Decorates a given User instance with the methods in the UserMixin class"
    
    methodize = lambda func: MethodType(func, user)
    
    # Too many problems were occuring transplanting the UserMixin class so I
    # remade the methods here.
    user.is_active = methodize(lambda self: True)
    user.is_authenticated = methodize(lambda self: True)
    user.is_anonymous = methodize(lambda self: False)
    user.get_id = methodize(lambda self: self.id)
    
    return user

# All users must have an account_type variable in order for the 
# account_type_required decorator to work
from flask.ext.login import AnonymousUser
class Anonymous(AnonymousUser):
    account_type = None

## Decorator that enforces account_type based permissions ##
from functools import wraps
from flask.ext.login import current_user
from flask import current_app, flash
from types import StringType
from galah.base.pretty import pretty_list
from galah.web import app
def account_type_required(account_type):
    """
    A decorator that can be applied to views to only allow access to users with
    certain account types.
{'fraction_non_alphanumeric': 0.05319148936170213, 'fraction_numerical': 0.004453240969816922, 'mean_word_length': 4.15031847133758, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3694818', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1063, 'n_words': 522}