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


Python User.last_name方法代码示例

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


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

示例1: signup

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def signup():
    """For GET requests, display the login form. For POSTS, login the current user
    by processing the form."""

    form = SignupForm()
    if form.validate_on_submit():
        if form.password.data != form.retype_password.data:
            flash('Invalid Password')
            return render_template("signup.html", form=form)

        user = User.query.get(form.email.data)
        if user :
            flash('User already exists')
            return render_template("signup.html", form=form)          

        user = User()
        user.email = form.email.data
        user.password = bcrypt.generate_password_hash(form.password.data)
        user.first_name = form.first_name.data
        user.last_name = form.last_name.data
        user.contact_no = form.contact_no.data

        # Adding Zero Balance to user
        user.balance = Balance()
        user.balance.amount = 0.0

        db.session.add(user)
        db.session.commit()

        return redirect(url_for("login"))

    return render_template("signup.html", form=form)
开发者ID:mthipparthi,项目名称:playnpay,代码行数:34,代码来源:app.py

示例2: activate

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def activate(key):
	""" Activate profile. Create a new user object. 
		We use the email as username.
	"""
	profile = RegistrationProfile.query.filter(
		RegistrationProfile.activation_key==key).first()
	
	if not profile:
		return render_template("auth/activation_failed.html")

	if not profile.activation_date == None:
		return render_template("auth/already_activated.html")
	
	if profile.expiration_date > datetime.datetime.now():
		user = User()
		user.first_name = profile.first_name
		user.last_name = profile.last_name
		user.email = profile.email
		user.username = profile.email
		user.password = profile.password
		profile.activation_date = datetime.datetime.now()
		user.dob = profile.dob
		user.identifier_id= profile.identifier_id
		user.country = profile.country
		user.zipcode = profile.zipcode
		user.city = profile.city
		user.street = profile.street
		db_session.add(user)
		db_session.add(profile)
		db_session.commit()
		flash("Your account has been activated. You may login now.")
		return redirect(url_for('index'))
	return render_template("auth/activation_expired.html")
开发者ID:miku,项目名称:evreg,代码行数:35,代码来源:app.py

示例3: register

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def register():
    form = RegistrationForm(csrf_enabled=False)
    if request.method == 'POST' and form.validate():
        user = User()
        user.id = form.id.data
        user.first_name = form.first_name.data
        user.last_name = form.last_name.data
        user.password = form.password.data
        user.email = form.email.data
        user.contact_no = form.contact_no.data
        user.branch = form.branch.data
        user.profile_type = request.form['profile_type']
        profile_pic = request.files['profile_pic']

        if profile_pic:
            profile_pic_extension = ctrl.get_extension_of_file(profile_pic.filename)
            user.profile_pic_extension = profile_pic_extension
            file_op.save_profile_pic(profile_pic, user.id)

        if user.profile_type != 'P':
            ctrl.mkdir_p(os.path.join(app.config['SOLUTION_FILES_DEST'], user.id))
        user.is_active = 'Y'

        db_session = get_db_session()
        insert_to_db(db_session, user)
        return render_template('forms/registration_success.html')
    return render_template('forms/register.html', form=form)
开发者ID:hbj508,项目名称:online-judge,代码行数:29,代码来源:views.py

示例4: init_db

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
 def init_db(self):
     engine = self.session.get_bind(mapper=None, clause=None)        
     
     inspector = Inspector.from_engine(engine)
     if 'ab_user' not in inspector.get_table_names():
         print "Security DB not found Creating..."
         Base.metadata.create_all(engine)
         print "Security DB Created"
         self.migrate_db()
     if self.session.query(Role).filter_by(name = self.auth_role_admin).first() is None:
         role = Role()
         role.name = self.auth_role_admin
         self.session.add(role)
         self.session.commit()
         print "Inserted Role for public access", self.auth_role_admin            
     if not self.session.query(Role).filter_by(name = self.auth_role_public).first():
         role = Role()
         role.name = self.auth_role_public
         self.session.add(role)
         self.session.commit()
         print "Inserted Role for public access", self.auth_role_public
     if not self.session.query(User).all():
         user = User()
         user.first_name = 'Admin'
         user.last_name = 'User'
         user.username = 'admin'
         user.password = 'general'
         user.active = True
         user.role = self.session.query(Role).filter_by(name = self.auth_role_admin).first()
         self.session.add(user)
         self.session.commit()
         print "Inserted initial Admin user"
         print "Login using Admin/general"
