testappproj/testapp/management/commands/seed_db.py
author amit@thunder
Mon, 17 May 2010 22:33:59 +0530
changeset 0 0b061d58aea3
permissions -rw-r--r--
First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system

import sys
from datetime import datetime
from random import randrange 

from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User






from testapp.models import Test_User


def seed_db():
    """ a method to seed the database with random data """
    
#    defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M")
#    mentor_profile = defaultMentor.get_profile()
#    userEvents.updateProfile(mentor_profile, {'rights':"AD"})
    
    for i in range(1,21):
        
        username = 'user'+str(i)
        email = username+'@example.com'
        password = '123456'
        fullname='user user'
#        dob = datetime.now()
#        gender = "M"
#        user = userEvents.createUser(username,email,password,dob,gender)
#        create_notification("NU", user)
        user=User.objects.create_user(username=username,email=email,password=password)
        user.is_active = True
        user.save()
        test_user=Test_User(user_id=user.id,fullname=fullname)
        test_user.save()


class Command(NoArgsCommand):
    
    def handle_noargs(self, **options):
        """ Just copied the code from seed_db.py """
        
        seed_db()