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


Python Feedback.user方法代码示例

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


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

示例1: post_feedback

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import user [as 别名]
def post_feedback(request, subject, text):
	logger.debug("Ajax request received for feedback.")
	success = False
	
	if request.user.is_authenticated():
		user = request.user
		logger.info("Submitting feedback for "+str(user))
		
		fb = Feedback()
		fb.user = user
		fb.subject = subject
		fb.text = text
		fb.save()
		
		success = True
	
	return simplejson.dumps({'success':success})
开发者ID:karthikprabhu,项目名称:newstrolley-stable,代码行数:19,代码来源:ajax.py

示例2: add

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import user [as 别名]
def add(request):
    """Gather feedback for a page, and if it is ok show a thanks message and link back to the page."""

    submit_was_success = False
    return_to_url      = None

    # If it is a post request try to create the feedback
    if request.method == 'POST':
        form = FeedbackForm( request.POST )
        if form.is_valid():
            feedback = Feedback()
            feedback.url      = form.cleaned_data['url']
            feedback.email    = form.cleaned_data['email']
            feedback.comment  = form.cleaned_data['comment']

            # if there is any content in the honeypot field then label this comment as spammy
            if form.cleaned_data['website']:
                feedback.status = 'spammy'
            
            # if the comment starts with an html tag it is probably spam
            if re.search('\A\s*<\w+>', form.cleaned_data['comment']):
                feedback.status = 'spammy'

            if request.user.is_authenticated():
                feedback.user = request.user

            feedback.save()

            submit_was_success = True
            return_to_url = feedback.url or None
        
    else:
        # use GET to grab the url if set
        form = FeedbackForm(initial=request.GET)
        
    
    return render_to_response(
        'feedback/add.html',
        {
            'form':               form,
            'submit_was_success': submit_was_success,
            'return_to_url':      return_to_url,
        },
        context_instance=RequestContext(request)
    )
开发者ID:Code4SA,项目名称:pombola,代码行数:47,代码来源:views.py

示例3: add

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import user [as 别名]
def add(request):
    """Gather feedback for a page, and if it is ok show a thanks message and link back to the page."""

    submit_was_success = False
    return_to_url      = None

    # If it is a post request try to create the feedback
    if request.method == 'POST':
        form = FeedbackForm( request.POST )
        if form.is_valid():
            feedback = Feedback()
            feedback.url      = form.cleaned_data['url']
            feedback.comment  = form.cleaned_data['comment']

            if request.user.is_authenticated():
                feedback.user = request.user

            feedback.save()

            submit_was_success = True
            return_to_url = feedback.url or None
        
    else:
        # use GET to grab the url if set
        form = FeedbackForm(initial=request.GET)
        
    
    return render_to_response(
        'feedback/add.html',
        {
            'form':               form,
            'submit_was_success': submit_was_success,
            'return_to_url':      return_to_url,
        },
        context_instance=RequestContext(request)
    )
开发者ID:supercool,项目名称:mzalendo,代码行数:38,代码来源:views.py


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