equal
deleted
inserted
replaced
2 from datetime import datetime |
2 from datetime import datetime |
3 from django.core.management.base import NoArgsCommand |
3 from django.core.management.base import NoArgsCommand |
4 |
4 |
5 from django.contrib.auth.models import User |
5 from django.contrib.auth.models import User |
6 |
6 |
7 from pytask.profile.models import Profile |
7 from pytask.profile.models import Profile, Notification |
8 |
8 |
9 def seed_db(): |
9 def seed_db(): |
10 """ a method to seed the database with random data """ |
10 """ a method to seed the database with random data """ |
11 |
11 |
12 |
12 |
13 for i in range(1,21): |
13 for i in range(21,1,-1): |
14 |
14 |
15 username = 'user'+str(i) |
15 username = 'user'+str(i) |
16 email = username+'@example.com' |
16 email = username+'@example.com' |
17 password = '123456' |
17 password = '123456' |
18 dob = datetime.now() |
18 dob = datetime.now() |
36 new_profile.rights = "CT" |
36 new_profile.rights = "CT" |
37 elif i%3 == 0: |
37 elif i%3 == 0: |
38 new_profile.rights = "CR" |
38 new_profile.rights = "CR" |
39 new_profile.save() |
39 new_profile.save() |
40 |
40 |
|
41 new_user.is_superuser = True |
|
42 new_user.is_staff = True |
|
43 new_user.save() |
|
44 |
|
45 for i in range(10): |
|
46 Notification(sent_to=new_user, sent_date=datetime.now(), |
|
47 subject="A subject here for"+str(i), |
|
48 message="A message with mess"+str(i)+" html inside.\ |
|
49 <br /><b>a bold text</b>" |
|
50 ).save() |
|
51 |
41 class Command(NoArgsCommand): |
52 class Command(NoArgsCommand): |
42 |
53 |
43 def handle_noargs(self, **options): |
54 def handle_noargs(self, **options): |
44 """ Just copied the code from seed_db.py """ |
55 """ Just copied the code from seed_db.py """ |
45 |
56 |