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


Python models.Person类代码示例

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


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

示例1: add_user

def add_user(req):
    user = req.user
    stub = user.username.split('@')[0]
    user.email = req.POST['email']
    user.first_name = req.POST['first_name']
    user.last_name = req.POST['last_name']
    user.save()
    org_group = OrgGroup(pk=req.POST['team'])
    office_location = OfficeLocation(pk=req.POST['office_location'])

    attributes = {
        'user': user,
        'stub': stub,
        'title': req.POST['title'],
        'office_location': office_location,
        'org_group': org_group,
        'office_phone': req.POST['office_phone'],
        'mobile_phone': req.POST['mobile_phone']
    }

    if req.FILES:
        attributes['photo_file'] = req.FILES['photo_file']

    person = Person(**attributes)
    person.save()
    return user
开发者ID:Gointer,项目名称:collab,代码行数:26,代码来源:views.py

示例2: create_superuser

def create_superuser():
    user = get_user_model().objects.create_superuser('[email protected]', '[email protected]', '1')
    # If using collab, person objects needs to be created too
    if 'core' in settings.INSTALLED_APPS:
        from core.models import Person
        person = Person()
        person.user = user
        person.save()
开发者ID:MonteDesai,项目名称:idea-box,代码行数:8,代码来源:utils.py

示例3: test_generating_slug

    def test_generating_slug(self):
        person = Person(name='Charles Babbage')
        person.save()

        self.assertEqual(
            person.slug,
            'charles-babbage',
        )
开发者ID:almereyda,项目名称:historymesh,代码行数:8,代码来源:slugs.py

示例4: get_user

 def get_user(self, user, name, profile_picture):
     person = None
     try:
         person = Person.objects.get(login=user)
     except Person.DoesNotExist:
         person = Person(login=user, name=name, profile_picture=profile_picture)
         person.save()
     return person
开发者ID:xstpl,项目名称:beholder,代码行数:8,代码来源:Utils.py

示例5: test_helper_no_profile

 def test_helper_no_profile(self):
     u = get_user_model()()
     u.first_name = "John"
     u.last_name = "Smith"
     u.save()
     self.assertEquals(False, helpers.user_has_profile(u))
     p = Person()
     p.user = u
     p.save()
     self.assertEquals(True, helpers.user_has_profile(u))
开发者ID:Gointer,项目名称:collab,代码行数:10,代码来源:test_models.py

示例6: test_multiple_tags_multiple_users

    def test_multiple_tags_multiple_users(self):
        user1 = UserF(username="[email protected]")
        person1 = Person(user=user1)
        person1.save()

        user2 = UserF(username="[email protected]")
        person2 = Person(user=user2)
        person2.save()

        user3 = UserF(username="[email protected]")
        person3 = Person(user=user3)
        person3.save()

        tag_category = TagCategory(name='Test Category',
                                   slug='staff-directory-test-category')
        tag_category.save()

        tags = []
        tagged_item = add_tags(person1, 'TagA',
                                'staff-directory-test-category', user1, 'person')
        tagged_item = add_tags(person2, 'TagA',
                                'staff-directory-test-category', user1, 'person')
        tags.append(tagged_item.tag.slug)

        tagged_item = add_tags(person2, 'TagB',
                                'staff-directory-test-category', user1, 'person')
        tagged_item = add_tags(person3, 'TagB',
                                'staff-directory-test-category', user2, 'person')
        tags.append(tagged_item.tag.slug)

        emails = _get_emails_for_tag(tags)
        self.assertTrue(len(emails) == 1)
        self.assertIn(user2.email, emails)
开发者ID:cfpb,项目名称:collab-staff-directory,代码行数:33,代码来源:test_unit.py

