def create_child(fname, lname, gender, birthdate): child = Child(first_name=fname, last_name=lname, gender=gender, birthdate=birthdate) child.save() return child
def create_child(lname=None, year_range=None): gender = get_random_gender() fname = get_random_fname(gender) if year_range is not None: birthdate = get_random_bd(year_range = year_range) else: birthdate = get_random_bd() photo = kid_photo(gender) age = get_age(birthdate) grade_level = calc_grade_level(age) school = get_school() child = Child(first_name=fname, last_name=lname, gender=gender, birthdate = birthdate, grade_level = grade_level, school=school) child.save() f = open(photo, 'r') np = Photo(album=child.album, caption="Profile", original_image=File(f)) np.save() child.set_profile_pic(np) return child
def create_child(lname=None, year_range=None): gender = get_random_gender() fname = get_random_fname(gender) if year_range is not None: birthdate = get_random_bd(year_range=year_range) else: birthdate = get_random_bd() photo = kid_photo(gender) age = get_age(birthdate) grade_level = calc_grade_level(age) school = get_school() child = Child(first_name=fname, last_name=lname, gender=gender, birthdate=birthdate, grade_level=grade_level, school=school) child.save() f = open(photo, 'r') np = Photo(album=child.album, caption="Profile", original_image=File(f)) np.save() child.set_profile_pic(np) return child
def save(self, request=None): child = Child() child.first_name = self.cleaned_data["first_name"] child.first_name = child.first_name.title() child.last_name = self.cleaned_data["last_name"] if child.last_name is None or (len(child.last_name) == 0): child.last_name = request.user.get_profile().last_name child.gender = self.cleaned_data["gender"] child.birthdate = self.cleaned_data["birthdate"] school = self.cleaned_data["school"] schoolname = self.cleaned_data["schoolname"] sch = None if (len(school)): sch = School.objects.get(id=school) elif (len(schoolname)): pd_sch, fa = PD_School.objects.get_or_create(name=schoolname) sch,fa = School.objects.get_or_create(gsid="PD"+str(pd_sch.id), name=schoolname, pd=True) if sch is not None: child.school = sch child.save() relation = self.cleaned_data["relation"] childrelation = Adult_Child() childrelation.adult=request.user childrelation.child=child childrelation.relation=settings.RELATION_TYPES_DICT[relation] childrelation.set_admin_perms() childrelation.save() return True
def create_child(fname, lname, gender, birthdate): child = Child(first_name=fname, last_name=lname, gender=gender, birthdate = birthdate) child.save() return child
def save(self, request=None): child = Child() child.first_name = self.cleaned_data["first_name"] child.first_name = child.first_name.title() child.last_name = self.cleaned_data["last_name"] if child.last_name is None or (len(child.last_name) == 0): child.last_name = request.user.get_profile().last_name child.gender = self.cleaned_data["gender"] child.birthdate = self.cleaned_data["birthdate"] school = self.cleaned_data["school"] schoolname = self.cleaned_data["schoolname"] sch = None if (len(school)): sch = School.objects.get(id=school) elif (len(schoolname)): pd_sch, fa = PD_School.objects.get_or_create(name=schoolname) sch, fa = School.objects.get_or_create(gsid="PD" + str(pd_sch.id), name=schoolname, pd=True) if sch is not None: child.school = sch child.save() relation = self.cleaned_data["relation"] childrelation = Adult_Child() childrelation.adult = request.user childrelation.child = child childrelation.relation = settings.RELATION_TYPES_DICT[relation] childrelation.set_admin_perms() childrelation.save() return True