<commit_before>from datetime import datetime
from couchdbkit.ext.django.schema import *
from django.contrib.auth.models import get_hexdigest, check_password, UNUSABLE_PASSWORD
from django.core.mail import send_mail
import random

class User(Document):
    username      = StringProperty(required=True)
    first_name    = StringProperty(required=False)
    last_name     = StringProperty(required=False)
    email         = StringProperty(required=False)
    password      = StringProperty(required=True)
    is_staff      = BooleanProperty(default=False)
    is_active     = BooleanProperty(default=True)
    is_superuser  = BooleanProperty(default=False)
    last_login    = DateTimeProperty(required=False)
    date_joined   = DateTimeProperty(default=datetime.utcnow)

    class Meta:
        app_label = "django_couchdb_utils_auth"

    def __unicode__(self):
        return self.username

    def __repr__(self):
        return "<User: %s>" %self.username

    def is_anonymous(self):
        return False

    def save(self):
        if not self.check_username():
            raise Exception('This username is already in use')

        super(User, self).save()


    def check_username(self):
        u = User.get_user(self.username, is_active=None)
        if self._id is None or u is None:
            return True
        return u._id == self._id

    def _get_id(self):
        return self.username

    id = property(_get_id)

    def get_full_name(self):
        "Returns the first_name plus the last_name, with a space in between."
        full_name = u'%s %s' % (self.first_name, self.last_name)<commit_msg>Return the document after the save.<commit_after>from datetime import datetime
from couchdbkit.ext.django.schema import *
from django.contrib.auth.models import get_hexdigest, check_password, UNUSABLE_PASSWORD
from django.core.mail import send_mail
import random

class User(Document):
    username      = StringProperty(required=True)
    first_name    = StringProperty(required=False)
    last_name     = StringProperty(required=False)
    email         = StringProperty(required=False)
    password      = StringProperty(required=True)
    is_staff      = BooleanProperty(default=False)
    is_active     = BooleanProperty(default=True)
    is_superuser  = BooleanProperty(default=False)
    last_login    = DateTimeProperty(required=False)
    date_joined   = DateTimeProperty(default=datetime.utcnow)

    class Meta:
        app_label = "django_couchdb_utils_auth"

    def __unicode__(self):
        return self.username

    def __repr__(self):
        return "<User: %s>" %self.username

    def is_anonymous(self):
        return False

    def save(self):
        if not self.check_username():
            raise Exception('This username is already in use')
        return super(User, self).save()

    def check_username(self):
        u = User.get_user(self.username, is_active=None)
        if self._id is None or u is None:
            return True
        return u._id == self._id

    def _get_id(self):
        return self.username

    id = property(_get_id)

    def get_full_name(self):
        "Returns the first_name plus the last_name, with a space in between."
        full_name = u'%s %s' % (self.first_name, self.last_name)
{'fraction_non_alphanumeric': 0.08473539308657081, 'fraction_numerical': 0.0, 'mean_word_length': 3.047029702970297, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5507211', 'n_tokens_mistral': 955, 'n_tokens_neox': 929, 'n_words': 235}