示例7: handle

    def handle(self, *args, **options):
        last_names = [
            'Sherman', 'Maddox', 'Montgomery', 'Small', 'Larsen', 'Marsh', 'Gardner', 'White', 'Gill', 'Pennington', 'Stein', 'Kirby', 'Jennings', 'French', 'Glass', 'Velasquez', 'Doyle', 'York', 'Fisher', 'Strong', 'Henson', 'Harmon', 'Higgins', 'James', 'Hancock', 'Drake', 'Eaton', 'Gordon', 'Harrington', 'Blevins', 'Avila', 'Solis', 'Richmond', 'Stark', 'Haynes', 'Durham', 'Montoya', 'Barrett', 'Chase', 'Mckay', 'Little', 'Perry', 'Howard', 'Caldwell', 'West', 'Fox', 'Long', 'Wright', 'Foster', 'Sloan', 'Frazier', 'Lowe', 'Cabrera', 'Barron', 'Ayala', 'Frank', 'Hammond', 'Orr', 'Holloway', 'King', 'Rush', 'Wiley', 'Neal', 'Davis', 'Fulton', 'Webb', 'Sanchez', 'Strickland', 'Clark', 'Middleton', 'Moody', 'Owens', 'Graham', 'Cotton', 'Shaffer', 'Hawkins',
            'Cooper', 'Justice', 'Clarke', 'Mcconnell', 'Mccarthy', 'Macdonald', 'Castillo', 'Gilbert', 'Horton', 'Finley', 'Beard', 'Sanders', 'Levy', 'Richard', 'Bowen', 'Grant', 'Wilkins', 'Ramsey', 'Lynch', 'Koch', 'Mercado', 'Roach', 'Bond', 'Lane', 'Tanner', 'Byers', 'Humphrey', 'Austin', 'Carney', 'Golden', 'Pope', 'Kramer', 'Ellison', 'Jefferson', 'Duffy', 'Gross', 'Mcmahon', 'Hudson', 'Mckee', 'Atkinson', 'Bush', 'Thompson', 'Faulkner', 'Christian', 'Ingram', 'Cannon', 'Gay', 'Nieves', 'Hodges', 'Langley', 'Watson', 'Woods', 'Gallagher', 'Delacruz', 'Stafford', 'Knight', 'Kerr', 'Chapman', 'Roman', 'Christensen', 'Robles', 'Mathews', 'Waller', 'Buckley', 'Myers', 'Powers', 'Lindsay', 'Gates', 'Miller', 'Johns', 'Morin', 'Fleming', 'Bishop', 'Clements']
        first_names = [
            'Sarah', 'Ian', 'Upton', 'Uriah', 'Hayden', 'Zia', 'Lila', 'Benjamin', 'Addison', 'Vivian', 'Kirby', 'Oscar', 'Demetrius', 'Hashim', 'Michelle', 'Odessa', 'Phillip', 'Michael', 'Dante', 'Omar', 'Dominic', 'Wing', 'Joshua', 'Charlotte', 'Thomas', 'Aquila', 'Rana', 'Jolene', 'Felix', 'Cailin', 'Tatiana', 'Oprah', 'Belle', 'Sydnee', 'Kuame', 'Fleur', 'Matthew', 'Sylvia', 'Mary', 'Deborah', 'Ross', 'Hyacinth', 'Jacqueline', 'Jessica', 'Callie', 'Ariana', 'Leo', 'Desiree', 'Lunea', 'Chava', 'Jorden', 'Rudyard', 'Cally', 'Knox', 'Arthur', 'Dana', 'Rebekah', 'Yen', 'Hadassah', 'Duncan', 'Ginger', 'Valentine', 'Ivana', 'Iona', 'Jemima', 'Dorothy', 'Joan', 'Timothy', 'Amity', 'Uriel', 'Skyler', 'Phelan', 'Alma', 'Hadley',
            'Quemby', 'Sonya', 'Axel', 'Slade', 'Riley', 'Rajah', 'Giselle', 'Selma', 'Nadine', 'Pascale', 'Carol', 'Steel', 'Lane', 'Emi', 'Trevor', 'Wyatt', 'Claire', 'Harlan', 'Liberty', 'Alexandra', 'Avram', 'Barbara', 'Rashad', 'Holmes', 'Kenneth', 'Preston', 'Patience', 'Adele', 'Alfonso', 'Harrison', 'Julian', 'Jena', 'Peter', 'Kessie', 'Katell', 'Denton', 'Piper', 'Jerry', 'Teegan', 'Chandler', 'Walter', 'Cheryl', 'Desirae', 'Tasha', 'Hunter', 'Logan', 'Tatyana', 'Gail', 'Galvin', 'Dara', 'Athena', 'Kay', 'Dustin', 'Faith', 'Mariam', 'Leroy', 'Edan', 'Alexis', 'Nissim', 'Octavia', 'Kareem', 'Heidi', 'Aspen', 'Gregory', 'Garrison', 'Jolie', 'Gloria', 'Alec', 'Asher', 'Julie', 'Ayanna', 'Gavin', 'Germane', 'Bertha', 'Quinn', 'Tarik']

        office_location = OfficeLocation.objects.get(pk='DC123')

        for x in xrange(int(args[0])):
            while True:
                first_name = first_names[int(random.random() *
                                             len(first_names))]
                last_name = last_names[int(random.random() * len(last_names))]
                username = last_name + first_name[0]
                email = username + '@exmaple.com'
                if not get_user_model().objects.filter(username=email).exists():
                    break

            user_attr = {
                'first_name': first_name,
                'last_name': last_name,
                'is_active': True,
                'is_superuser': False,
                'date_joined': '2012-03-01T16:03:14Z',
                'password': 'pbkdf2_sha256$10000$ggAKkiHobFL8$xQzwPeHNX1vWr9uNmZ/gKbd17uLGZVM8QNcgmaIEAUs=',
                'is_staff': True,
                'email': email,
                'username': email
            }

            userModel = get_user_model()
            user = userModel(**user_attr)
            user.save()

            person_attr = {
                'office_location': office_location,
                'allow_tagging': True,
                'photo_file': 'avatars/default.jpg',
                'stub': username.replace('.', ''),
                'office_phone': '5555555555',
                'user': user,
                'email_notifications': False,
                'org_group': OrgGroup.objects.order_by('?')[0]
            }

            person = Person(**person_attr)
            person.save()

        self.stdout.write(
            'Successfully created %d users and persons' % int(args[0]))
