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


Python FeedbackForm.save方法代码示例

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


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

示例1: feedback_save

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def feedback_save(request):
    form = FeedbackForm(request.user, data=request.POST.copy() or None)

    if form.is_bound and form.is_valid():
        form.save(request.user) 

    return HttpResponse()
开发者ID:mkramb,项目名称:errorify,代码行数:9,代码来源:views.py

示例2: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def feedback(request):
    if request.method == 'POST' and request.is_ajax():
        f = FeedbackForm(request.POST)
        f.save()
        return HttpResponse()
    else:
        return HttpResponseBadRequest()
开发者ID:prateek-iiitd,项目名称:IIITDAlumniPortal,代码行数:9,代码来源:views.py

示例3: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def feedback(request):

    form = FeedbackForm(request.POST or None)
    if form.is_valid():
        form.save()

        # TODO: Add message (django.contrib.messages)

        return redirect('/')

    return render(request, 'feedback.html', {'form': form})
开发者ID:nixilla,项目名称:where-is-when-is,代码行数:13,代码来源:views.py

示例4: feedback_view

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def feedback_view(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponse('ok')
        else:
            errors = {}
            for key, value in form.errors.items():
                errors[key] = value[0]
            return HttpResponse(json.dumps(errors))
开发者ID:renkse,项目名称:myapps,代码行数:13,代码来源:views.py

示例5: send_feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def send_feedback(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'guestbook/frontend/thanks.html')
    else:
        form = FeedbackForm()

    return render(request, 'guestbook/frontend/send_feedback.html', {
        'form': form,
    })
开发者ID:VBelozyorov,项目名称:libcms,代码行数:14,代码来源:views.py

示例6: add_feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def add_feedback(request, conference_slug=''):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('guestbook_index'))
    else:
        form = FeedbackForm()
    return render(request, 'guestbook/feedback_add.html',
                              {'form': form,
                               'module':'guestbook',})
开发者ID:isergey,项目名称:system,代码行数:14,代码来源:views.py

示例7: feedbackcreate

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def feedbackcreate(request):

    form = FeedbackForm(request.POST or None)
    topics = Topic.objects.all()

    if request.method == 'POST':
        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse('thanks'))
        else:
            return render(request, 'feedback.html', {'form': form, 'topics': topics })

    return render(request, 'feedback.html', {'form': FeedbackForm(), 'topics': topics})
开发者ID:Bauerr,项目名称:geoq,代码行数:15,代码来源:views.py

示例8: edit_feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def edit_feedback(request, id):
    feedback = get_object_or_404(Feedback, id=id)
    if request.method == 'POST':
        form = FeedbackForm(request.POST, instance=feedback)
        if form.is_valid():
            form.save()
            return redirect('guestbook:administration:feedbacks_list')
    else:
        form = FeedbackForm(instance=feedback)

    return render(request, 'guestbook/administration/edit_feedback.html', {
        'form': form,
    })
开发者ID:VBelozyorov,项目名称:libcms,代码行数:15,代码来源:views.py

示例9: edit

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def edit(request, message_id):
    feedback = get_object_or_404(Feedback, id=message_id)
    if request.method == 'POST':
        form = FeedbackForm(request.POST, instance=feedback)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('administration_guestbook_index'))
    else:
        form = FeedbackForm(model_to_dict(feedback),instance=feedback)
    return direct_to_template(request, 'guestbook/administration/edit_message.html',
                              {'form': form,
                               'feedback':feedback,
                               'active_module': 'guestbook'})
开发者ID:isergey,项目名称:system,代码行数:15,代码来源:views.py

示例10: contact

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def contact(request):
    """
    Feedback form
    """
    form = FeedbackForm(initial={'submitter': request.user})

    if request.method == 'POST':
        form = FeedbackForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            form.save()
            messages.error(request, 'Thank you', fail_silently=False)
        else:
            messages.error(request, 'Invalid', fail_silently=False)
            print form.errors

    return render(request, "contact.html", {'form': form, 'helper': FeedbackForm.helper})
开发者ID:joash,项目名称:djangotemplate,代码行数:18,代码来源:views.py

