コード例 #1
0
def add_feedback(request):
    """
	Add new feedback into MySQL databases
	Http form MUST includes `summary`, `category`, `contact`
	:param request: httpRequest
	:return: status (success or fail), err_info and err_code
	"""
    if request.method == 'POST':
        try:
            feedback_info = json.loads(
                request.body.decode('utf-8'))['feedback']

            new_feedback = Feedback(summary=feedback_info['summary'],
                                    category=feedback_info['category'],
                                    contact=feedback_info['contact'],
                                    details=feedback_info['details'] if
                                    'details' in feedback_info.keys() else '')

            new_feedback.save()
            return JsonResponse({'status': 'success'})

        except DatabaseError as e:
            return JsonResponse({
                'status': 'fail',
                'err_code': e.args[0],
                'err_info': e.args[1],
            })
コード例 #2
0
ファイル: views.py プロジェクト: phongdk92/qlnt
def feedback(request):
#hainhh
    print 0
    if request.method == 'POST': # If the form has been submitted...
        if request.is_ajax():
            url = 'url: ' + request.POST['feedback_url']
            user = '******' + unicode(request.user)
            school = 'school: ' + unicode(get_school(request))
            content = request.POST['content']
            subject = u'[qlnt] User feedback'
            message = '\n'.join([url, user, school, content])
            #print message
            #send_email( subject = subject, message = message,
            #                          to_addr= ['*****@*****.**', '*****@*****.**'])
            Feedback.objects.create(content = content, title = url, email = school)
            thread.start_new_thread(send_email, (subject, message, GMAIL_LOGIN, ['*****@*****.**', '*****@*****.**','*****@*****.**']))
            return HttpResponse(simplejson.dumps({'success': True}), mimetype='json')
        else:
            form = FeedbackForm(request.POST) # A form bound to the POST data
            if form.is_valid():
                c = Feedback(fullname = form.cleaned_data['fullname'] ,
                             phone = form.cleaned_data['phone'],
                             email = form.cleaned_data['email'],
                             title = form.cleaned_data['title'],
                             content = form.cleaned_data['content'],
                             )
                c.save()
                return HttpResponseRedirect('/app/contact') # Redirect after POST
    else:
        form = FeedbackForm() # An unbound form

    return render_to_response('contact.html', {'form': form}, django.template.RequestContext(request))
コード例 #3
0
def feedback():
    #descriptions = Feedback
    feedbacks = Feedback.query.order_by(Feedback.id.desc())
    #print(feedbacks)
    if request.method == "POST":
        description = request.form.get("description")
        contact_details = request.form.get("contact_details")
        f = Feedback()
        f.description = description
        f.contact_details = contact_details
        f.save()
        print(description, contact_details)
        flash("反馈提交成功,我们将会尽快处理!")
        return redirect(url_for('zhihu.home'))
    return render_template("beagle/feedback.html",
                           title="反馈",
                           feedbacks=feedbacks,
                           f="feedback")
コード例 #4
0
ファイル: views.py プロジェクト: truonganhhoang/qlnt
def feedback(request):
    #hainhh
    print 0
    if request.method == 'POST':  # If the form has been submitted...
        if request.is_ajax():
            url = 'url: ' + request.POST['feedback_url']
            user = '******' + unicode(request.user)
            school = 'school: ' + unicode(get_school(request))
            content = request.POST['content']
            subject = u'[qlnt] User feedback'
            message = '\n'.join([url, user, school, content])
            #print message
            #send_email( subject = subject, message = message,
            #                          to_addr= ['*****@*****.**', '*****@*****.**'])
            Feedback.objects.create(content=content, title=url, email=school)
            thread.start_new_thread(
                send_email, (subject, message, GMAIL_LOGIN, [
                    '*****@*****.**', '*****@*****.**',
                    '*****@*****.**'
                ]))
            return HttpResponse(simplejson.dumps({'success': True}),
                                mimetype='json')
        else:
            form = FeedbackForm(request.POST)  # A form bound to the POST data
            if form.is_valid():
                c = Feedback(
                    fullname=form.cleaned_data['fullname'],
                    phone=form.cleaned_data['phone'],
                    email=form.cleaned_data['email'],
                    title=form.cleaned_data['title'],
                    content=form.cleaned_data['content'],
                )
                c.save()
                return HttpResponseRedirect(
                    '/app/contact')  # Redirect after POST
    else:
        form = FeedbackForm()  # An unbound form

    return render_to_response('contact.html', {'form': form},
                              django.template.RequestContext(request))
コード例 #5
0
ファイル: views.py プロジェクト: tranvictor/truongnha
def feedback(request):
    if request.method == 'POST': # If the form has been submitted...
        if request.is_ajax():
            user = request.user
            if (request.user.is_anonymous()
                    or request.user.username in [settings.DEMO_LOGIN_SCHOOL,
                        settings.DEMO_LOGIN_TEACHER,
                        settings.DEMO_LOGIN_UPPER,
                        settings.DEMO_LOGIN_STUDENT]):
                url = 'url: ' + request.POST['feedback_url']
                user_name = 'name: ' + unicode(request.POST['username'])
                email = 'email: ' + unicode(request.POST['userEmail'])
                content = 'content: ' + unicode(request.POST['content'])
                time = 'time: ' + unicode(date.today())
                if 'subject' in request.POST:
                    subject= unicode(request.POST['subject'])
                else: subject = u'[truongnha.com] Users\' feedback'
                message = '\n'.join([url, user_name, email, content, time])
                Feedback.objects.create(
                    content = content,
                    title = url,
                    email = email,
                    fullname = user)
                send_email(subject, message, None,
                        [ '*****@*****.**',
                            '*****@*****.**',
                            '*****@*****.**',])
                return HttpResponse(simplejson.dumps({'success': True}),
                        mimetype='json')
            else:
                url = 'url: ' + request.POST['feedback_url']
                user_name = 'user: '******'HIEU_TRUONG', 'HIEU_PHO',
                        'GIAM_DOC_SO', 'TRUONG_PHONG']:
                    email = profile.organization.email
                    phone = profile.organization.phone
                else:
                    if profile.position == 'HOC_SINH':
                        email = user.pupil.email
                        phone = user.pupil.sms_phone
                    elif profile.position == 'GIAO_VIEN':
                        email = user.teacher.email
                        phone = user.teacher.sms_phone
                user_email = 'email: ' + unicode(email)
                user_phone = 'phone: ' + unicode(phone)
                school = 'school: ' + unicode(get_school(request))
                content = request.POST['content']
                time = 'time: ' + unicode(date.today())
                subject = u'[truongnha.com] Users\' feedback'
                message = '\n'.join([url, user_name, user_email,
                    user_phone, school, content, time])
                Feedback.objects.create(
                    content = content,
                    title = url,
                    email = school,
                    fullname = user
                )
                send_email(subject, message, '',
                        ['*****@*****.**',
                            '*****@*****.**',
                            '*****@*****.**'])
                return HttpResponse(simplejson.dumps({'success': True}),
                        mimetype='json')
        else:
            form = FeedbackForm(request.POST) # A form bound to the POST data
            if form.is_valid():
                c = Feedback(fullname = form.cleaned_data['fullname'] ,
                             phone = form.cleaned_data['phone'],
                             email = form.cleaned_data['email'],
                             title = form.cleaned_data['title'],
                             content = form.cleaned_data['content'],
                             )
                c.save()
                return HttpResponseRedirect('/app/contact') # Redirect after POST
    else:
        form = FeedbackForm() # An unbound form
    return render_to_response('contact.html',
            {'form': form}, django.template.RequestContext(request))