开发者ID:Gointer,项目名称:collab,代码行数:52,代码来源:create_users.py

示例8: test_create_tags_for_person

    def test_create_tags_for_person(self):
        user = UserF(username="[email protected]")
        person = Person(user=user)
        person.save()

        tag_category = TagCategory(name='Test Category',
                                   slug='staff-directory-test-category')
        tag_category.save()

        tagged_item = add_tags(person, 'TagA',
                                'staff-directory-test-category', user, 'person')

        self.assertEqual(1, person.tags.count())
开发者ID:cfpb,项目名称:collab-staff-directory,代码行数:13,代码来源:test_unit.py

示例9: add_person

def add_person(request):

    """
    >>> from django.test import Client
    >>> from django.core.urlresolver import reverse
    >>> client = Client()

    >>> response = client.get('add_person')
    >>> response.status_code
    200

    >>> client.post('/add_person/', {'name': 'fred')
    200
    """

    items = Person.objects.all()

    if request.method == 'POST':  # If the form has been submitted...
        form = PersonForm(request.POST)  # A  form bound to the POST data
        if form.is_valid():  # All validation rules pass
            newPerson = Person(
                        name=form.cleaned_data['name'],
                        bio=form.cleaned_data['bio'],
                        contacts=form.cleaned_data['contacts'],
                        surname=form.cleaned_data['surname'],
                        birth_date=form.cleaned_data['birth_date']
                        )
            newPerson.save()

        if request.is_ajax():
            rdict = {'bad': 'false'}
            if not form.is_valid():
                rdict.update({'bad': 'true'})
                d = {}
                for e in form.errors.iteritems():
                    d.update({e[0]: unicode(e[1])})
                rdict.update({'errs': d})
            json = simplejson.dumps(rdict, ensure_ascii=False)
            return HttpResponse(json, mimetype='application/javascript')
        else:
            return HttpResponseRedirect('/')  # Redirect after POST

    else:
        form = PersonForm()  # An unbound form

    return render_to_response('add_person.html', {
        'form': form,
        'items': items,
    },
     context_instance=RequestContext(request),
    )
