<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2011 <NAME>
#
# Author: <NAME> <<EMAIL>>
#
# This program 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.
#
# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

import datetime

from django.contrib.auth.models import User
from django.db import models
from django.db.models import permalink
from django.db.models.signals import post_save
from django.utils.translation import ugettext as _


class UserProfile(models.Model):
    user = models.OneToOneField(User)
    in_search = models.BooleanField(default=True,
        help_text=_('Show my profile in search results'))
    is_public = models.BooleanField(default=True,
        help_text=_('Let others to see my public profile'))
    
    def __unicode__(self):
        return 'Profile for user %s' % self.user.username
    
    @permalink
    def get_absolute_url(self):
        return ('user_profile_public', [str(self.user.username)])
    
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        profile, created = UserProfile.objects.get_or_create(user=instance)
post_save.connect(create_user_profile, sender=User)

class UserActivationCode(models.Model):
    user = models.OneToOneField(User)
    code = models.CharField(max_length=30)
    date_created = models.DateTimeField(auto_now_add=True)
    
    def __unicode__(self):
        return "Activation code %s for user %s" % \
                (self.code, self.user.username)

    @permalink                
    def get_absolute_url(self):
        return ('user_activation', [str(self.code)])
    
    def is_active(self):
        expiration_date = self.date_created.replace(day=self.date_created.day+7)
        now = datetime.datetime.now()
        if now < expiration_date:
            return True
        return False<commit_msg>Added full_name property to UserProfile model<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2011 <NAME>
#
# Author: <NAME> <<EMAIL>>
#
# This program 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.
#
# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

import datetime

from django.contrib.auth.models import User
from django.db import models
from django.db.models import permalink
from django.db.models.signals import post_save
from django.utils.translation import ugettext as _


class UserProfile(models.Model):
    user = models.OneToOneField(User)
    in_search = models.BooleanField(default=True,
        help_text=_('Show my profile in search results'))
    is_public = models.BooleanField(default=True,
        help_text=_('Let others to see my public profile'))
    
    def __unicode__(self):
        return 'Profile for user %s' % self.user.username
    
    @permalink
    def get_absolute_url(self):
        return ('user_profile_public', [str(self.user.username)])

    @property
    def full_name(self):
        f_name, l_name = self.user.first_name, self.user.last_name
        if f_name and l_name:
            return '%s %s' % (f_name, l_name)
        return f_name or l_name or self.user.username
    
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        profile, created = UserProfile.objects.get_or_create(user=instance)
post_save.connect(create_user_profile, sender=User)

class UserActivationCode(models.Model):
    user = models.OneToOneField(User)
    code = models.CharField(max_length=30)
    date_created = models.DateTimeField(auto_now_add=True)
    
    def __unicode__(self):
        return "Activation code %s for user %s" % \
                (self.code, self.user.username)

    @permalink                
    def get_absolute_url(self):
        return ('user_activation', [str(self.code)])
    
    def is_active(self):
        expiration_date = self.date_created.replace(day=self.date_created.day+7)
        now = datetime.datetime.now()
        if now < expiration_date:
            return True
        return False
{'fraction_non_alphanumeric': 0.0913604766633565, 'fraction_numerical': 0.0035749751737835156, 'mean_word_length': 3.3982532751091705, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '2326030', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1441, 'n_words': 468}