testappproj/testapp/management/commands/seed_db.py
changeset 0 0b061d58aea3
equal deleted inserted replaced
-1:000000000000 0:0b061d58aea3
       
     1 import sys
       
     2 from datetime import datetime
       
     3 from random import randrange 
       
     4 
       
     5 from django.core.management.base import NoArgsCommand
       
     6 from django.contrib.auth.models import User
       
     7 
       
     8 
       
     9 
       
    10 
       
    11 
       
    12 
       
    13 from testapp.models import Test_User
       
    14 
       
    15 
       
    16 def seed_db():
       
    17     """ a method to seed the database with random data """
       
    18     
       
    19 #    defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M")
       
    20 #    mentor_profile = defaultMentor.get_profile()
       
    21 #    userEvents.updateProfile(mentor_profile, {'rights':"AD"})
       
    22     
       
    23     for i in range(1,21):
       
    24         
       
    25         username = 'user'+str(i)
       
    26         email = username+'@example.com'
       
    27         password = '123456'
       
    28         fullname='user user'
       
    29 #        dob = datetime.now()
       
    30 #        gender = "M"
       
    31 #        user = userEvents.createUser(username,email,password,dob,gender)
       
    32 #        create_notification("NU", user)
       
    33         user=User.objects.create_user(username=username,email=email,password=password)
       
    34         user.is_active = True
       
    35         user.save()
       
    36         test_user=Test_User(user_id=user.id,fullname=fullname)
       
    37         test_user.save()
       
    38 
       
    39 
       
    40 class Command(NoArgsCommand):
       
    41     
       
    42     def handle_noargs(self, **options):
       
    43         """ Just copied the code from seed_db.py """
       
    44         
       
    45         seed_db()