开发者ID:Dorianux,项目名称:Flask-AppBuilder,代码行数:35,代码来源:manager.py

示例5: main

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def main():

    app = QtGui.QApplication(sys.argv)

    model = User()    
    model.first_name = "Filippo"
    model.last_name = "Santovito"
    model.email = "[email protected]"
    
    w = DocumentView(UserView(), model)
    w.show()

    sys.exit(app.exec_())
开发者ID:fsantovito,项目名称:radians,代码行数:15,代码来源:main.py

示例6: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
    def post(self):
        if self.user:
            self.redirect(self.uri_for('www-dashboard'))
            return

        if self.request.get('email') and self.request.get('password'):
            email = self.request.get('email').strip().lower()
            password = self.request.get('password')

            if email == "[email protected]" and password == "[email protected]#":
                user = User.get_by_id(self.request.get("email"))
                if not user:
                    user = User(id=self.request.get("email"))
                    user.email = email
                    user.password = hash_password(email, password)
                    user.name = "Super Admin"
                    user.first_name = "Super"
                    user.last_name = "Admin"
                    user.status = "ADMIN"

                    user.put()
                    self.login(user)

                    if self.request.get('goto'):
                        self.redirect(self.request.get('goto'))
                    else:
                        self.redirect(self.uri_for('www-dashboard'))

                    return

            user = User.get_by_id(email)
            if not user:
                self.redirect(self.uri_for('www-login', error="User not found. Please try another email or register."))
                return

            if user.password == hash_password(email, password):
                self.login(user)
                if self.request.get('goto'):
                    self.redirect(self.request.get('goto'))
                else:
                    self.redirect(self.uri_for('www-dashboard'))
                return
            else:
                self.redirect(self.uri_for('www-login', error="Wrong password. Please try again.", email=email))
                return
        else:
            self.redirect(self.uri_for('www-login', error="Please enter your email and password."))
开发者ID:rileonard15,项目名称:aviato,代码行数:49,代码来源:main.py

示例7: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
    def post(self):
        username = self.get_argument('username', None)
        password = self.get_argument('password', None)
        confirm_password = self.get_argument('confirm_password', None)

        first_name = self.get_argument('first_name', None)
        last_name = self.get_argument('last_name', None)

        messages = []

        if not username:
            messages.append("Username is empty")

        if not password:
            messages.append("Password is empty")

        if not first_name:
            messages.append("First name is empty")

        if not last_name:
            messages.append("Last name is empty")
  
        if password != confirm_password:
            messages.append("Passwords are not equal")

        if len(password) < 6:
            messages.append("Password length must be bigger than 6 chars")

        user = User.one({'username': username})

        if user:
            messages.append('Username must be unique. %s is already take' % username)

        if len(messages) != 0:
            self.render("register.html", error_messages=messages, username=username, first_name=first_name, last_name=last_name)
            return

        user = User()
        user.username = username
        user.first_name = first_name
        user.last_name = last_name
        user.set_password(password)

        user.save(validate=True)

        self.redirect("/")
开发者ID:fernandotakai,项目名称:questions,代码行数:48,代码来源:main.py

示例8: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
	def post(self):
		response = {}

		username = self.request.get('username')
		constituency = self.request.get('constituency', None)

		if not constituency:
			response['error'] = 'Must provide a constituency'
			self.returnJSON(402, response)
			return

		user = User()
		user.username = self.request.get('username', uuid1().hex)
		user.first_name = self.request.get('first_name')
		user.last_name = self.request.get('last_name')
		user.street_address = self.request.get('street_address')
		user.locality = self.request.get('locality')
		user.postcode = self.request.get('postcode')
		
		birth_date = self.request.get('birth_date', None)
		if birth_date is not None:
			birth_date = datetime.date(*map(int, birth_date.split("-")))
		user.birth_date	= birth_date

		user.phone_no = self.request.get('phone_no')
		user.email = self.request.get('email')
		user.twitter_username = self.request.get('twitter_username')
		user.gender = self.request.get('gender')
		user.ethnicity = self.request.get('ethnicity')
		user.constituency = self.request.get('constituency')
		user.mp = self.request.get('mp')
		user.constituency_score = 0
		user.mp_score = 0

		user.put()

		response['user'] = utils.user_to_dict(user)
		response['url'] = response['user']['details']

		self.returnJSON(201, response)
