reg/management/commands/seed_db.py
author nishanth
Fri, 09 Apr 2010 12:28:58 +0530
changeset 4 ededea9ad08b
parent 2 c11afa8623f7
child 23 42e2a810e1c8
permissions -rw-r--r--
login and logout works .
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     1
import sys
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     2
from datetime import datetime
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     3
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     4
from django.core.management.base import NoArgsCommand
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     5
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     6
from django.contrib.auth.models import User
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     7
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     8
from workshop.reg.events import create_user, create_event
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
     9
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    10
def seed_db():
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    11
    """ a method to seed the database with random data """
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    12
    
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    13
    for i in range(20):
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    14
        user = create_user('user'+str(i)+'@example.com','123456', 'User', str(i))
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    15
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    16
    for i in range(5):
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    17
        create_event("workshop"+str(i), "This is workshop"+str(i), datetime(2010, 4, i+4), datetime(2010, 4, i+6), user)
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    18
    
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    19
class Command(NoArgsCommand):
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    20
    
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    21
    def handle_noargs(self, **options):
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    22
        """ Just copied the code from seed_db.py """
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    23
        
c11afa8623f7 incorporated gen_key .
nishanth
parents:
diff changeset
    24
        seed_db()