From 0661fe0f012400a64c2e095244048285786f4107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Sun, 25 Feb 2018 16:10:38 +0100 Subject: [PATCH] Fix path --- profiles/models.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/profiles/models.py b/profiles/models.py index 7c120e7..ab44199 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -6,13 +6,16 @@ the preferred search engin, and if the user is likely to directly use urls or to type in the search engine. """ +import os import random from django.db import models +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + NICKNAMES = open("/usr/share/dict/american-english").read().splitlines() -LASTNAMES = open("../data/lastnames.txt").read().splitlines() -FIRSTNAMES = open("../data/firstnames.txt").read().splitlines() -EMAIL_DOMAINS = open("../data/email_domains.txt").read().splitlines() +LASTNAMES = open(BASE_DIR + "/data/lastnames.txt").read().splitlines() +FIRSTNAMES = open(BASE_DIR + "/data/firstnames.txt").read().splitlines() +EMAIL_DOMAINS = open(BASE_DIR + "/data/email_domains.txt").read().splitlines() class InvalidData(Exception): @@ -223,7 +226,7 @@ def create_profile(nick=None): nick=nick, first_name=first_name, last_name=last_name, - email=email + email=email, uses_url=(random.random() < 0.5), ) profile.search_engine = random.choice(SearchEngine.objects.all())