Partial generation of profiles

This commit is contained in:
Rémi Oudin 2018-02-25 13:18:12 +01:00
parent d4aefb6bb7
commit 05a2e2ca3f

View file

@ -204,3 +204,27 @@ class Profile(models.Model):
on_delete=models.CASCADE) on_delete=models.CASCADE)
browser_fingerprint = models.ForeignKey(BrowserFingerprint, browser_fingerprint = models.ForeignKey(BrowserFingerprint,
on_delete=models.CASCADE) on_delete=models.CASCADE)
def generate_email(nick, first_name, last_name):
domain = random.choice(EMAIL_DOMAINS)
if random.random() < 0.3:
email = first_name + "." + last_name + "@" + domain
else:
email = nick + "@" + domain
return email
def create_profile(nick=None):
nick = "".join(random.sample(NICKNAMES, random.randrange(2,5)))
first_name = random.choice(FIRSTNAMES)
last_name = random.choice(LASTNAMES)
email = generate_email(nick, first_name, last_name)
profile = Profile(
nick=nick,
first_name=first_name,
last_name=last_name,
email=email
uses_url=(random.random() < 0.5),
)
profile.search_engine = random.choice(SearchEngine.objects.all())
profile.browser_fingerprint = random.choice(BrowserFingerprint.objects.all())