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


Python User.find_by_email方法代码示例

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


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

示例1: login

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import find_by_email [as 别名]
def login():
    if current_user.is_authenticated():
        flash(gettext('You are already signed in.'))
        return redirect(url_for('index'))

    form = LoginForm()
    if form.validate_on_submit():
        try:
            user = User.find_by_email(form.email.data)
            if (user is not None) and (user.check_password(form.password.data)): 
                login_user(user)
                
                # Update the User's info
                user.last_login = user.last_seen
                user.last_seen = datetime.datetime.utcnow()
                user.save()
                redirect_to = url_for('dashboard')
                if 'redirect_to' in session:
                    redirect_to = session['redirect_to']
                    session.pop('redirect_to', None)
                flash(gettext('Signed in successfully.'))
                return redirect(redirect_to)
            else:
                raise Exception(gettext('User not found or invalid password'))
        except:
            flash(gettext('Invalid email or password'), 'error')

    return render_template('admin/signin.html', 
        title = gettext('Sign In'),
        form = form)
开发者ID:Tibodef,项目名称:PythonBlog,代码行数:32,代码来源:views.py

示例2: dispatch_request

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import find_by_email [as 别名]
	def dispatch_request(self):
		try:
			user = request.form['userEmail']
			title = request.form['missionTitle'].encode('utf-8')
			contents = request.form['missionContents'].encode('utf-8')
			difficulty = request.form['missionDifficulty']
			effect = request.form['missionEffect']

			effect = int(float(effect))
			difficulty = int(float(difficulty))

			m = Mission(title, contents, difficulty, effect)
			m.push_data()

			m = Mission.get_mission(title)
			u = User.find_by_email(user)
		
			ms = MissionState(u.id, m.id, '1')
			ms.push_data()

			response = Lusponse.make_success_response('success make missions', '')
			return response

		except Exception, e:
			response = Lusponse.make_fail_response('fail make missions', "%r"%e)
			return response
开发者ID:utopianami,项目名称:2013_pythonServer,代码行数:28,代码来源:views.py

示例3: tmp_test_info_setup

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import find_by_email [as 别名]
    def tmp_test_info_setup(self):
        self.make_users()
        print 'Make Users : %d'%(len(User.query.all() ) )
        self.ptrol_all_users()

        print UserInfo.query.count() == 12
        print User.query.count() == 12
        pprint(User.query.all())

        test_user = User('test_user5393', '5393')
        db.session.add(test_user)
        db.session.commit()

        test_user_info = UserInfo._make_user_info_with_email('test_user5393', 5, 3, 9, 3)
        db.session.add(test_user_info)
        db.session.commit()
        
        assert UserInfo.query.count() == 13
        assert User.query.count() == 13

        test_user = User.find_by_email('test_user5393')
        test_user_info = test_user.user_info.first()
        
        print test_user_info.get_avg_energy_data_with_date(datetime(2013, 10, 1, 1), datetime(2013, 10, 31, 23, 59, 59))

        self.sign_up('test_user7193', '7193')   
        self.sign_in('test_user7193', '7193')   
        self.info_setup('test_user7193', 7, 1, 9 , 3)

        test_user = User.find_by_email('test_user7193')
        test_user_info = test_user.user_info.first()
        
        print test_user_info.get_avg_energy_data_with_date(datetime(2013, 10, 1, 1), datetime(2013, 10, 31, 23, 59, 59))

        print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
        rv = self.getmonthdata('User7193')
        print rv.data 
        print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
开发者ID:utopianami,项目名称:2013_pythonServer,代码行数:40,代码来源:tests_flask.py

示例4: get_month_energy_datas

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import find_by_email [as 别名]
	def get_month_energy_datas(cls, email):
		from app.users.models import User
		user = User.find_by_email(email)

		year = datetime.now().year
		month = datetime.now().month
		max_day = datetime.now().day
		month_data_list = []
		
		for day in xrange(1, max_day):
			start_date = datetime(year, month, day)
			end_date = start_date + timedelta(days=1)
			day_datas = cls.get_energy_datas_with_date(user.id, start_date, end_date)
			data_sum = 0;
			for day_data in day_datas:
				data_sum += day_data.energy_amount
			month_data_list.append(data_sum)
			
		for index in xrange(2, max_day-1):
			month_data_list[index] += month_data_list[index-1]

		return month_data_list
开发者ID:utopianami,项目名称:2013_pythonServer,代码行数:24,代码来源:models.py

示例5: _make_energy_data_with_email

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import find_by_email [as 别名]
	def _make_energy_data_with_email(cls, email, submit_time, energy_amount):
		from app.users.models import User
		user_id = User.find_by_email(email).id
		return EnergyData(user_id, submit_time, energy_amount)
开发者ID:utopianami,项目名称:2013_pythonServer,代码行数:6,代码来源:models.py


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