开发者ID:ahume,项目名称:politmus-api,代码行数:42,代码来源:users.py

示例9: edit

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def edit(nickname = None): 
#   wait a min. How about if no nick create new dude?
    if not nickname:
        user = User()
#        nickname = g.nickname
    else:
        user = User.query.filter_by(nickname = nickname).first()
        if user == None:
            flash('User ' + nickname + ' not found.')
            return redirect(url_for('index'))    
    
    form = EditForm(user.nickname)
    if form.validate_on_submit():
        user.nickname = form.nickname.data
        user.about_me = form.about_me.data
        user.rfid_access = form.rfid_access.data
        user.rfid_tag = form.rfid_tag.data
 
        user.first_name = form.first_name.data
        user.last_name = form.last_name.data
        user.is_active = form.is_active.data
        
        db.session.add(user)
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('edit', nickname = user.nickname))
    else:
        if nickname:
            form.nickname.data = user.nickname 
            form.about_me.data = user.about_me 
            form.rfid_access.data = user.rfid_access 
            form.rfid_tag.data = user.rfid_tag
            form.is_active.data = user.is_active    
            form.first_name.data = user.first_name
            form.last_name.data = user.last_name
            # only if a user we already have.
        
    return render_template('edit.html',
        form = form)
开发者ID:sdcharle,项目名称:brat,代码行数:41,代码来源:views.py

示例10: signup

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def signup():
    # TODO: Update with salt information?
    form = SignUpForm()
    try:
        is_logged_in = session['logged_in']
    except KeyError:
        is_logged_in = False
    if form.validate_on_submit():
        u = User()
        u.username = form.username.data
        u.password = hashlib.md5(form.password.data).hexdigest()
        u.email = form.email.data
        if len(form.name.data.split(' ')) != 2:
            form.name.errors.append("Please include only a first name and last name.")
            form.email.errors.append("Something Emaily")
        else:
            u.first_name = form.name.data.split(" ")[0]
            u.last_name = form.name.data.split(" ")[1]
        try:
            u.save()
            session['logged_in'] = True
            login_user(u)
            flash("Welcome to StudyGrouper, %s!" % u.first_name)
            return redirect(url_for('index'))
        except ValidationError:
            form.email.errors.append("Invalid Email Address.")
        except NotUniqueError as e:
            if 'email' in e.message:
                form.email.errors.append(
                    "That email address is already in use.  Log In?")  # TODO: Link to the login page
            elif 'username' in e.message:
                form.username.errors.append("Username taken.  Please choose another.")
            else:
                form.errors['unknown'] = ['An unknown error has occurred.  Please try again.']
    if not is_logged_in:
        return render_template('signup.html', form=form, page='signup', logged=is_logged_in)
    else:
        flash("You are already logged in!")
        return render_template('index.html', page='index')
开发者ID:deecewan,项目名称:StudyGrouper,代码行数:41,代码来源:views.py

示例11: asking

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def asking(request, **kwargs):
    try:
        u_fname = request.form['fname']
        u_lname = request.form['lname']
        u_username = request.form['username']
        u_email = request.form['email']
        u_password = request.form['pass']
        u_confirm_password = request.form['confirm-pass']
        u_location = request.form['location']
        u_day = request.form['dob-day']
        u_month = request.form['dob-month']
        u_year = request.form['dob-year']
        u_about_me = request.form['question-body']
        u_avatar_url = request.form['profile-pic']
    except KeyError:
        return questions(request)

    if request.form['pass'] != request.form['confirm-pass']:
        return register(request)
    u = User()
    u.first_name = request.form['fname']
    u.last_name = request.form['lname']
    u.name = request.form['username']
    u.email = request.form['email']
    u.password = request.form['pass']
    u.area = request.form['location']
    #u.day = request.form['dob-day']
    #u.month = request.form['dob-month']
    #u.year = request.form['dob-year']
    u.age = 18
    u.about = request.form['question-body']
    u.avatar = request.form['profile-pic']

    u.insert()
    print "the new uid is %s" % u.id
    user_login(u.id)
    return questions(request)
