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


Python models.Person类代码示例

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


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


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