def org_create(request): o = Org() o.name = request.POST['name'].encode('utf-8') o.handle = create_handle(request.POST['name']) o.vision_statement = request.POST['vision_statement'].encode('utf-8') if request.POST['social_mission'] == 'yes': o.social_mission = True else: o.social_mission = False if request.POST['profit'] == 'yes': o.profit_seeking = True else: o.profit_seeking = False o.save() if request.POST['admin'] == 'yes': o.admins.add(request.user) o.save() f, created = UserToOrgFollow.objects.get_or_create(user=request.user, org=o) f.following = True f.save() request.user.refresh_orgs_following() return json_response(json_encode(o))
def org_create(request): o = Org() o.name = request.POST['name'].encode('utf-8') o.handle = create_handle(request.POST['name']) o.vision_statement = request.POST['vision_statement'].encode('utf-8') if request.POST['social_mission'] == 'yes': o.social_mission = True else: o.social_mission = False if request.POST['profit'] == 'yes': o.profit_seeking = True else: o.profit_seeking = False o.save() if request.POST['admin'] == 'yes': o.admins.add(request.user) o.save() f, created = UserToOrgFollow.objects.get_or_create(user = request.user, org = o) f.following = True f.save() request.user.refresh_orgs_following() return json_response(json_encode(o))
def create_test_users(): henryOrg = Org( name="Habitat for Henry", street='3241 S Wabash Ave', city='Chicago', zipCode='60616', state='IL', country='USA', description=""" # HFH: Donate to me I am a one-man org. Woohoo! - Markdown - Is - Cool """, ) henryOrg.save() henryUser = User.objects.create_user( username="******", email="*****@*****.**", password="******", org=henryOrg, ) henryUser.save() henryProfile = Profile( user=henryUser, bio="I am Henry, the guy who made this cool site.", birth_date=datetime.strptime('Aug 1 1997', "%b %d %Y"), ) henryProfile.save() henryItems: Items = Items.default_object() henryItems.apply_list({ # add some items 'toilet paper': 3, 'lettuce': 4, 'bleach': 10, }) henryItems.save() henryHome1 = Home( user=henryUser, name='Condo', street='6060 N Ridge Ave', city='Chicago', zipCode='60660', state='IL', country='USA', items=henryItems, ) henryHome1.save() testuserorg = Org( name="Habitat for Test", street='1634 W Warren Blvd', city='Chicago', zipCode='60612', state='IL', country='USA', description=""" # Test User's Org > I am a one-man org. Woohoo! """, ) testuserorg.save() testUser = User.objects.create_user( username="******", email="*****@*****.**", password="******", org=testuserorg, ) testUser.save() testProfile = Profile( user=testUser, bio="I am a test user! Hi!", birth_date=datetime.now(), ) testProfile.save() testitems: Items = Items.default_object() testitems.apply_list({ # add some items 'lettuce': 4, 'eggplant': 200, }) testitems.save() testUserHome = Home( user=testUser, name='my test home', street='3530 S Wolcott Ave', city='Chicago', zipCode='60609', state='IL', country='USA', items=testitems, ) testUserHome.save()