• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Person类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

 def get(self):
     person = Person(first_name='Pedro',
                     last_name='Perez',
                     email='[email protected]',
                     birth_date=date(1983, 2, 21))
     person.put()
     self.response.write('Inserted Person!')
开发者ID:Eforcers,项目名称:google-dev-courses,代码行数:7,代码来源:views.py


示例2: register

def register(request):
    if request.method == 'GET':
        return httputils.render_html(request,'gobang/register.html', {})
    else:
        email = request.POST.get('email', default = None)
        passwd = request.POST.get('passwd', default = None)
        username = request.POST.get('username', default = None)
        validation_code = request.POST.get('validation_code', default = None)
        #check input not none
        for item in (email, passwd,username,validation_code):
            if item is None:
                return render(request, 'gobang/register.html',{'error_msg':'input has none'})
        #check validation code right
        server_validation_code = validation_cache.get(email)
        if server_validation_code is None or server_validation_code != validation_code:
            return render(request, 'gobang/register.html',{'error_msg':'validation code not right'})

        #insert db and use model to check input format right
        added_person = Person(username=username,passwd=passwd,email=email)
        try:
            added_person.save()
        except Exception as e:
            #record exception
            gobang_logger.error("insert db error, {0}".format(e))
            return render(request, 'gobang/register.html',{'error_msg':str(e)})

        #set sessions and redirect
        request.session['login'] = True
        request.session['pk'] = added_person.pk
        request.session['username'] = added_person.username
        return HttpResponseRedirect('/gobang/index')
开发者ID:slgu,项目名称:online_gobang,代码行数:31,代码来源:views.py


示例3: post

 def post(self):
     email = self.request.get("email")
     name = self.request.get("name")
     person = Person.get_by_key_name(name)
     if not person:
         person = Person(key_name=email, email=email, name=name)
         person.put()
开发者ID:bogo,项目名称:purser,代码行数:7,代码来源:person_controller.py


示例4: post

 def post(self):
     continue_uri = self.request.get('continue')
     person = Person()
     person.first_name = self.request.get('first_name')
     person.last_name = self.request.get('last_name')
     person.put()
     self.redirect(continue_uri)
开发者ID:yesudeep,项目名称:tiss-secure,代码行数:7,代码来源:handlers.py


示例5: merge_people

def merge_people(elem):
	"""
	Parses data from "<Person />" tags
	Checks if  entry already exists
	If so, do a merge 
	else, import the model data
	Saves model to mysql database
	"""
	for p in elem :
		person_filter_obj = Person.objects.filter(wcdb_id = p.get('ID'))
		if (len(person_filter_obj) != 0):
			person = person_filter_obj[0]	#if person exists, use it
			person.name = p.get('Name')
		else:					#else make a new one
			person = Person(name = p.get('Name'), wcdb_id = p.get('ID'))
		kind = p.find('Kind')
		location = p.find('Location')
		common = p.find('Common')
		if (kind != None): 
			person.kind = kind.text
		if (location != None):
			person.location = location.text
		if (common != None):
			merge_common(common, person)
		person.save()
开发者ID:luis-3000,项目名称:WorldwideCrisesWebsite,代码行数:25,代码来源:mergeXML.py


示例6: setUp

 def setUp(self):
     self.dad = Person(full_name='John Smith Senior', mother=None, father=None)
     self.dad.save()
     self.mom = Person(full_name='Jane Smith', mother=None, father=None)
     self.mom.save()
     self.kid = Person(full_name='John Smith Junior', mother=self.mom, father=self.dad)
     self.kid.save()
开发者ID:ssaltzman,项目名称:POET,代码行数:7,代码来源:tests.py


示例7: create_new_user

    def create_new_user(self, rawname, role, email=""):
        """ Creates a new Person record with a unique username, or returns a person wiht the matching username"""

        ut = Utils()
        username = ut.cleanUserName(rawname)

        if ut.validateUserName(username):

            # check for username
            person = self.get_person(username)

            # create a new person if we have not got this one
            if person == None:
                person = Person()
                person.email = email
                person.passhash = ""
                # no passhash if not got a direct logon
                person.username = username
                person.displayname = ut.tidyUserName(
                    rawname
                )  # allow the username to be updated on the myHoots or profile or summink
                person.before_put()
                person.role = role
                person.put()

            self._person = person

            return username
        else:
            return ""
开发者ID:Carhoots,项目名称:blog,代码行数:30,代码来源:user.py


