summaryrefslogtreecommitdiff
path: root/taskapp/management
diff options
context:
space:
mode:
authornishanth2010-02-12 23:09:11 +0530
committernishanth2010-02-12 23:09:11 +0530
commitae22a79131a2e6decccd0a9542c578d17dbc0000 (patch)
tree78a40f3824dd444a337b3e72cfebb27875206f77 /taskapp/management
parentf22bacc74ce5be78f8d17f218f4aa39369d54cdb (diff)
downloadpytask-ae22a79131a2e6decccd0a9542c578d17dbc0000.tar.gz
pytask-ae22a79131a2e6decccd0a9542c578d17dbc0000.tar.bz2
pytask-ae22a79131a2e6decccd0a9542c578d17dbc0000.zip
removed seed_db from utils and added it as a command for manage.py and removed url corresponding to seed_db .
Diffstat (limited to 'taskapp/management')
-rw-r--r--taskapp/management/__init__.py1
-rw-r--r--taskapp/management/commands/__init__.py0
-rw-r--r--taskapp/management/commands/seed_db.py42
3 files changed, 43 insertions, 0 deletions
diff --git a/taskapp/management/__init__.py b/taskapp/management/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/taskapp/management/__init__.py
@@ -0,0 +1 @@
+
diff --git a/taskapp/management/commands/__init__.py b/taskapp/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/taskapp/management/commands/__init__.py
diff --git a/taskapp/management/commands/seed_db.py b/taskapp/management/commands/seed_db.py
new file mode 100644
index 0000000..60b2a56
--- /dev/null
+++ b/taskapp/management/commands/seed_db.py
@@ -0,0 +1,42 @@
+import sys
+from datetime import datetime
+from django.core.management.base import NoArgsCommand
+
+from django.contrib.auth.models import User
+
+from pytask.taskapp.events import task as taskEvents
+from pytask.taskapp.events import user as userEvents
+
+
+def seed_db():
+ """ a method to seed the database with random data """
+
+ defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M")
+
+ for i in range(1,10):
+
+ username = 'user'+str(i)
+ email = username+'@example.com'
+ password = '123456'
+ dob = datetime.now()
+ gender = "M"
+ userEvents.createUser(username,email,password,dob,gender)
+
+ for i in range(1,21):
+
+ title = "Task "+str(i)
+ desc = "I am "+title
+ created_by = defaultMentor
+ credits = 20
+
+ task = taskEvents.createTask(title,desc,created_by,credits)
+ if task:
+ taskEvents.addMentor(task, defaultMentor)
+ taskEvents.publishTask(task)
+
+class Command(NoArgsCommand):
+
+ def handle_noargs(self, **options):
+ """ Just copied the code from seed_db.py """
+
+ seed_db()