<commit_before># -*- coding: UTF-8 -*-
from django.conf import settings
from django.db import models
from django.utils import timezone
from datetime import timedelta
from django.contrib.auth.models import User
import urllib, hashlib, time, random
from core.utils.frespo_utils import get_or_none, socialImages, socialImages_small
from social_auth.models import UserSocialAuth
from django.utils.http import urlquote
from django.template.defaultfilters import slugify
from decimal import Decimal
from core.utils.frespo_utils import twoplaces, CURRENCY_SYMBOLS


class UserInfo(models.Model): 
    user = models.ForeignKey(User)
    paypalEmail = models.EmailField(max_length=256)
    screenName = models.CharField(max_length=64)
    realName = models.CharField(max_length=256)
    website = models.CharField(max_length=128, null=True, blank=True)
    about = models.TextField(null=True, blank=True)
    receiveAllEmail = models.BooleanField()
    brazilianPaypal = models.BooleanField()
    is_primary_email_verified = models.BooleanField()
    is_paypal_email_verified = models.BooleanField()
    hide_from_userlist = models.BooleanField()
    preferred_language_code = models.CharField(max_length=10, null=True, blank=True)
    bitcoin_receive_address = models.CharField(max_length=128, blank=True)

    @classmethod
    def newUserInfo(cls, user):
        userinfo = cls()
        userinfo.user = user
        userinfo.paypalEmail = user.email
        userinfo.is_primary_email_verified = True
        userinfo.is_paypal_email_verified = True
        userinfo.screenName = user.username
        userinfo.website = ''
        userinfo.about = ''
        userinfo.realName = user.first_name+' '+user.last_name
        userinfo.receiveAllEmail = True
        userinfo.brazilianPaypal = False
        userinfo.hide_from_userlist = False
        return userinfo

    def is_differentPaypalEmail(self):
        is_different = self.paypalEmail and self.paypalEmail != self.user.email
        return is_different

    def get_website_url(self):
        if(self.website.startswith("http://") or self.website.startswith("https://")):
            return self.website
        else:
            return "http://"+self.website

    def get_website_short(self):
        if self.website and len(self.website) > 40:
            return self.website[0:40]+'...'
        return self.website

    def is_complete(self):
        return self.screenName and self.realName and self.user.email


def gravatar_url_small(self):
    gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?"
    # return gravatar_url + urllib.urlencode({'d':"http://dl.dropbox.com/u/2683925/glyphicons_003_user.png", 's':"23"})
    return gravatar_url + urllib.urlencode({'d':settings.SITE_HOME+"/static/img/user_23.png", 's':"23"})

def gravatar_url_medium(self):
    gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?"
    return gravatar_url + urllib.urlencode({'d':settings.SITE_HOME+"/static/img/user_48.png", 's':"48"})

def gravatar_url_big(self):
    gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?"
    return gravatar_url + urllib.urlencode({'d':settings.SITE_HOME+"/static/img/user_128.png", 's':"128"})

def getUserInfo(self):
    return get_or_none(UserInfo, user=self)

def getSocialAuths(self):
    return UserSocialAuth.objects.filter(user=self)

def github_username(self):
    for social_auth in self.getSocialAuths():
        if social_auth.provider == 'github' and social_auth.extra_data.has_key('social_username'):
            return social_auth.extra_data['social_username']
    return None

def getOffers(self):
    return Offer.objects.filter(sponsor=self).order_by('status','-price')

def getSolutions(self):
    return Solution.objects.filter(programmer=self).order_by('-creationDate')

def getKickstartingIssues(self):
    return Issue.objects.filter(createdByUser=self, is_public_suggestion=True).order_by('-creationDate')

def set_email_verified(self, is_primary):
    userinfo = self.getUserInfo()
    if is_primary:
        userinfo.is_primary_email_verified = True<commit_msg>#142 Use Gravatar identicons<commit_after># -*- coding: UTF-8 -*-
