当前位置: 首页>>代码示例>>Python>>正文


Python models.Person类代码示例

本文整理汇总了Python中people.models.Person的典型用法代码示例。如果您正苦于以下问题:Python Person类的具体用法?Python Person怎么用?Python Person使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Person类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

 def save(self):
     m = Series.objects.create(
             title=self.title, title_fr=self.title_fr,
             title_int=self.title_int, begin_year=self.begin_year,
             end_year=self.end_year, id_imdb=self.id_imdb,
             poster=self.poster, rating=self.rating,
             votes=self.votes, plot=self.plot,
             language=self.language, alias=self.alias,
             number_of_episodes=0, number_of_seasons=0)
     m.save()
     for idx, actor in enumerate(self.persons['cast']):
         p = Person.add(actor)
         SeriesContributors.objects.create(
                 person=p, series=m, function='A', rank=idx)
     for idx, director in enumerate(self.persons['director']):
         p = Person.add(director)
         SeriesContributors.objects.create(
                 person=p, series=m, function='D', rank=idx)
     for idx, writer in enumerate(self.persons['writer']):
         p = Person.add(writer)
         p.save()
         SeriesContributors.objects.create(
                 person=p, series=m, function='W', rank=idx)
     for genre in self.genres:
         g = Genre.add(genre)
         m.genres.add(g)
     return m
开发者ID:ercool,项目名称:pandore,代码行数:27,代码来源:series_processor.py

示例2: test_that_importing_a_spreadsheet_over_modified_fields_overwrites_them

    def test_that_importing_a_spreadsheet_over_modified_fields_overwrites_them(self):
        """Test with first name, email, phone number, address two, 
           (if appropriate) donation amount, donation date, vol shift hours, and vol shift date"""

        # import a spreadsheet
        people_info = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]

        # make a spreadsheet of them.
        s =self._create_a_person_spreadsheet_and_clear_the_data()

        s.do_import(fields=["first_name","last_name","email","phone_number"])

        # assert that they're back.
        people_info2 = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]

        self.assertEqual(people_info, people_info2)


        # change a value.  Assert that they're not equal
        p = Person.objects_by_account(self.a1).all()[0]
        p.first_name = "foo"
        p.save()

        people_info2 = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]

        self.assertNotEqual(people_info, people_info2)


        # import again.  Assert that we're back to where we started.
        s.do_import(fields=["first_name","last_name","email","phone_number"])

        # assert that they're back.
        people_info2 = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]

        self.assertEqual(people_info, people_info2)
开发者ID:skoczen,项目名称:mycelium,代码行数:35,代码来源:unit_tests.py

示例3: test_queryset_for_new_group_rule_for_general_tag_contains

    def test_queryset_for_new_group_rule_for_general_tag_contains(self):
        # create a new group rule (and TagSet)
        group, group_rule = self.test_create_new_group_rule_for_general_tag_contains()

        # hand-create a few people, some of whom match, and others who don't
        ppl = self._generate_people(number=6)

        self.create_tag_for_person(person=ppl[0], tagset_name="General", tag="really cool test tag")
        self.create_tag_for_person(person=ppl[2], tagset_name="General", tag="really cool test tag")
        self.create_tag_for_person(person=ppl[4], tagset_name="General", tag="another tag")
        self.create_tag_for_person(person=ppl[5], tagset_name="Donor", tag="really cool test tag")

        # assert the queryset string is right
        self.assertEqual(group_rule.queryset_filter_string, "filter(taggeditem__tag__in=Tag.objects_by_account(self.account).filter(tagset__name='General',name__icontains='test'))")

        # get the queryset, make sure it matches a hand-created one.
        qs = group.members
    
        hand_qs = Person.objects_by_account(self.account).filter(Q(pk=ppl[0].pk) | Q(pk=ppl[2].pk) )
        self.assertEqualQuerySets(qs,hand_qs)

        # try for the other tag group
        group2, group_rule2 = self.test_create_new_group_rule_for_general_tag_contains(right_hand_term="another")
        hand_qs2 = Person.objects_by_account(self.account).filter(Q(pk=ppl[4].pk) )
        self.assertEqualQuerySets(group2.members,hand_qs2)
