示例#1
0
文件: tests.py 项目: bopopescu/pd
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
示例#2
0
文件: forms.py 项目: bopopescu/pd
    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
示例#3
0
文件: forms.py 项目: braskin/pd
    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
示例#4
0
文件: tests.py 项目: braskin/pd
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