def create_adult_child(adult, child, relation): adult_child = Adult_Child(adult=adult, child=child, relation=relation, can_view_schedule=True) adult_child.save() return adult_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 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_adult_child(adult, child, relation): adult_child = Adult_Child( adult = adult, child = child, relation = relation, can_view_schedule = True) adult_child.save() return adult_child