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


Python Person.objects_by_account方法代码示例

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


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

示例1: test_that_importing_a_spreadsheet_over_modified_fields_overwrites_them

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:37,代码来源:unit_tests.py

示例2: test_queryset_for_new_group_rule_for_general_tag_contains

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:27,代码来源:unit_tests.py

示例3: test_queryset_for_new_group_rule_for_custom_tag_is_exactly

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:30,代码来源:unit_tests.py

示例4: test_queryset_for_new_group_rule_for_volunteer_status_is_inactive

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:28,代码来源:unit_tests.py

示例5: add_person_via_organization_search_results

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
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,代码行数:11,代码来源:views.py

示例6: test_get_row

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:11,代码来源:unit_tests.py

示例7: test_num_rows

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:12,代码来源:unit_tests.py

示例8: test_get_rows

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:12,代码来源:unit_tests.py

示例9: get_target_object_people_Person

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:55,代码来源:spreadsheet.py

示例10: _that_importing_a_person_spreadsheet_refills_an_emptied_database

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    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,代码行数:15,代码来源:unit_tests.py

示例11: _account_numbers_dict

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
def _account_numbers_dict(account):
    start_of_this_year = datetime.date(month=1, day=1, year=datetime.date.today().year)
    
    total_donations = Donation.objects_by_account(account).filter(date__gte=start_of_this_year).count()
    if not total_donations:
        total_donations = 0
    total_donors = Donation.objects_by_account(account).filter(date__gte=start_of_this_year).order_by().all().aggregate(Count('donor', distinct=True))["donor__count"]
    if not total_donors:
        total_donors = 0
    total_donation_amount = Donation.objects_by_account(account).filter(date__gte=start_of_this_year).order_by().all().aggregate(Sum('amount'))["amount__sum"]
    if not total_donation_amount:
        total_donation_amount = 0
    average_donation = Donation.objects_by_account(account).filter(date__gte=start_of_this_year).order_by().all().aggregate(Avg('amount'))["amount__avg"]
    if not average_donation:
        average_donation = 0
    total_volunteer_hours = CompletedShift.objects_by_account(account).filter(date__gte=start_of_this_year).order_by().all().aggregate(Sum('duration'))["duration__sum"]
    if not total_volunteer_hours:
        total_volunteer_hours = 0
    total_people = Person.objects_by_account(account).count()
    total_orgs = Organization.objects_by_account(account).count()
    total_groups = Group.objects_by_account(account).count()
    total_tags = Tag.objects_by_account(account).count()
    total_taggeditems = TaggedItem.objects_by_account(account).count()
    recent_conversations = Conversation.objects_by_account(account).all()[:5]

    return locals()
开发者ID:skoczen,项目名称:mycelium,代码行数:28,代码来源:views.py

示例12: test_that_importing_the_same_spreadsheet_multiple_times_is_idempotent

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    def test_that_importing_the_same_spreadsheet_multiple_times_is_idempotent(self):
        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)

        s.do_import(fields=["first_name","last_name","email","phone_number"])
        people_info2 = [self._person_dict(p) for p in Person.objects_by_account(self.a1)]
        self.assertEqual(people_info, people_info2)
开发者ID:skoczen,项目名称:mycelium,代码行数:18,代码来源:unit_tests.py

示例13: test_importing_a_zip_works

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    def test_importing_a_zip_works(self):
        fields = ["zip",]
        s = self._create_a_person_spreadsheet_and_clear_the_data()
        s.do_import(fields=fields)

        # assert that they're back without names
        assert all(p.zip != None for p in Person.objects_by_account(self.a1))
开发者ID:skoczen,项目名称:mycelium,代码行数:9,代码来源:unit_tests.py

示例14: group_count

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
def group_count(request):
    group_id = request.GET['group_id']
    if group_id:
        group = get_or_404_by_account(Group, request.account, group_id)
        members = group.members
    else:
        members = Person.objects_by_account(request.account).all()
    return {"fragments":{"group_count":render_to_string("spreadsheets/_group_count.html", locals())}}
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:views.py

示例15: test_ignoring_a_column_actually_ignores_it

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import objects_by_account [as 别名]
    def test_ignoring_a_column_actually_ignores_it(self):
        fields = ["first_name","last_name","email",]
        s = self._create_a_person_spreadsheet_and_clear_the_data()
        
        s.do_import(fields=fields)

        # assert that they're back without names
        assert all(p.phone_number == None for p in Person.objects_by_account(self.a1))
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:unit_tests.py


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