author | nishanth |
Fri, 12 Feb 2010 23:09:11 +0530 | |
changeset 37 | 40651a873f44 |
child 111 | c272d4c601cd |
permissions | -rw-r--r-- |
37
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
1 |
import sys |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
2 |
from datetime import datetime |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
3 |
from django.core.management.base import NoArgsCommand |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
4 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
5 |
from django.contrib.auth.models import User |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
6 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
7 |
from pytask.taskapp.events import task as taskEvents |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
8 |
from pytask.taskapp.events import user as userEvents |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
9 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
10 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
11 |
def seed_db(): |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
12 |
""" a method to seed the database with random data """ |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
13 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
14 |
defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
15 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
16 |
for i in range(1,10): |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
17 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
18 |
username = 'user'+str(i) |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
19 |
email = username+'@example.com' |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
20 |
password = '123456' |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
21 |
dob = datetime.now() |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
22 |
gender = "M" |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
23 |
userEvents.createUser(username,email,password,dob,gender) |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
24 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
25 |
for i in range(1,21): |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
26 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
27 |
title = "Task "+str(i) |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
28 |
desc = "I am "+title |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
29 |
created_by = defaultMentor |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
30 |
credits = 20 |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
31 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
32 |
task = taskEvents.createTask(title,desc,created_by,credits) |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
33 |
if task: |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
34 |
taskEvents.addMentor(task, defaultMentor) |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
35 |
taskEvents.publishTask(task) |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
36 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
37 |
class Command(NoArgsCommand): |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
38 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
39 |
def handle_noargs(self, **options): |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
40 |
""" Just copied the code from seed_db.py """ |
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
41 |
|
40651a873f44
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
nishanth
parents:
diff
changeset
|
42 |
seed_db() |