from django.conf import settings
from django.db import models
from django.utils import timezone
from datetime import timedelta
from django.contrib.auth.models import User
import urllib, hashlib, time, random
from core.utils.frespo_utils import get_or_none, socialImages, socialImages_small
from social_auth.models import UserSocialAuth
from django.utils.http import urlquote
from django.template.defaultfilters import slugify
from decimal import Decimal
from core.utils.frespo_utils import twoplaces, CURRENCY_SYMBOLS


class UserInfo(models.Model): 
    user = models.ForeignKey(User)
    paypalEmail = models.EmailField(max_length=256)
    screenName = models.CharField(max_length=64)
    realName = models.CharField(max_length=256)
    website = models.CharField(max_length=128, null=True, blank=True)
    about = models.TextField(null=True, blank=True)
    receiveAllEmail = models.BooleanField()
    brazilianPaypal = models.BooleanField()
    is_primary_email_verified = models.BooleanField()
    is_paypal_email_verified = models.BooleanField()
    hide_from_userlist = models.BooleanField()
    preferred_language_code = models.CharField(max_length=10, null=True, blank=True)
    bitcoin_receive_address = models.CharField(max_length=128, blank=True)

    @classmethod
    def newUserInfo(cls, user):
        userinfo = cls()
        userinfo.user = user
        userinfo.paypalEmail = user.email
        userinfo.is_primary_email_verified = True
        userinfo.is_paypal_email_verified = True
        userinfo.screenName = user.username
        userinfo.website = ''
        userinfo.about = ''
        userinfo.realName = user.first_name+' '+user.last_name
        userinfo.receiveAllEmail = True
        userinfo.brazilianPaypal = False
        userinfo.hide_from_userlist = False
        return userinfo

    def is_differentPaypalEmail(self):
        is_different = self.paypalEmail and self.paypalEmail != self.user.email
        return is_different

    def get_website_url(self):
        if(self.website.startswith("http://") or self.website.startswith("https://")):
            return self.website
        else:
            return "http://"+self.website

    def get_website_short(self):
        if self.website and len(self.website) > 40:
            return self.website[0:40]+'...'
        return self.website

    def is_complete(self):
        return self.screenName and self.realName and self.user.email


def gravatar_url_small(self):
    gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?"
    # return gravatar_url + urllib.urlencode({'d':settings.SITE_HOME+"/static/img/user_23.png", 's':"23"})
    return gravatar_url + "d=identicon&s=23"

def gravatar_url_medium(self):
    gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?"
    # return gravatar_url + urllib.urlencode({'d':settings.SITE_HOME+"/static/img/user_48.png", 's':"48"})
    return gravatar_url + "d=identicon&s=48"

def gravatar_url_big(self):
    gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?"
    # return gravatar_url + urllib.urlencode({'d':settings.SITE_HOME+"/static/img/user_128.png", 's':"128"})
    return gravatar_url + "d=identicon&s=128"

def getUserInfo(self):
    return get_or_none(UserInfo, user=self)

def getSocialAuths(self):
    return UserSocialAuth.objects.filter(user=self)

def github_username(self):
    for social_auth in self.getSocialAuths():
        if social_auth.provider == 'github' and social_auth.extra_data.has_key('social_username'):
            return social_auth.extra_data['social_username']
    return None

def getOffers(self):
    return Offer.objects.filter(sponsor=self).order_by('status','-price')

def getSolutions(self):
    return Solution.objects.filter(programmer=self).order_by('-creationDate')

def getKickstartingIssues(self):
    return Issue.objects.filter(createdByUser=self, is_public_suggestion=True).order_by('-creationDate')

def set_email_verified(self, is_primary):
    userinfo = self.getUserInfo()
    if is_primary:
        userinfo.is_primary_email_verified = True
{'fraction_non_alphanumeric': 0.11711071640023683, 'fraction_numerical': 0.011841326228537596, 'mean_word_length': 4.106408706166868, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, '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': '7121849', 'n_tokens_mistral': 2816, 'n_tokens_neox': 2667, 'n_words': 473}