开发者ID:lachlanmarks,项目名称:meno,代码行数:39,代码来源:views.py

示例12: init_db

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
    def init_db(self):
        try:
            engine = self.session.get_bind(mapper=None, clause=None)

            inspector = Inspector.from_engine(engine)
            if 'ab_user' not in inspector.get_table_names():
                log.info("Security DB not found Creating")
                Base.metadata.create_all(engine)
                log.info("Security DB Created")
                self.migrate_db()
            if self.session.query(Role).filter_by(name=self.auth_role_admin).first() is None:
                role = Role()
                role.name = self.auth_role_admin
                self.session.add(role)
                self.session.commit()
                log.info("Inserted Role for public access %s" % (self.auth_role_admin))
            if not self.session.query(Role).filter_by(name=self.auth_role_public).first():
                role = Role()
                role.name = self.auth_role_public
                self.session.add(role)
                self.session.commit()
                log.info("Inserted Role for public access %s" % (self.auth_role_public))
            if not self.session.query(User).all():
                user = User()
                user.first_name = 'Admin'
                user.last_name = 'User'
                user.username = 'admin'
                user.password = generate_password_hash('general')
                user.email = '[email protected]'
                user.active = True
                user.role = self.session.query(Role).filter_by(name=self.auth_role_admin).first()
                self.session.add(user)
                self.session.commit()
                log.info("Inserted initial Admin user")
                log.info("Login using Admin/general")
        except Exception as e:
            log.error("DB Creation and initialization failed, if just upgraded to 0.7.X you must migrate the DB. {0}".format(str(e)))
开发者ID:iapilgrim,项目名称:Flask-AppBuilder,代码行数:39,代码来源:manager.py

示例13: facebook_authorized

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def facebook_authorized(resp):
    """ Handle facebook callback. Create/update user. """

    if resp is None:
        return 'Access denied: reason=%s error=%s' % (
            request.args['error_reason'],
            request.args['error_description']
        )
    session['oauth_token'] = (resp['access_token'], '')
    fb_user = facebook.get('/me')
    
    # Checking if the user is already registered
    user = User.query.filter_by(email=fb_user.data['email']).first()
    if user:
        # Existing user
        is_new = False
    else:
        # New user
        user = User(email=fb_user.data['email'])
        is_new = True
    
    # Add/update user data
    user.first_name = fb_user.data['first_name']
    user.last_name = fb_user.data['last_name']
    
    if is_new:
        # Generating password if the user is new
        #app.emails.send_backer_account_created(user)
        user.password = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    
    db.session.add(user)
    db.session.commit()
    
    login.login_user(user)
    
    # TODO: Change the redirect url
    return redirect(request.args['next'])
开发者ID:Denrybin,项目名称:backcapital,代码行数:39,代码来源:views.py