示例8: get

  def get(self):
    # 編集確認
    person_id = self.request.get("id")
    person_obj = ''
    if (person_id):
      person_obj = Person.get( person_id )

    # 所有しない発言者IDを指定された場合は一覧へリダイレクトする
    if person_obj and person_obj.owner != users.get_current_user():
      self.redirect(urls.APP_PERSON_URL)
      return

    # 所有する発言者を取得します
    query = Person.all()
    query.filter( 'owner = ', users.get_current_user() )
    query.order('-created_on')
    owned_persons = query.fetch(limit = 1000)

    # 所有する発言者の名言を取得する
    meigens = ''
    if person_obj:
      query = Meigen.all()
      query.filter( 'owner = ', users.get_current_user() )
      query.filter( 'person = ', person_obj )
      meigens = query.fetch(limit = 1000)

    # 画面を表示する
    Viewer.generate(Viewer(), self.response, TEMPLATE_PATH, { 'persons': owned_persons, 'current_person': person_obj, 'meigens': meigens } )
开发者ID:sadao,项目名称:meigen-pedia,代码行数:28,代码来源:person.py


示例9: doperson

def doperson(request,username,method):
    person=Person.objects.get(username=username)
    if request.user.is_superuser:
        if request.method=="GET":
            result=1
        elif request.method=="POST":
            result=2
            if method=='delete':#删除确认
                person.delete()
            elif method=='update':#更新表单
                #update
                personinfo_name = ['name', 'sex', 'age', 'adno','home','profession', 'education', 'disease_history', 'disease_age_h',
                       'disease_current','disease_age_c', 'used_drugs', 'using_drugs']
                try:
                    person = Person.objects.get(username=username)
                except Person.DoesNotExist:
                    person = Person(username=username)
                for key in personinfo_name:
                    setattr(person,key,request.POST.get(key,''))
                person.save()
        else:#显示查看界面
            result=0
    else:#无权操作
        result=-1
    return render_to_response('person.html', locals())
开发者ID:lomoalbert,项目名称:SDE,代码行数:25,代码来源:views.py


示例10: person

  def person(self):
    cookie, is_new_cookie = self.get_cookie()
    if is_new_cookie:
      person = Person.create(cookie)
    else:
      person = Person.get_by_cookie(cookie)

    return person
开发者ID:crizCraig,项目名称:Wifi-chat,代码行数:8,代码来源:base_handler.py


示例11: create_player

def create_player(first, last):

    person = Person(first_name=first, last_name=last)
    person.save()
    player = Player(person=person)
    player.save()

    return player
开发者ID:tammolaube,项目名称:soccer-island,代码行数:8,代码来源:test_models.py


示例12: test_setter

    def test_setter(self):
        # The "full_name" property hasn't provided a "set" method.
        self.assertRaises(AttributeError, setattr, self.a, 'full_name', 'Paul McCartney')

        # But "full_name_2" has, and it can be used to initialise the class.
        a2 = Person(full_name_2 = 'Paul McCartney')
        a2.save()
        self.assertEqual(a2.first_name, 'Paul')
开发者ID:ssaltzman,项目名称:POET,代码行数:8,代码来源:tests.py


示例13: setUp

 def setUp(self):
     Redis().flushall()
     p1 = Person(name='Test User 1', ssn='123456789')
     p1.save()
     pn1 = PhoneNumber(person=p1, label='Test 1', phone_number='5558675309')
     pn1.save()
     from django import db
     db.reset_queries()
开发者ID:bumyong,项目名称:django-hotstorage,代码行数:8,代码来源:tests.py


示例14: save

    def save(self):
        password = self.cleaned_data.pop('password1')
        self.cleaned_data.pop('password2')

        person = Person(**self.cleaned_data)
        person.set_password(password)
        person.save()
        return person
开发者ID:rosedu-hacks,项目名称:books,代码行数:8,代码来源:forms.py


示例15: createUser

    def createUser(self, user_info, user, uri):
        # Verifying authenticity of signup request
        if user:
            print "Printing User Info Object"
            print user_info
            requested_role = user_info["role"]
            if users.is_current_user_admin():
                requestee_role = 'admin'
            else:
                requestee_role = self.getCurrentUserRole(user)[0]
            
            print requestee_role
            print requested_role
            
            if requestee_role == 'superintendent' and requested_role not in ['principal','teacher','student']:
                return {
                    'error': 'User does not have permissions to create that role'
                }
            elif requestee_role == 'principal' and requested_role not in ['teacher', 'student']:
                return {
                    'error': 'User does not have permissions to create that role'
                }
            elif requestee_role == 'teacher' and requested_role  not in ['student']:
                return {
                    'error': 'User does not have permissions to create that role'
                }
            elif requestee_role == False:
                return {
                    'error': 'User does not have permissions to create that role'
                }
            else:
                # Check to see if user already exists
                try:    
                    email = user_info.email
                    query = Person.query(Person.email == email)
                    person = query.fetch(1)
                    person = person[0]
                    print person
                    if person:
                        print "User already exists..."
                        return {
                            'error': 'User already exists'
                        }

                except:
                    print "Creating User..."
                    guid = str(uuid4())
                    f_name = user_info["f_name"]
                    l_name = user_info["l_name"]
                    
                    person = Person(f_name=f_name, l_name=l_name, email=user_info["email"], role=[user_info["role"]], guid=guid)
                    person.put()
                    # self.sendEmail(f_name, l_name, user_info["email"], guid, uri)
                    return person
        else:
            return {
                'error': 'No user logged in'
            }