开发者ID:yrik,项目名称:42cc,代码行数:51,代码来源:views.py

示例10: setUp

    def setUp(self):
        self.meta, unused = BadgesEventMeta.get_or_create_dummy()
        LabourEventMeta.get_or_create_dummy()
        ProgrammeEventMeta.get_or_create_dummy()

        self.event = self.meta.event
        self.person, unused = Person.get_or_create_dummy()
开发者ID:Hilzu,项目名称:kompassi,代码行数:7,代码来源:tests.py

示例11: test_single_tag_single_user

    def test_single_tag_single_user(self):
        user = UserF(username="[email protected]")
        person = Person(user=user)
        person.save()

        tag_category = TagCategory(name='Test Category',
                                   slug='staff-directory-test-category')
        tag_category.save()

        tags = []
        tagged_item = add_tags(person, 'TagA',
                                'staff-directory-test-category', user, 'person')
        tags.append(tagged_item.tag.slug)

        emails = _get_emails_for_tag(tags)
        self.assertTrue(len(emails) == 1)
        self.assertIn(user.email, emails)
开发者ID:cfpb,项目名称:collab-staff-directory,代码行数:17,代码来源:test_unit.py

示例12: test_event_adminship

    def test_event_adminship(self):
        person, unused = Person.get_or_create_dummy(superuser=False)
        labour_event_meta, unused = LabourEventMeta.get_or_create_dummy()

        assert not labour_event_meta.is_user_admin(person.user)

        labour_event_meta.admin_group.user_set.add(person.user)

        assert labour_event_meta.is_user_admin(person.user)
开发者ID:Siikakala,项目名称:kompassi,代码行数:9,代码来源:tests.py

示例13: test_single_tag_user_profile

    def test_single_tag_user_profile(self):
        user = UserF(username="[email protected]")
        user.set_password("x")
        user.save()
        person = Person(user=user)
        person.stub = "jack"
        person.save()
        resp1 = self.client.login(username="[email protected]", password="x")
        self.assertTrue(resp1)

        tag_category = TagCategory(name='Test Category',
                                   slug='staff-directory-test-category')
        tag_category.save()

        resp2 = self.client.post('/staff/add-person-to-tag/%s/hello!/' %
                                (person.stub), {'person_stub': person.stub,
                                                'tag_category': 'staff-directory-test-category'})

        self.assertContains(resp2, "redirect", status_code=200)
开发者ID:cfpb,项目名称:collab-staff-directory,代码行数:19,代码来源:test_unit.py

示例14: get_or_create_dummy

    def get_or_create_dummy(cls):
        from .email_alias_type import EmailAliasType
        from core.models import Person
        alias_type, unused = EmailAliasType.get_or_create_dummy()
        person, unused = Person.get_or_create_dummy()

        return cls.objects.get_or_create(
            type=alias_type,
            person=person,
        )
开发者ID:Siikakala,项目名称:kompassi,代码行数:10,代码来源:email_alias.py

示例15: get_or_create_dummy

    def get_or_create_dummy(cls):
        from core.models import Person, Event

        person, unused = Person.get_or_create_dummy()
        event, unused = Event.get_or_create_dummy()

        signup, created = Signup.objects.get_or_create(person=person, event=event)
        extra = signup.signup_extra
        extra.save()

        return signup, created
开发者ID:wyrmiyu,项目名称:kompassi,代码行数:11,代码来源:models.py


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