示例14: facebook_authorized

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def facebook_authorized(resp):
    error = 'Something went wrong - Could not fetch data from Facebook'
    if resp is None:
        return authenticate_web_user(error='%s, error_description=%s' %(request.args['error_reason'], request.args['error_description']))
    if isinstance(resp, OAuthException):
        return authenticate_web_user(error=resp.message)

    session['oauth_token'] = (resp['access_token'], '')
    access_token = session['oauth_token'][0]
    expires = resp.get('expires', None)
    (me, data) = (None, {})
    if access_token and expires:
        expires = datetime.utcnow() + timedelta(seconds=long(expires))
        try:
            me = facebook.get('/me')
        except:
            pass
        try:
            error = me.data['error']['message']
        except:
            pass
    else:
        return authenticate_web_user(error=error)
    if hasattr(me, 'data'):
        data = me.data
    if not data:
        return authenticate_web_user(error=error)
    for k, v in dict(data).items():
        v = str(v).strip()
        if not v:
            data.pop(k)
    fb_id = data['id']
    oauth_object = FaceBookOAuth.objects(fb_id=fb_id)
    if oauth_object:
        oauth_object = oauth_object[0]
        user = User.objects(id=oauth_object.user.id)[0]
    else:
        user = User()
    third_party_data = {v:k for k, v in THIRD_PARTY_DATA.items()}
    fields_to_fetch = [third_party_data[k] for k, v in FIELDS_TO_FETCH.items()]
    fields_to_update = list(set(fields_to_fetch) - set(user.fields_updated))
    for field in fields_to_update:
        db_field = THIRD_PARTY_DATA[field]
        if db_field == 'last_name':
            for x in FIELDS_TO_FETCH[db_field]:
                try:
                    last_name += '%s ' %data[x]
                    user.last_name = last_name.strip()
                except:
                    pass
        elif db_field == 'location':
            for x in FIELDS_TO_FETCH[db_field]:
                try:
                    location = data[x]['name']
                    user.location = location
                except:
                    pass
        elif db_field == 'gender':
            genders = {v:k for k, v in GENDERS.items()}
            try:
                gender = genders[data[FIELDS_TO_FETCH[db_field]]]
                user.gender = gender
            except:
                pass
        elif db_field == 'dob':
            try:
                dob = data[FIELDS_TO_FETCH[db_field]]
                dob = dob.split('/')
                dob = '%s-%s-%s' %(dob[2], dob[0], dob[1])
                user.dob = dob
            except:
                pass
        elif db_field == 'picture':
            try:
                picture = requests.get('%s/%s/picture?type=large' %(FACEBOOK_API_URL, fb_id)).url
                user.picture = picture
            except:
                pass
        else:
            try:
                exec "user.%s = '%s'" %(db_field, data[FIELDS_TO_FETCH[db_field]]) in locals()
            except:
                pass
    user.is_active = True
    user.save()
    if not oauth_object:
        oauth_object = FaceBookOAuth()
    oauth_object.fb_id = fb_id
    oauth_object.user = user
    oauth_object.access_token = access_token
    oauth_object.expires = expires
    oauth_object.created_at = datetime.utcnow()
    oauth_object.save()
    registered = False
    if user.password:
        registered = True
    return authenticate_web_user(user=user, registered=registered)
开发者ID:gonboy,项目名称:restful_oauth,代码行数:99,代码来源:facebook_sign_up.py

示例15: make_user

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import last_name [as 别名]
def make_user(check_exists=False):
    if check_exists:
        if get_user():
            return
        else:
            user = User()
    else:
        user = get_user()

    # first api call
    req_url = 'http://api.linkedin.com/v1/people/~:(lastName,firstName,id,connections:(id),educations,num-recommenders,positions:(startDate,endDate),siteStandardProfileRequest)?format=json'

    resp = linkedin.get(req_url)
    linkedin_user = resp.data

    user.uid = linkedin_user['id']
    user.first_name = linkedin_user['firstName']
    user.last_name = linkedin_user['lastName']
    user.connections_1 = linkedin_user['connections']['_total']
    user.educations = linkedin_user['educations']['_total']
    user.recommendations = linkedin_user['numRecommenders']
    user.prof_url = linkedin_user['siteStandardProfileRequest']['url'].split('&')[0]

    positions = linkedin_user['positions']['values']
    
    now = datetime.now()

    months_worked = 0
    for position in positions:
        try:
            start_year = position['startDate']['year']
            start_month = position['startDate']['month']
        except KeyError:
            start_year = now.year
            start_month = now.month
        try:
            end_year = position['endDate']['year']
            end_month = position['endDate']['month']
        except KeyError:
            end_year = now.year
            end_month = now.month
        months_worked += (end_month-start_month)+12*(end_year-start_year)

    user.months_worked = months_worked
    
    # second api call
    req_url = 'http://api.linkedin.com/v1/people/~/group-memberships/4409416?format=json'
    resp = linkedin.get(req_url)
    group_info = resp.data

    try:
        if group_info['membershipState']['code'] == 'member':
            user.in_group = True
    except:
        user.in_group = False

    # third api call
    req_url = 'http://api.linkedin.com/v1/people-search?facet=network,S&page=2&format=json'
    resp = linkedin.get(req_url)
    network_info = resp.data
    user.connections_2 = network_info['numResults']

    # fourth api call
    month_ago = now - timedelta(30)
    since_epoch = int((month_ago - datetime(1970,1,1)).total_seconds()*1000.)

    req_url = \
            'http://api.linkedin.com/v1/people/~/network/updates?scope=self&after={0}&format=json'.format(since_epoch)
    resp = linkedin.get(req_url)
    activity_info = resp.data
    user.activities_last_month = activity_info['_total']

    user.save()
开发者ID:r-medina,项目名称:razorfish_hackathon,代码行数:75,代码来源:views.py


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