开发者ID:skoczen,项目名称:mycelium,代码行数:25,代码来源:unit_tests.py

示例4: test_queryset_for_new_group_rule_for_custom_tag_is_exactly

    def test_queryset_for_new_group_rule_for_custom_tag_is_exactly(self):
        # hand-create a few people, some of whom match, and others who don't
        ppl = self._generate_people(number=5)


        self.create_tag_for_person(person=ppl[0], tagset_name="new test tagset", tag="really cool test tag")
        self.create_tag_for_person(person=ppl[2], tagset_name="new test tagset", tag="really cool test tag")
        self.create_tag_for_person(person=ppl[4], tagset_name="new test tagset", tag="another tag")

        # create a new group rule
        group, group_rule = self.test_create_new_group_rule_for_custom_tag_is_exactly()

        # assert the queryset string is right
        self.assertEqual(group_rule.queryset_filter_string, "filter(taggeditem__tag__in=Tag.objects_by_account(self.account).filter(tagset__name='new test tagset',name__iexact='test'))")
        # get the queryset, make sure it matches a hand-created one.
        qs = group.members
    
        self.assertEqualQuerySets(qs,Person.objects_by_account(self.account).none())

        # check the contains group
        opposite_group, opposite_group_rule = self.test_create_new_group_rule_for_custom_tag_is_exactly(right_hand_term="test", operator_name="contains")
        opposite_hand_qs = Person.objects_by_account(self.account).filter(Q(pk=ppl[0].pk) | Q(pk=ppl[2].pk) )
        self.assertEqualQuerySets(opposite_group.members,opposite_hand_qs)

        # try for the other tag group
        group2, group_rule2 = self.test_create_new_group_rule_for_custom_tag_is_exactly(right_hand_term="another tag")
        hand_qs2 = Person.objects_by_account(self.account).filter(Q(pk=ppl[4].pk))
        self.assertEqualQuerySets(group2.members,hand_qs2)
开发者ID:skoczen,项目名称:mycelium,代码行数:28,代码来源:unit_tests.py

示例5: test_queryset_for_new_group_rule_for_volunteer_status_is_inactive

    def test_queryset_for_new_group_rule_for_volunteer_status_is_inactive(self):
        from volunteers import VOLUNTEER_STATII
        # hand-create a few people, some of whom match, and others who don't
        ppl = self._generate_people()
        v = ppl[2].volunteer
        v.status = VOLUNTEER_STATII[2][0]    #inactive
        v.save()   
        v = ppl[4].volunteer   
        v.status = VOLUNTEER_STATII[3][0]   #temporarily inactive
        v.save()

        # create a new group rule
        group, group_rule = self.test_create_new_group_rule_for_volunteer_status_is_inactive()

        self.assertEqual(group_rule.queryset_filter_string, "filter(volunteer__status='inactive')")

        # get the queryset, make sure it matches a hand-created one.
        qs = group.members
        hand_qs = Person.objects_by_account(self.account).filter( Q(pk=ppl[2].pk) )

        self.assertEqualQuerySets(qs,hand_qs)

        # check the opposite
        opposite_group, opposite_group_rule = self.test_create_new_group_rule_for_volunteer_status_is_inactive(operator_name="is not")
        oppostite_hand_qs = Person.objects_by_account(self.account).filter(Q(pk=ppl[0].pk) | Q(pk=ppl[1].pk) | Q(pk=ppl[3].pk) | Q(pk=ppl[4].pk) )
        self.assertEqualQuerySets(opposite_group.members,oppostite_hand_qs)
开发者ID:skoczen,项目名称:mycelium,代码行数:26,代码来源:unit_tests.py

示例6: make_a_person

