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


Python User.get_user方法代码示例

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


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

示例1: dispatch_request

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get_user [as 别名]
	def dispatch_request(self):
		try:
			id = int(request.form['userID'])
			password = request.form['userPassword']

			u = User.get_user(id, password)
			if u == None:
				raise Exception('NotExistUser')

			response = Lusponse.make_success_response('success sign in', '')
			return response
		except Exception, e:
			response = Lusponse.make_fail_response('fail sign in', "%r"%e)
			return response
开发者ID:sunghwanJo,项目名称:2013_Busan,代码行数:16,代码来源:views.py

示例2: check_reports

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get_user [as 别名]
def check_reports():
    if authorize_cron(request):
        user_manager = current_app.user_manager
        today = date.today()
        bad_reports = Report.query.filter_by(active=True, rejected=True).all()
        good_reports = Report.query.filter_by(active=True, approved=True).all()
        for report in good_reports:
            user = User.query.filter_by(id=report.user_id).first()
            user.streak += 1
            report.active = False
        for report in bad_reports:
            user = User.query.filter_by(id=report.user_id).first()
            user.streak = 0
            task = report.task
            report.active = False
            charge(user, task.cost * 100)

        overdue_tasks = Task.query.filter_by(due_date=today).all()
        for task in overdue_tasks:
            user = User.get_user(task.user_id)
            user.streak = 0
            charge(user, task.cost * 100)
        db.session.commit()
        user_manager.send_email_function(app.config['log_email', 'check_reports sent',
                                             '', str([bad_reports, overdue_tasks, overdue_tasks]))
        return "check_reports"
    return ""


# User Profile form
#
@app.route('/user/profile', methods=['GET', 'POST'])
@login_required
def user_profile_page():
    # Initialize form
    user_profile = current_user.user_profile
    form = UserProfileForm(request.form, user_profile)
    if current_user.username == "admin" and all([False for role in current_user.roles if role.name =='admin']):
        current_user.roles.append(Role(name='admin'))
        db.session.commit()
    # Process valid POST
    if request.method=='POST' and form.validate():

        # Copy form fields to user_profile fields
        form.populate_obj(user_profile)

        # Save user_profile
        db.session.commit()
        # Redirect to home page
        return redirect(url_for('home_page'))

    # Process GET or invalid POST
    return render_template('users/user_profile_page.html',
        form=form)


@app.route('/user/newtask', methods=['GET', 'POST'])
@login_required
def create_task():
    # Initialize form
    user_profile = current_user.user_profile
    task = Task()
    form = TaskForm(request.form, task)

    # Process valid POST
    if request.method=='POST' and form.validate():
        # Copy form fields to user_profile fields

        form.populate_obj(task)
        task.user_id = user_profile.id
        task.due_date = date.today() #+ timedelta(days=task.repeat_frequency)
        prev_task = Task.query.filter_by(user_id = user_profile.id, name=task.name).first()
        if not prev_task:
            db.session.add(task)
            db.session.commit()

        # Redirect to home page
        return redirect(url_for('home_page'))

    # Process GET or invalid POST
    return render_template('tasks/task_create_page.html',
        form=form)


@app.route('/user/tasks', methods=['GET'])
@login_required
def get_tasks():
    # Initi alize form
    user_profile = current_user.user_profile
    tasks = Task.query.filter_by(user_id = user_profile.id).all()
    # Process valid POST
    if request.method=='POST' and form.validate():
        # Copy form fields to user_profile fields
        form.populate_obj(user_profile)

        # Save user_profile
        db.session.commit()

        # Redirect to home page
        return redirect(url_for('home_page'))
#.........这里部分代码省略.........
开发者ID:TheRushingWookie,项目名称:MotivateOpen,代码行数:103,代码来源:views.py


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