author | Nishanth Amuluru <nishanth@fossee.in> |
Wed, 05 Jan 2011 22:30:45 +0530 | |
changeset 219 | f04a1ec7a07f |
parent 218 | 59107ce0a618 |
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 |
183
c088c79a225c
now there is also a notification sent to a new created user in seed_db.
nishanth
parents:
139
diff
changeset
|
11 |
from pytask.taskapp.utilities.notification import create_notification |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
12 |
|
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
|
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 |
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
|
15 |
""" 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
|
16 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
17 |
defaultReviewer = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
18 |
reviewer_profile = defaultReviewer.get_profile() |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
19 |
userEvents.updateProfile(reviewer_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
|
20 |
|
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
21 |
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
|
22 |
|
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 |
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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
gender = "M" |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
28 |
user = userEvents.createUser(username,email,password,dob,gender) |
183
c088c79a225c
now there is also a notification sent to a new created user in seed_db.
nishanth
parents:
139
diff
changeset
|
29 |
create_notification("NU", user) |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
30 |
|
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
31 |
if i%4==0: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
32 |
create_request(defaultReviewer, "MG", user) |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
33 |
elif i%3==0: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
34 |
create_request(defaultReviewer, "DV", user) |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
35 |
elif i%2==0: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
36 |
create_request(defaultReviewer, "AD", user) |
139
56203661002a
provided links to make a raise the privileges of a user.
nishanth
parents:
132
diff
changeset
|
37 |
elif i in [7, 13]: |
132
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
38 |
user.is_active = False |
ca88bf4ad362
implemented notification functionality for AD MG DV.
nishanth
parents:
121
diff
changeset
|
39 |
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
|
40 |
|
121 | 41 |
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
|
42 |
|
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 |
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
|
44 |
desc = "I am "+title |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
45 |
created_by = defaultReviewer |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
46 |
pynts = 20 |
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
|
47 |
|
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
48 |
task = taskEvents.createTask(title,desc,created_by,pynts) |
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
|
49 |
if task: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
183
diff
changeset
|
50 |
taskEvents.addReviewer(task, defaultReviewer) |
111 | 51 |
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
|
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 |
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
|
54 |
|
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 |
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
|
56 |
""" 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
|
57 |
|
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
|
58 |
seed_db() |