Partial generation of profiles
This commit is contained in:
parent
d4aefb6bb7
commit
05a2e2ca3f
1 changed files with 24 additions and 0 deletions
|
@ -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())
|
||||||
|
|
Loading…
Reference in a new issue