# HG changeset patch # User nishanth # Date 1265364647 -19800 # Node ID 988d4994578f53b9f3b35daa786d9d80d107f08e # Parent 055dc4c1db57bcc1e8d4cc82ac80892434e9426f modified createUser method in events/user.py . diff -r 055dc4c1db57 -r 988d4994578f taskapp/events/user.py --- a/taskapp/events/user.py Fri Feb 05 15:02:55 2010 +0530 +++ b/taskapp/events/user.py Fri Feb 05 15:40:47 2010 +0530 @@ -26,13 +26,17 @@ gender : u'M'/u'F' """ - user = User(username=username, email=email) - user.set_password(password) - user.save() - properties = {'dob':dob, 'gender':gender} - user_profile = Profile(user=user) - updateProfile(user_profile, properties) - return user + try: + user = User.objects.get(username=username) + return user + except: + user = User(username=username, email=email) + user.set_password(password) + user.save() + properties = {'dob':dob, 'gender':gender} + user_profile = Profile(user=user) + updateProfile(user_profile, properties) + return user def createSuUser(username,email,password,dob,gender): """ create user using createUser method and set the is_superuser flag """ @@ -41,3 +45,4 @@ su_user.is_staff = True su_user.is_superuser = True su_user.save() + return su_user diff -r 055dc4c1db57 -r 988d4994578f urls.py --- a/urls.py Fri Feb 05 15:02:55 2010 +0530 +++ b/urls.py Fri Feb 05 15:40:47 2010 +0530 @@ -7,6 +7,8 @@ from pytask.taskapp.views.user import homepage, register, user_login, user_logout, view_my_profile, edit_my_profile, browse_users from pytask.taskapp.views.task import browse_tasks, view_task, create_task, add_mentor, add_tasks, claim_task, assign_task +from pytask.taskapp.utils.seed_db import seed_db + urlpatterns = patterns('', # Example: # (r'^pytask/', include('pytask.foo.urls')), @@ -34,4 +36,6 @@ (r'^user/view/uid=(\d+)$', view_my_profile), (r'^user/edit/?$', edit_my_profile), (r'^user/browse/?$',browse_users), + + (r'^seed_db/$', seed_db), )