diff options
author | nishanth | 2010-02-05 15:42:35 +0530 |
---|---|---|
committer | nishanth | 2010-02-05 15:42:35 +0530 |
commit | 68aadc0ccab2fce65c3ade8fb495c375465c7e5e (patch) | |
tree | 06a5f7c0161c3f942eb2cbf4cf0a4aaeb3511492 /taskapp/utils | |
parent | 1fe5883f26ff2f87930f393dc87e6e084ca9762b (diff) | |
download | pytask-68aadc0ccab2fce65c3ade8fb495c375465c7e5e.tar.gz pytask-68aadc0ccab2fce65c3ade8fb495c375465c7e5e.tar.bz2 pytask-68aadc0ccab2fce65c3ade8fb495c375465c7e5e.zip |
added seed_db in utils that seeds database with random users and tasks .
Diffstat (limited to 'taskapp/utils')
-rw-r--r-- | taskapp/utils/__init__.py | 0 | ||||
-rw-r--r-- | taskapp/utils/seed_db.py | 33 |
2 files changed, 33 insertions, 0 deletions
diff --git a/taskapp/utils/__init__.py b/taskapp/utils/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/taskapp/utils/__init__.py diff --git a/taskapp/utils/seed_db.py b/taskapp/utils/seed_db.py new file mode 100644 index 0000000..e472a9e --- /dev/null +++ b/taskapp/utils/seed_db.py @@ -0,0 +1,33 @@ +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") |