author | nishanth |
Tue, 02 Mar 2010 14:46:05 +0530 | |
changeset 174 | d034cd77cfa6 |
parent 139 | 56203661002a |
child 183 | c088c79a225c |
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 |
|
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
10 |
from pytask.taskapp.utilities.request import create_request |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
11 |
|
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
|
12 |
|
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 |
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
|
14 |
""" 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
|
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 |
defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") |
114 | 17 |
mentor_profile = defaultMentor.get_profile() |
18 |
userEvents.updateProfile(mentor_profile, {'rights':"AD"}) |
|
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
|
19 |
|
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
20 |
for i in range(1,21): |
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
|
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
|
22 |
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
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
gender = "M" |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
27 |
user = userEvents.createUser(username,email,password,dob,gender) |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
28 |
|
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
29 |
if i%4==0: |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
30 |
create_request(defaultMentor, "MG", user) |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
31 |
elif i%3==0: |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
32 |
create_request(defaultMentor, "DV", user) |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
33 |
elif i%2==0: |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
34 |
create_request(defaultMentor, "AD", user) |
139
56203661002a
provided links to make a raise the privileges of a user.
nishanth
parents:
132
diff
changeset
|
35 |
elif i in [7, 13]: |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
36 |
user.is_active = False |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
37 |
user.save() |
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
|
38 |
|
121 | 39 |
for i in range(1,21): |
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
|
40 |
|
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 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
|
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
|
46 |
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
|
47 |
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
|
48 |
taskEvents.addMentor(task, defaultMentor) |
111 | 49 |
if i%2==0:taskEvents.publishTask(task) |
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
|
50 |
|
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
|
51 |
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
|
52 |
|
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
|
53 |
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
|
54 |
""" 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
|
55 |
|
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
|
56 |
seed_db() |