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


Python Answer.count_for方法代码示例

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


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

示例1: user_profile

# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import count_for [as 别名]
def user_profile():
    """Displays the user profile page"""
    user = users.get_current_user()
    question_count = Question.count_for(user)
    answer_count = Answer.count_for(user)
    form = ProspectiveUserForm()
    all_prospective_users = ProspectiveUser.get_for(user)
    prospective_user = all_prospective_users.get()

    if request.method == 'POST':
        if prospective_user is None:
            prospective_user = ProspectiveUser (
                login = user,
                origin_location = get_location(form.origin_location.data),
                notification_radius_in_km = form.notification_radius_in_km.data,
                screen_name = form.screen_name.data
            )
        else:
            prospective_user.origin_location = get_location(form.origin_location.data)
            prospective_user.notification_radius_in_km = form.notification_radius_in_km.data
            prospective_user.screen_name = form.screen_name.data
        try:
            prospective_user.put()
            subscribe_user_for_nearby_questions(prospective_user.key.id())
            flash(u'Home location successfully saved.', 'success')

            return redirect(url_for('user_profile'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('user_profile'))

    return render_template('user_profile.html', user=user, prospective_user=prospective_user,
                           question_count=question_count, answer_count=answer_count, form=form)
开发者ID:ahbuntu,项目名称:ece1779,代码行数:35,代码来源:views.py


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