# HG changeset patch # User nishanth # Date 1265996351 -19800 # Node ID 40651a873f44f2b969108bb7229a1ad35be6c11d # Parent 0f10deac0a9bcd2947eeba1972c0d7b8ae6cb892 removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db . diff -r 0f10deac0a9b -r 40651a873f44 taskapp/__init__.pyc Binary file taskapp/__init__.pyc has changed diff -r 0f10deac0a9b -r 40651a873f44 taskapp/admin.pyc Binary file taskapp/admin.pyc has changed diff -r 0f10deac0a9b -r 40651a873f44 taskapp/management/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskapp/management/__init__.py Fri Feb 12 23:09:11 2010 +0530 @@ -0,0 +1,1 @@ + diff -r 0f10deac0a9b -r 40651a873f44 taskapp/management/commands/__init__.py diff -r 0f10deac0a9b -r 40651a873f44 taskapp/management/commands/seed_db.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskapp/management/commands/seed_db.py Fri Feb 12 23:09:11 2010 +0530 @@ -0,0 +1,42 @@ +import sys +from datetime import datetime +from django.core.management.base import NoArgsCommand + +from django.contrib.auth.models import User + +from pytask.taskapp.events import task as taskEvents +from pytask.taskapp.events import user as userEvents + + +def seed_db(): + """ a method to seed the database with random data """ + + defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") + + for i in range(1,10): + + username = 'user'+str(i) + email = username+'@example.com' + password = '123456' + dob = datetime.now() + gender = "M" + userEvents.createUser(username,email,password,dob,gender) + + for i in range(1,21): + + title = "Task "+str(i) + desc = "I am "+title + created_by = defaultMentor + credits = 20 + + task = taskEvents.createTask(title,desc,created_by,credits) + if task: + taskEvents.addMentor(task, defaultMentor) + taskEvents.publishTask(task) + +class Command(NoArgsCommand): + + def handle_noargs(self, **options): + """ Just copied the code from seed_db.py """ + + seed_db() diff -r 0f10deac0a9b -r 40651a873f44 taskapp/utils/__init__.py diff -r 0f10deac0a9b -r 40651a873f44 taskapp/utils/seed_db.py --- a/taskapp/utils/seed_db.py Fri Feb 05 17:21:00 2010 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -from datetime import datetime -from django.contrib.auth.models import User -from django.http import HttpResponse -from pytask.taskapp.events import task as taskEvents -from pytask.taskapp.events import user as userEvents - -def seed_db(request): - """ a method to seed the database with random data """ - - defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") - - for i in range(1,10): - - username = 'user'+str(i) - email = username+'@example.com' - password = '123456' - dob = datetime.now() - gender = "M" - userEvents.createUser(username,email,password,dob,gender) - - for i in range(1,21): - - title = "Task "+str(i) - desc = "I am "+title - created_by = defaultMentor - credits = 20 - - task = taskEvents.createTask(title,desc,created_by,credits) - if task: - taskEvents.addMentor(task, defaultMentor) - taskEvents.publishTask(task) - - return HttpResponse("Done") diff -r 0f10deac0a9b -r 40651a873f44 urls.py --- a/urls.py Fri Feb 05 17:21:00 2010 +0530 +++ b/urls.py Fri Feb 12 23:09:11 2010 +0530 @@ -38,5 +38,4 @@ (r'^user/edit/?$', userViews.edit_my_profile), (r'^user/browse/?$', userViews.browse_users), - (r'^seed_db/$', seed_db), )