def make_a_person(max=1):
    g, m, f = '','',''
    i = 1
    while i <= max:
        i += 1
        rg = random.randint(1,20)    
        if rg >= 3:
            g = random.choice(GIVEN_NAMES)
        elif rg == 2:
            g = random.choice(INITIALS)

        rm = random.randint(1,50)    
        if rm  == 49:
            m = random.choice(GIVEN_NAMES)
        elif rm == 50:
            m = random.choice(INITIALS)

        rf = random.randint(0,10)    
        if rf >= 1:
            f = random.choice(FAMILY_NAMES)
        
        name = ' '.join(('%s %s %s' %  (g, m, f)).split())
        if name == '':
            print('The name is empty!')
            return
        else:
            p = Person(name=name)
            p.save()
            print('Created person named %s' % p.name)
开发者ID:SacNaturalFoods,项目名称:mess,代码行数:29,代码来源:make_a_mess.py

示例7: add

def add(request):
    name=request.GET.get('name')
    age = request.GET.get('age')
    person= Person()
    person.name=name
    person.age=age
    result= person.save()
    return HttpResponse(str(result))
开发者ID:liue,项目名称:people,代码行数:8,代码来源:views.py

示例8: test_get_row

    def test_get_row(self):
        s = self.created_and_imported_csv_spreadsheet()
        # assert that the get_row function returns what I thought it should
        
        p1 = Person.objects_by_account(self.a1).all()[0]
        p2 = Person.objects_by_account(self.a1).all()[2]

        self.assertEqual(s.get_row(0), self._mailing_list_row_dict(p1))
        self.assertEqual(s.get_row(2), self._mailing_list_row_dict(p2))
开发者ID:skoczen,项目名称:mycelium,代码行数:9,代码来源:unit_tests.py

示例9: add_person_via_organization_search_results

def add_person_via_organization_search_results(request):
    people = Person.objects_by_account(request.account).none()
    if 'q' in request.GET:
        q = request.GET['q']
        if q != "":
            qs = Person.objects_by_account(request.account).all()
            people = Person.search(q,queryset=qs,require_queryset=True, ignorable_chars=["-","(",")"])

    return {"fragments":{"new_person_search_results":render_to_string("organizations/_add_person_to_org_results.html", locals())}}
开发者ID:skoczen,项目名称:mycelium,代码行数:9,代码来源:views.py

示例10: test_get_rows

    def test_get_rows(self):
        s = self.created_and_imported_csv_spreadsheet()
        # assert that the get_rows function returns what I thought it should
        
        p1 = Person.objects_by_account(self.a1).all()[0]
        p2 = Person.objects_by_account(self.a1).all()[1]
        p3 = Person.objects_by_account(self.a1).all()[2]
        people = [p1, p2, p3]

        self.assertEqual(s.get_rows(0,3), [self._mailing_list_row_dict(p) for p in people ])
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:unit_tests.py

示例11: test_num_rows

    def test_num_rows(self):
        # get a sample random spreadsheet with a number of rows I know
        s = self.created_and_imported_csv_spreadsheet()
        # assert that the num_rows function returns what I thought it should
        self.assertEqual(s.num_rows, Person.objects_by_account(self.a1).count())


        s2 = self.created_and_imported_excel_spreadsheet()
        # assert that the num_rows function returns what I thought it should
        self.assertEqual(s2.num_rows, Person.objects_by_account(self.a1).count())
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:unit_tests.py

示例12: getPerson

