<commit_before>import bcrypt
from sqlalchemy import Boolean, Column, Integer, String
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship

from scoring_engine.models.base import Base

from scoring_engine.db import db_salt


class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    username = Column(String(20), nullable=False)
    password = Column(String(50), nullable=False)
    authenticated = Column(Boolean, default=False)
    team_id = Column(Integer, ForeignKey('teams.id'))
    team = relationship("Team", back_populates="users")

    def __init__(self, username, password, team=None):
        self.username = username
        self.password = bcrypt.hashpw(password.encode('utf-8'), db_salt)
        self.team = team

    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return True

    @property
    def is_anonymous(self):
        return False

    @property
    def get_username(self):
        return self.username

    def get_id(self):
        try:
            return unicode(self.id)  # python 2
        except NameError:<commit_msg>Moving encode to store hashpw as string<commit_after>import bcrypt
from sqlalchemy import Boolean, Column, Integer, String
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship

from scoring_engine.models.base import Base

from scoring_engine.db import db_salt


class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    username = Column(String(20), nullable=False)
    password = Column(String(50), nullable=False)
    authenticated = Column(Boolean, default=False)
    team_id = Column(Integer, ForeignKey('teams.id'))
    team = relationship("Team", back_populates="users")

    def __init__(self, username, password, team=None):
        self.username = username
        self.password = bcrypt.hashpw(password, db_salt).encode('utf-8')
        self.team = team

    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return True

    @property
    def is_anonymous(self):
        return False

    @property
    def get_username(self):
        return self.username

    def get_id(self):
        try:
            return unicode(self.id)  # python 2
        except NameError:
{'fraction_non_alphanumeric': 0.09136212624584718, 'fraction_numerical': 0.0049833887043189366, 'mean_word_length': 3.2941176470588234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1336936', 'n_tokens_mistral': 719, 'n_tokens_neox': 681, 'n_words': 187}