示例11: create

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def create(request):
    username = None
    group = 'teacher'
    
    if request.user.is_authenticated():
        username = request.user.username
        if request.user.has_perm('feedback.add_feedback'):
            group = 'parent'
            
    if request.POST:
        form = FeedbackForm(request.POST)
        if form.is_valid():
            # this saves the form submission data, but doesn't submit it to the server yet
            # It is needed so that we can set the parent ID on the model data before final submission
            fb = form.save(commit=False)
            fb.sentByParent = request.user
            fb.save()
            
            return HttpResponseRedirect('/feedback/parent_view/')
        
    else:
        form = FeedbackForm()
        
        args = {}
        args.update(csrf(request))
        
        args['form'] = form
        args['username'] = username
        args['group'] = group
        
        return render_to_response('create_feedback.html', args)
开发者ID:kblauer,项目名称:kinder-updates,代码行数:33,代码来源:views.py

示例12: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def feedback(request):
    """
    sends the feedback modal.
    """
    logged_in = True

    # CHECKS:
    #   i) user is logged in
    #   ii) request is either ajax for requesting feedback modal
    #   iii) request is a POST request for submitting feedback
    # else error
    if (not request.user.is_authenticated()) or \
            (not request.is_ajax() and not request.method == "POST"):
        return HttpResponse("Please login and go to the main page.")

    form = FeedbackForm()
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user         # add user
            obj.save()
            messages.success(request, "Thank you for your valuable feedback.")
        return HttpResponseRedirect(reverse('home'))
    return render(request, 'feedback.html',{
        'form': form, 'logged_in': logged_in })
开发者ID:IIIT-Delhi,项目名称:findmystuff,代码行数:28,代码来源:views.py

示例13: index

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def index(request):
    feedbacks_page = get_page(request, Feedback.objects.filter(publicated=True).order_by('-add_date'))

    count_feedback = len(feedbacks_page)

    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'guestbook/frontend/thanks.html')
    else:
        form = FeedbackForm()

    return render(request, 'guestbook/frontend/index.html', {
        'feedbacks_page': feedbacks_page,
        'form': form,
        'count_feedback': count_feedback
    })
开发者ID:isergey,项目名称:libcms,代码行数:20,代码来源:views.py

示例14: add

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def add(request):
	if request.method == "POST":
		form = FeedbackForm(request.POST)
		
		if form.is_valid():
			if request.user.is_authenticated(): form.instance.user = request.user
			else: form.instance.user = None
			if 'HTTP_REFERER' in request.META:
				form.instance.context = request.META['HTTP_REFERER']
			form.save()
			return HttpResponse('', mimetype="text/plain")
		else:
			logger.debug(form.errors)
			error_msg = []
			for field in form.errors:
				for error in form.errors[field]:
					error_msg.append('%s: %s' % (form.fields[field].label, error))
			error_msg = '\n'.join(error_msg)
			
			return HttpResponseBadRequest(error_msg, mimetype="text/plain")
	else:
		return HttpResponseNotAllowed(["POST",])
开发者ID:truongsinh,项目名称:tykes,代码行数:24,代码来源:views.py

示例15: applicant_profile

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import save [as 别名]
def applicant_profile(request, event_name, name):
  try:
    applicant = Applicant.objects.get(norm_name=normalize_name(name), event__name=event_name)
  except Applicant.DoesNotExist:
    raise Http404('Applicant does not exist.')
  try:
    event = Event.objects.get(name=event_name)
  except Event.DoesNotExist:
    raise Http404('Event does not exist')
  try:
    feedback = Feedback.objects.get(applicant=applicant, scholar=request.user.mcuser)
  except Feedback.DoesNotExist:
    feedback = Feedback()
    feedback.applicant = applicant
    feedback.scholar = request.user.mcuser
  if request.method == 'POST':
    form = FeedbackForm(request.POST, instance=feedback)
    if (form.is_valid()):
      form.save()
      if request.is_ajax():
        return JsonResponse({'msg': 'saved successfully'})
      return redirect('feedback:index', event_name)
  else:
    form = FeedbackForm(instance=feedback)
  all_feedback = Feedback.objects.filter(applicant=applicant)
  is_interviewer = request.user.mcuser in event.interviewers.all()
  is_assigned = Assignment.objects.filter(scholar=request.user.mcuser, applicant=applicant).exists()

  context = {
      'feedback': all_feedback,
      'applicant': applicant,
      'form': form,
      'state': get_state(),
      'event_name': event_name,
      'survey_link': event.survey_link,
      'is_interviewer': is_interviewer and is_assigned,
      'favorited': favorited(request.user.mcuser, applicant)
      }
  return render(request, 'feedback/applicant.html', context)
开发者ID:mcdermott-scholars,项目名称:mcdermott,代码行数:41,代码来源:views.py


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