def getPerson(row, fields, importrec):
    Person, created = Person.objects.get_or_create(
        firstname=Person.normalize("firstname",
                                    getfield(fields, "nom", row)),
        lastname=Person.normalize("lastname",
                                   getfield(fields, "prenom", row)),
        birthday=Person.normalize("lastname",
                                   getfield(fields, "datenaissance", row))
    )
    if created:
        Person.sourcetype = "I"
        Person.sourceid = importrec.pk
        if "prenoms" in fields:
            Person.prenoms = Person.normalize("prenoms",
                getfield(fields, "prenoms", row))
        if "uniquid" in fields:
            Person.uniquid = Person.normalize("uniquid",
                getfield(fields, "uniquid", row))
        if "email" in fields:
            Person.email = Person.normalize("email",
                getfield(fields, "email", row))
        if "mobile" in fields:
            Person.mobile = Person.normalize("mobile",
                getfield(fields, "mobile", row))
        password = User.objects.make_random_password(length=8)
        Person.initpass = password
        Person.save()
        print "Created Person ", Person
    else:
        print "Existing Person", Person
开发者ID:jmbarbier,项目名称:djeskoolz,代码行数:30,代码来源:csvteacher.py

示例13: get_target_object_people_Person

    def get_target_object_people_Person(self):
        from people.models import Person
        if self.has_sufficient_fields_for_identity:
            # find the matching row
            # print self.data
            if "first_name" in self.data and "last_name" in self.data and ( self.data["first_name"] != "" or self.data["last_name"] != ""):
                q = Person.objects_by_account(self.account).all()
                if "first_name" in self.data:
                    q = q.filter(first_name=self.data["first_name"])
                if "last_name" in self.data:
                    q = q.filter(last_name=self.data["last_name"])

                if q.count() == 1:
                    return q[0], False

            # print "first and last name were not enough"

            q = Person.objects_by_account(self.account).all()
            if "email" in self.data and self.data["email"] != "":
                q = q.filter(email=self.data["email"])
                
                if q.count() == 1:
                    return q[0], False
                elif q.count() > 1:
                    if "first_name" in self.data:
                        q = q.filter(first_name=self.data["first_name"])
                    if "last_name" in self.data:
                        q = q.filter(last_name=self.data["last_name"])
                    if q.count() == 1:
                        return q[0], False
                    elif q.count() > 1:
                        if "phone_number" in self.data:
                            q = q.filter(phone_number=self.data["phone_number"])
                        if q.count() == 1:
                            return q[0], False

            # print "email based search wasn't enough"

            q = Person.objects_by_account(self.account).all()
            if "phone_number" in self.data and self.data["phone_number"] != "":
                q = q.filter(phone_number=self.data["phone_number"])
                if q.count() == 1:
                    return q[0], False
                elif q.count() > 1:
                    if "first_name" in self.data:
                        q = q.filter(first_name=self.data["first_name"])
                    if "last_name" in self.data:
                        q = q.filter(last_name=self.data["last_name"])
                    if q.count() == 1:
                        return q[0], False
            
            # print "phone based search wasn't enough."
        return Person.raw_objects.create(account=self.account), True
开发者ID:skoczen,项目名称:mycelium,代码行数:53,代码来源:spreadsheet.py

示例14: _that_importing_a_person_spreadsheet_refills_an_emptied_database

    def _that_importing_a_person_spreadsheet_refills_an_emptied_database(self, file_type=None, extension=None, fields=["first_name","last_name","email","phone_number"]):
        # create a bunch of people, store their info in a dict
        people_info = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]

        # make a spreadsheet of them.
        s = self._create_a_person_spreadsheet_and_clear_the_data(file_type, extension)

        s.do_import(fields=fields)

        # assert that they're back.
        people_info2 = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]

        self.assertEqual(people_info, people_info2)
开发者ID:skoczen,项目名称:mycelium,代码行数:13,代码来源:unit_tests.py

示例15: add_person

def add_person(r):
    if(r.method == "GET"):
        return render(r, 'edit_person.jinja')
    elif(r.method == "POST"):
        p = Person(
            first_name=r.POST['fname'],
            last_name=r.POST['lname'],
            nickname=r.POST['nickname'],
            active=True,
            info=""
        )
        p.save()
        return redirect(people)
开发者ID:elimgoodman,项目名称:Personnel,代码行数:13,代码来源:views.py


注:本文中的people.models.Person类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。