import sys 
import os
import time
import random
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
import django
os.environ['DJANGO_SETTINGS_MODULE'] = 'sikweb.settings'
from django.conf import settings

django.setup()
#django related stuff should be imported below this
from members.models import Member, MemberRequest
from misc.namegenerator import generate_names
MEMBERAMOUNT = 30
MEMBERREQUESTAMOUNT = 3

print ("""THIS SCRIPT WILL GENERATE DUMMY VALUES TO DATABASE 
AND SHOULD __NEVER__ BE RUN ON PRODUCTION. 
IF YOU ARE ON PRODUCTION ABORT (ctrl-c) IMMEDIATELY!!!!
CONTINUING IN 10 SECONDS""")
time.sleep(10)

names = generate_names(MEMBERAMOUNT)
maildomains = ["example.coms",'ggmail.om',"notmail.dom"] #intentionally wrong
places = ["Helsinki", "Espoo", "Korso","Kerava", "Kouvostoliitto"]
for i in range(MEMBERAMOUNT):
    f,l = names[i]
    mail = "{}.{}@{}".format(f.lower(),l.lower(),random.choice(maildomains))
    por = random.choice(places)
    ayy = random.randint(0,1)
    jas = random.randint(0,1)
    Member.objects.create(first_name=f,
                          last_name=l,
                          email=mail,
                          POR=por,
                          AYY=ayy,
                          jas=jas)


for m in list(Member.objects.all())[:5]:
    MemberRequest.objects.create(member=m)
