<commit_before>from django.db import models
from django.contrib.auth.models import User, Permission
from django.utils.translation import ugettext_lazy as _
import datetime
import hashlib
import random
import re

SHA1_RE = re.compile('^[a-f0-9]{40}$')

class EmailValidationManager(models.Manager):

    @classmethod
    def create(self,user):
        ev = EmailValidation()
        ev.user = user
        ev.email = user.email
        ev.date_requested = datetime.datetime.now()
        salt = hashlib.new('SHA1',str(random.random())).hexdigest()[:5]
        ev.activation_key = hashlib.new('SHA1',salt+user.username).hexdigest()
        ev.save()
        print "activation key = %s" % ev.activation_key
        return ev


class EmailValidation(models.Model):
    user = models.ForeignKey(User)
    email = models.CharField(max_length=50)
    date_requested = models.DateField()
    activation_key = models.CharField(_('activation key'), max_length=40)

    def __unicode__(self):
        return u'%s at %s' % (str(self.user),str(self.date_requested))
<commit_msg>removed use of hashlib. now just using a random string over [a-f0-9] for activation key.<commit_after>from django.db import models
from django.contrib.auth.models import User, Permission
from django.utils.translation import ugettext_lazy as _
import datetime
import random
import re

SHA1_RE = re.compile('^[a-f0-9]{40}$')
alphabet = 'abcdef1234567890'

class EmailValidationManager(models.Manager):

    @classmethod
    def create(self,user):
        ev = EmailValidation()
        ev.user = user
        ev.email = user.email
        ev.date_requested = datetime.datetime.now()
        ev.activation_key = ''.join([random.sample(alphabet,1)[0] for x in range(40)])
        ev.save()
        print "activation key = %s" % ev.activation_key
        return ev


class EmailValidation(models.Model):
    user = models.ForeignKey(User)
    email = models.CharField(max_length=50)
    date_requested = models.DateField()
    activation_key = models.CharField(_('activation key'), max_length=40)

    def __unicode__(self):
        return u'%s at %s' % (str(self.user),str(self.date_requested))

{'fraction_non_alphanumeric': 0.11920222634508348, 'fraction_numerical': 0.017161410018552876, 'mean_word_length': 3.6188436830835116, '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': '6062429', 'n_tokens_mistral': 695, 'n_tokens_neox': 658, 'n_words': 152}