开发者ID:Bale96,项目名称:educationalGames,代码行数:58,代码来源:SignUpController.py


示例16: setUp

 def setUp(self):
     self.person1 = Person(name = "Person1")
     self.person2 = Person(name = "Person2")
     self.person3 = Person(name = "Person3")
     self.person4 = Person(name = "Person4")
     self.person1.save()
     self.person2.save()
     self.person3.save()
     self.person4.save()
开发者ID:kkraft,项目名称:twupairstairs,代码行数:9,代码来源:tests.py


示例17: get_image_info

    def get_image_info(self, uid, name):
        post_data = {'api_key': self.api_key(),
                     'api_secret': self.api_secret(),
                     'img_uid': uid}

        r = requests.post(self.base_url() + 'GetImageInfo', post_data)
        json_obj = json.loads(r.content)
        p = Person(uid=json_obj['faces'][0]['uid'], name=name)
        p.save()
        return r
开发者ID:tylerthomp,项目名称:SE329_Project_1,代码行数:10,代码来源:BetaFaceApiWrapper.py


示例18: magic

def magic(request):
    p1 = Person(login = "picrin", hashedPassword = "similar")
    p1.save()
    k1 = Tokena(value = "please come in", active = True, belongs_to = p1, created=datetime.datetime.utcnow())
    k1.save()
    k2 = Tokena(value = "you're not welcome", active = False, belongs_to = p1, created=datetime.datetime.utcnow())
    k2.save()
    print k1
    print k2
    return HttpResponse("nice", RequestContext(request))
开发者ID:GlasgowSoftwareCooperative,项目名称:2048Legends,代码行数:10,代码来源:queries.py


示例19: familytree_primitives_data

def familytree_primitives_data():
    filter_surnames = set(x for x in request.values.get('surname', '').lower().split(',') if x)

    # only show given individual
    single_person = request.values.get('single_person')
    if single_person:
        people = [Person.get(single_person)]
    else:
        people = sorted(Person.find(), key=lambda p: p.group_name)

    relatives_of = request.values.get('relatives_of')
    if relatives_of:
        central_person = Person.get(relatives_of)
        people = central_person.related_people

    # only find ancestors of given person
    ancestors, descendants = None, None
    ancestors_of = request.values.get('ancestors_of')
    if ancestors_of:
        central_person = Person.get(ancestors_of)
        ancestors = central_person.find_ancestors()

    descendants_of = request.values.get('descendants_of')
    if descendants_of:
        central_person = Person.get(descendants_of)
        descendants = central_person.find_descendants()

    if ancestors_of or descendants_of:
        people = set(list(ancestors or [])) | set(list(descendants or []))

    def _prepare_item(person):
        names_lowercase = (n.lower() for n in person.group_names)
        if filter_surnames:
            intersects = filter_surnames & set(names_lowercase)
            if not intersects:
                return

        # ethical reasons
        if person.death.year:
            tmpl = '{born} — {dead}'
        else:
            tmpl = '{born}'
        description = tmpl.format(born=person.birth.year_formatted or '?',
                                  dead=person.death.year_formatted or '?')
        return {
            'id': person.id,
            'title': person.name,
            'parents': [p.id for p in person.get_parents()],
            'spouses': [p.id for p in person.get_partners()],
            'description': description,
            'gender': person.gender,
        }
    prepared = (_prepare_item(p) for p in people)
    filtered = (p for p in prepared if p)
    return json.dumps(list(filtered))
开发者ID:daleathan,项目名称:wtfamily,代码行数:55,代码来源:web.py


示例20: addperson

def addperson():
    meeting = get_meeting()
    names = [x.name for x in meeting.people]
    if request.method == 'POST':
        name = request.form['username']
        if name not in names:
            person = Person(name=name)
            person.save()
            meeting.people.append(person)
            meeting.save()
        return redirect('/status/%s' % name)
开发者ID:uwekamper,项目名称:mbm3000,代码行数:11,代码来源:backend.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Photo类代码示例发布时间:2022-05-27
下一篇:
Python models.Pages类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap