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


Python Person.name方法代码示例

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


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

示例1: populate_person

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def populate_person(root) :
	"""
	Finds instances of Person in root's tree and saves them to the database

	@type root:  Element
	@param root: root of the ElementTree passed in to populate_models()
	@rtype:      N/A
	@return:     function does not return
	"""
	for person in root.findall("Person"):
		temp_person             =                     Person()
		temp_person.person_ID   =             person.get("ID")
		temp_person.name        =           person.get("Name")

		if person.find("Kind") is not None :
			temp_person.kind        =     person.find("Kind").text
		if person.find("Location") is not None :
			temp_person.location    = person.find("Location").text

		for crisis in person.iter("Crisis") :
			temp_relations = Relations()
			check = Relations.objects.filter(crisis_ID = crisis.get("ID"), person_ID = person.get("ID"))
			if len(check) == 0:
				temp_relations.populate(c_id = crisis.get("ID"), p_id = person.get("ID"))
				temp_relations.save()

		for org in person.iter("Org") :
			temp_relations = Relations()
			check = Relations.objects.filter(org_ID = org.get("ID"), person_ID = person.get("ID"))
			if len(check) == 0:
				temp_relations.populate(p_id = person.get("ID"), o_id = org.get("ID"))
				temp_relations.save()

		populate_common(person, person.get("ID"), temp_person)
		temp_person.save()
开发者ID:bblee1002,项目名称:cs373-wcdb,代码行数:37,代码来源:loadModels.py

示例2: register

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            person = Person()
            person.name = form.cleaned_data['name']
            person.email = form.cleaned_data['email']
            person.save()
            return HttpResponseRedirect('../list/')
    else:
        form = RegistrationForm()

    return render(request, '../templates/register.html', {'form': form})
开发者ID:armandobatina,项目名称:Python,代码行数:15,代码来源:views.py

示例3: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
 def post(self, user_id):
     auth_key = request.args.get('key')
     user = User.authenticate(user_id, auth_key)
     if user:
         supposed_person = request.get_json(force=True)
         person = Person()
         person.user_id = user_id
         person.name = supposed_person['name']
         db.session.add(person)
         db.session.commit()
         if person.person_id:
             return json.jsonify(person.as_dict())
     return json.jsonify({})
开发者ID:felipemfp,项目名称:minhaeiroAPI,代码行数:15,代码来源:apis.py

示例4: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
 def post(self, username):
     user = self.authenticate()
     if user:
         supposed_person = request.get_json(force=True)
         person = Person()
         person.person_id = 1 if len(
             user.people.all()) == 0 else user.people.all()[-1].person_id + 1
         person.user_id = user.user_id
         person.name = supposed_person['name']
         db.session.add(person)
         db.session.commit()
         if person.person_id:
             return json.jsonify(person.as_dict())
     raise InvalidUsage()
开发者ID:felipemfp,项目名称:catherine,代码行数:16,代码来源:apis.py

示例5: go

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def go(request):
	
	tabselected = None
	filtertag = request.META['PATH_INFO']
	if filtertag.find('/idea/') >= 0:
		filtertag = filtertag[6:]
		tabselected = filtertag.replace('/', '')
#		tabselected = 4
	else:
		filtertag = None
		
 	user = request.user
 	
 	rating = None
 	if user.is_authenticated():
		
		person = views.getPerson(request)
	 	if person:
	 		pratings = Rating.objects().order_by('score')
	 		if pratings and len(pratings)>=0:
	 			for prating in pratings:
	 				if person.currentRating >= prating.score:
	 					rating = prating
	 				else:
						break
	 	else:
			person = Person()
			person.email = user.email
			person.name = str(user)
			person.activationdate = datetime.datetime.now()
			person.save()
			views.incrementStat('users',1)
	 		pratings = Rating.objects().order_by('score')
	 		if pratings and len(pratings)>=0:
	 			for prating in pratings:
	 				if person.currentRating >= prating.score:
	 					rating = prating
					else:
						break
 		
 	
	template_values = {
 		'user':user,
 		'tabselected':tabselected,
 		'filtertag':None,
 		'rating':rating,
	}
	path = os.path.join(os.path.dirname(__file__), 'templates/ideas/index.html')
	return render_to_response(path, template_values)
开发者ID:jamesmwhite,项目名称:innuvate,代码行数:51,代码来源:idea_main.py

示例6: add_person

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def add_person(ctx, name, surname, patronymic, date_of_birth, institution_id):
    if name and surname and patronymic and date_of_birth and institution_id:
        try:
            institution = Institution.objects.get(pk=institution_id)
        except Institution.DoesNotExist:
            pass
        else:
            person = Person()
            person.name = name
            person.surname = surname
            person.patronymic = patronymic
            person.date_of_birth = date_of_birth
            person.institution_id = institution_id
            person.save()
            return True
    return False
开发者ID:ermakovoleg,项目名称:m3-blank,代码行数:18,代码来源:service.py

示例7: new_person

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def new_person():
    if not g.site.domain == g.user:
        abort(403)

    p = Person()
    if request.method == "POST":
        reqfile = request.files.get('file')
        if reqfile:
            f = File()
            f.site = g.site.domain
            f.name = reqfile.filename
            f.content_type = reqfile.mimetype
            f.slug, f.content_length = save_file(reqfile, current_app.config["UPLOAD_FOLDER"])
            f.save()

        p.site = g.site.domain
        p.name = request.form.get("name")
        p.title = request.form.get("title")
        p.phone = request.form.get("phone")
        p.email = request.form.get("email")
        p.twitter = request.form.get("twitter")
        p.description = request.form.get("description")
        slugs = [ __p.slug for __p in Person.objects.filter(site=g.site.domain) ]
        slug = slugify(p.name)
        counter = 1
        __slug = slug
        while __slug in slugs:
            counter += 1
            __slug = "%s_%d" % (slug, counter)
        p.slug = __slug

        if reqfile:
            p.image_slug = f.slug
        p.save()

        pl = Personnel.objects.get(site=g.site.domain)
        pl.people.append(p.slug)
        pl.save()

        return redirect(url_for(".show_personnel"))
    return render_template("edit_person.html", person=p)
开发者ID:abal09,项目名称:samklang,代码行数:43,代码来源:personnel.py

示例8: load_persons

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def load_persons():
    persons = []
    managers = {}

    # TEAMS
    existing_teams = {}
    teams = Team.query.all()
    for team in teams:
        existing_teams[team.name] = team
    print(existing_teams)

    # ROOMS
    existing_rooms = {}
    rooms = Room.query.all()
    for room in rooms:
        existing_rooms[room.name] = room
    print(existing_rooms)

    # We try to use a custom persons file if it exists. If not, default file
    if (path.isfile(config.DATABASE_PERSONS_FILE)):
        persons_file = config.DATABASE_PERSONS_FILE
    else:
        persons_file = config.DATABASE_PERSONS_DEFAULT_FILE

    with io.open(persons_file, 'r', encoding='utf8') as f:
        for line in f:
            if (len(line) > 1 and line[0] != '#'):
                neo = Person()

                split = line[:-1].split(';')
                neo.login = split[2].strip().lower()
                neo.surname = split[3]
                neo.name = split[4]
                neo.birthday = datetime.datetime.fromtimestamp(float(format_date(split[5])))
                neo.arrival = datetime.datetime.fromtimestamp(float(format_date(split[6])))
                neo.job = split[7]
                neo.email = split[8]
                neo.skype = split[9]
                neo.fixe = split[10]
                neo.mobile = split[11]

                team = split[1]
                manager = split[12]
                room = split[13]

                if manager in managers:
                    managers[manager].append(neo)
                else:
                    managers[manager] = [neo]

                if (team in existing_teams):
                    neo.team = existing_teams[team]

                if (room in existing_rooms):
                    neo.room = existing_rooms[room]

                else:
                    print('Error: Missing team ' + team + ' for ' + neo.login)
                persons.append(neo)

    for person in persons:
        # We link the managers
        if person.login in managers:
            person.subordinates = managers[person.login]
        db.session.add(person)
    db.session.commit()
开发者ID:Mogmi95,项目名称:Trombi,代码行数:68,代码来源:main.py

示例9: importperson

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import name [as 别名]
def importperson(request):
    '''
    普通用户导入自己的数据
    管理员导入任意人的数据
    '''
    personinfo_name = ['name',  'sex', 'age','adno','home' 'profession', 'education', 'disease_history', 'disease_age_h',
                       'disease_current','disease_age_c', 'used_drugs', 'using_drugs']
    questioninfo_name=['q1','q2','q3','q4','a','b','c','d','e','f','g','h','i','j','q6','q7','q8','q9','time_submit']
    if request.method == "GET":
        return render_to_response('importperson.html', locals())
    fi = request.FILES['personcsv']
    questions = []
    fi.readline()
    for line in fi.readlines():
        try:
            line=line.decode('utf8')
        except:
            try:
                line=line.decode('gbk')
            except:
                pass
        spli=',' if line.count(',')>line.count('\t') else '\t'
        attrs = line.replace('\n', '').replace('\r', '').split(spli)
        if request.user.is_superuser:
            try:
                person = Person.objects.get(username=attrs[0])
            except Person.DoesNotExist:
                person=Person(username=attrs[0])
            person.name,person.sex,person.age,person.adno,person.home,person.profession,person.education,person.disease_history,\
            person.disease_age_h,person.disease_current,person.disease_age_c,person.used_drugs,person.using_drugs=attrs[1:14]
            person.save()
            question_list=attrs[14:-1]
        else:
            person=Person.objects.get(username=request.user.username)
            question_list=attrs[:-1]
        question_dict=dict(zip(questioninfo_name,map(int,question_list)))
        question=Question(person=person,**question_dict)
        question.time_submit=datetime.datetime.strptime(attrs[-1],'%Y%m%d')
        element_A = question.q6
        if question.q2 <= 15:
            element_B = question.a
        elif question.q2 <= 30:
            element_B = 1 + question.a
        elif question.q2 < 60:
            element_B = 2 + question.a
        elif question.q2 > 60:
            element_B = 3 + question.a
        if question.q4 > 7:
            element_C = 0
        elif question.q4 > 6:
            element_C = 1
        elif question.q4 >= 5:
            element_C = 2
        elif question.q4 < 5:
            element_C = 3
        if question.q3 > question.q1:
            Sleep_efficiency = 1.0 * question.q4 / (24 - question.q3 + question.q1)
        else:
            Sleep_efficiency = 1.0 * question.q4 / (question.q1 - question.q3)
        if Sleep_efficiency > 0.85:
            element_D = 0
        elif Sleep_efficiency > 0.75:
            element_D = 1
        elif Sleep_efficiency >= 0.65:
            element_D = 2
        elif Sleep_efficiency < 0.65:
            element_D = 3
        Sleep_disorder = question.b + question.c + question.d + question.e + question.f + question.g + question.h + question.i + question.j
        if Sleep_disorder == 0:
            element_E = 0
        elif Sleep_disorder <= 9:
            element_E = 1
        elif Sleep_disorder <= 18:
            element_E = 2
        elif Sleep_disorder <= 27:
            element_E = 3
        element_F = question.q7
        Daytime_dysfunction = question.q8 + question.q9
        if Daytime_dysfunction == 0:
            element_G = 0
        elif Daytime_dysfunction <= 2:
            element_G = 1
        elif Daytime_dysfunction <= 4:
            element_G = 2
        elif Daytime_dysfunction <= 6:
            element_G = 3
        question.score = element_A + element_B + element_C + element_D + element_E + element_F + element_G
        question.save()
        questions.append(question)
    return render_to_response('importperson.html', locals())
开发者ID:lomoalbert,项目名称:SDE,代码行数:92,代码来源:views.py


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