Exemplo n.º 1
0
def register(request):
  if request.method == "POST":
    user_form = UserForm(request.POST)
    if user_form.is_valid():
      user = user_form.save()
      password = make_password(request.POST['password'])
      user.password = password
      user.save()
      profile = UserProfile()
      profile.user = user
      api_key = hashlib.md5((user.username + str(datetime.now())).encode('utf-8')).hexdigest()
      profile.api_key = api_key
      print("*"*20)
      print(api_key)
      profile.save()
      return redirect('user_home', username=user)
  return HttpResponse("Couldn't register this user")
Exemplo n.º 2
0
#Find Ken
# ken = User.objects.get_or_create(username='******')

# #Create ken's tasks
# for num in range(1,5):
#   new_task = ToDo(title=fake.sentence())
#   new_task.user = ken[0]
#   new_task.save()

#Create random users
for num in range(0, 20):
  user = User.objects.get_or_create(username=fake.user_name())
  profile = UserProfile()
  profile.user = user[0]
  profile.api_key = hashlib.md5((user[0].username + str(datetime.now())).encode('utf-8')).hexdigest()
  profile.save()
  users.append(user)

#Create and assign tasks for random people
# for num in range(0, len(users)):
#   new_task = ToDo(title=fake.sentence())
#   new_task.user = users[randint(0, len(users)-1)][0]
#   if num % 2 == 0:
#     new_task.completed = True
#   new_task.save()
#   todos.append(new_task)

# create random tasks
for num in range(0, 20):
  new_task = ToDo(title=fake.sentence())