Example #1
0
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))
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],
            })
Example #3
0
def dispose_text_message(msg):
    content = msg.content
    if _matches(content, MSG_PATTERNS['internship']):
        if _matches(content, INTERNSHIP_PATTERNS['today']):
            return InternshipNews.to_text(InternshipNews.get_today())
        elif _matches(content, INTERNSHIP_PATTERNS['ystd']):
            return InternshipNews.to_text(InternshipNews.get_ystd())
        elif _matches(content, INTERNSHIP_PATTERNS['company']):
            company = _get_keyword(content, INTERNSHIP_PATTERNS['company'])
            return InternshipNews.to_text(InternshipNews.get_by_company(company))
        elif _matches(content, INTERNSHIP_PATTERNS['address']):
            address = _get_keyword(content, INTERNSHIP_PATTERNS['address'])
            return InternshipNews.to_text(InternshipNews.get_by_company(address))
        elif _matches(content, INTERNSHIP_PATTERNS['source']):
            source = _get_keyword(content, INTERNSHIP_PATTERNS['source'])
            return InternshipNews.to_text(InternshipNews.get_by_source(source))
        else:
            return InternshipNews.to_text(InternshipNews.get_latest())

    elif _matches(content, MSG_PATTERNS['pku_eecs']):
        return fetch_eecs_pku()

    elif _matches(content, MSG_PATTERNS['feedback']):
        Feedback.add(Feedback(source=msg.source, content=msg.content))
        return MESSAGES['feedback']

    else:
        return MESSAGES['default']
Example #4
0
def add_feedback():
    try:
        name = Student.query.filter_by(number=session["user_number"]).first(
        ).name if session["user_type"] == 's' else Teacher.query.filter_by(
            number=session['user_number']).first().name
        feedback = Feedback(session["user_number"], name,
                            json.loads(request.data.decode())['feedback'])
        feedback.id = str(uuid.uuid1())
        db.session.add(feedback)
        db.session.commit()
        return json.dumps({"code": 1})
    except Exception as e:
        return json.dumps({"code": -1})
Example #5
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        message = form.message.data
        print(name)
        print(email)
        print(message)

        # 数据库操作
        feedback = Feedback(name=name, email=email, message=message)
        db.session.add(feedback)
        db.session.commit()

        send_mail(
            "New Feedback",
            current_app.config['MAIL_USERNAME'],
            'mail/feedback.html',
            name=name,
            email=email,
            message=message)

        print("\nData received. Now redirecting ...")
        flash("Message Recived", "Success")
        return redirect(url_for('.contact'))

    return render_template('contact.html', form=form)
Example #6
0
def receive_feedback():
    """
        Add user input from Feedback page to database
    """
    if request.method == 'POST':
        data = request.get_json(silent=False)

        category = data['selected_category']
        feedback = data['user_feedback']
        rating = data['user_rating']

        if (feedback != '' or rating != 0):
            feedback_ = Feedback(category=category,
                                 feedback=feedback,
                                 rating=rating)
            db.session.add(feedback_)

            # keep track of ratings from all users
            if (rating != 0):
                rating_ = Ratings(rating=rating)
                db.session.add(rating_)

            db.session.commit()
        return 'OK', 200

    return redirect('/')
Example #7
0
def geefFeedback():
    ### INPUT: Een dict met een ID van een document en per thema een -1 of 1
    ### OUTPUT: Een JSON, met daarin een dict van alle onderliggende documenten uit de de input-dict, en per document en dict met voorspellingen van een thema.
    data = request.get_json(force=True)
    item = Feedback.query.get(data["id"])
    if item:  # Controleer of het document al in de database staat, als dat zo is, update dan de informatie
        item.bestuurOndersteuning += data["bestuurOndersteuning"]
        item.veiligheid += data["veiligheid"]
        item.verkeerVervoerWaterstaat += data["verkeerVervoerWaterstaat"]
        item.economie += data["economie"]
        item.onderwijs += data["onderwijs"]
        item.sportCultuurRecreatie += data["sportCultuurRecreatie"]
        item.sociaalDomein += data["sociaalDomein"]
        item.volksgezondheidMilieu += data["volksgezondheidMilieu"]
        item.volkshuisvestingRuimtelijkeOrdening += data[
            "volkshuisvestingRuimtelijkeOrdening"]
    else:  # Voeg de informatie toe
        feedback = Feedback(
            id=data["id"],
            bestuurOndersteuning=data["bestuurOndersteuning"],
            veiligheid=data["veiligheid"],
            verkeerVervoerWaterstaat=data["verkeerVervoerWaterstaat"],
            economie=data["economie"],
            onderwijs=data["onderwijs"],
            sportCultuurRecreatie=data["sportCultuurRecreatie"],
            sociaalDomein=data["sociaalDomein"],
            volksgezondheidMilieu=data["volksgezondheidMilieu"],
            volkshuisvestingRuimtelijkeOrdening=data[
                "volkshuisvestingRuimtelijkeOrdening"])
        db.session.add(feedback)
    db.session.commit()
    return ("", 204)
Example #8
0
def create_feedback(ISBN, user):
    feedback_form = CreateFeedbackForm()
    top_review_form = SetNofTopReviewsForm()
    book = Book.query.get(ISBN)
    review = Review.query.filter_by(username=user, ISBN=ISBN).first()

    if feedback_form.validate_on_submit():
        feedback_params = {
            'customer_feedback': current_user.get_id(),
            'rating': feedback_form.rating.data,
            'customer_review': review.username,
            'ISBN': ISBN
        }
        if Feedback.query.filter_by(customer_feedback=current_user.get_id(),
                                    ISBN=book.ISBN,
                                    customer_review=user).first() is None:
            if current_user.get_id() != review.username:
                feedback = Feedback(**feedback_params)

                if save(feedback):
                    flash("Feedback created successfully!")

                    return redirect(url_for('my.show_book', ISBN=book.ISBN))
                else:
                    flash("Failed to create feedback. Please try again")
            else:
                flash("You may not create feedback for your own review")
        else:
            flash("You have already entered a feedback.")

    return render_template('my/book/show.html',
                           book=book,
                           review=review,
                           feedback_form=feedback_form,
                           top_review_form=top_review_form)
Example #9
0
def feedback_route():
    email = request.form["email"]
    print(email)
    body = request.form["body"]
    feedback = Feedback(email, body)
    db.session.add(feedback)
    db.session.commit()
    return redirect(url_for('planner.index'))
Example #10
0
def sendFeedback():
    form = FeedbackForm()
    if form.validate_on_submit():
        flash('Feedback sent. Thank you for your submission!')
        the_form = Feedback(name=form.name.data, email=form.email.data, body=form.body.data)
        db.session.add(the_form)
        db.session.commit()
        return redirect(url_for('category'))
    return render_template('feedback.html', title='New feedback form', form=form)
Example #11
0
def feedback():
    username = request.json.get('username')
    note = request.json.get('note')
    date = request.json.get('date')
    email = request.json.get('email')
    feedback = Feedback(username, note, date, email)
    db.session.add(feedback)
    db.session.commit()
    return formattingData(200, "Success", {})
Example #12
0
def feeds():
    form = FeedbackForm()
    if form.validate_on_submit():
        feedback = Feedback(name=form.name.data,
                            email=form.email.data,
                            message=form.message.data)
        db.session.add(feedback)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('index.html', form=form)
Example #13
0
    def test_follow_few_feedback(self):
        # create four users
        u1 = User(username='******', email='*****@*****.**')
        u2 = User(username='******', email='*****@*****.**')
        u3 = User(username='******', email='*****@*****.**')
        u4 = User(username='******', email='*****@*****.**')
        db.session.add_all([u1, u2, u3, u4])

        # create four posts
        now = datetime.utcnow()
        fb1 = Feedback(body="post from john",
                       author=u1,
                       timestamp=now + timedelta(seconds=1))
        fb2 = Feedback(body="post from susan",
                       author=u2,
                       timestamp=now + timedelta(seconds=4))
        fb3 = Feedback(body="post from mary",
                       author=u3,
                       timestamp=now + timedelta(seconds=3))
        fb4 = Feedback(body="post from david",
                       author=u4,
                       timestamp=now + timedelta(seconds=2))
        db.session.add_all([fb1, fb2, fb3, fb4])
        db.session.commit()

        # setup the followers
        u1.follow(u2)  # john follows susan
        u1.follow(u4)  # john follows david
        u2.follow(u3)  # susan follows mary
        u3.follow(u4)  # mary follows david
        db.session.commit()

        # check the followed posts of each user
        f1 = u1.followed_few_feedback().all()
        f2 = u2.followed_few_feedback().all()
        f3 = u3.followed_few_feedback().all()
        f4 = u4.followed_few_feedback().all()
        self.assertEqual(f1, [fb2, fb4, fb1])
        self.assertEqual(f2, [fb2, fb3])
        self.assertEqual(f3, [fb3, fb4])
        self.assertEqual(f4, [fb4])
Example #14
0
def index():
    form = FeedbackForm()
    if form.validate_on_submit():
        f = Feedback(first_name=form.first_name.data,
                     last_name=form.last_name.data,
                     email=form.email.data,
                     feedback=form.feedback.data)
        db.session.add(f)
        db.session.commit()
        flash(f'Thanks for the feedback {form.first_name.data}!')
        redirect(url_for('index'))
    return render_template('index.html', title='Give Feedback', form=form)
Example #15
0
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))
Example #16
0
    def post(self):
        """
        @content content of feedback
        """
        content = request.values.get('content', '')

        if not content:
            raise RespMissingArg('content')
        else:
            feedback = Feedback(accountid=g.account.id, content=content)
            db.session.add(feedback)
            db.session.commit()
        return {'feedback_id': feedback.id, 'content': feedback.content}
Example #17
0
def movies(page_num, imdb_id='0000'):
    movies = Movies.query.paginate(per_page=6, page=page_num, error_out=True)
    if request.method == 'POST':
        movie = Movies.query.filter_by(imdb_id=imdb_id).first()
        user_old = Feedback.query.filter_by(
            feed_id=(str(current_user.id) + '_' + movie.imdb_id)).first()
        if user_old:
            if (request.form['submit'] == 'Like' and user_old.feedback
                    == 1) or (request.form['submit'] == 'Dislike'
                              and user_old.feedback == -1):
                pass
            elif (request.form['submit'] == 'Like'
                  and user_old.feedback == -1):
                user_old.feedback = 1
            elif (request.form['submit'] == 'Dislike'
                  and user_old.feedback == 1):
                user_old.feedback = -1
            db.session.commit()
            return redirect(url_for('movies', page_num=page_num))
        else:
            if request.form['submit'] == 'Like':
                fb = Feedback(feed_id=(str(current_user.id) + '_' +
                                       movie.imdb_id),
                              movie_id=movie.imdb_id,
                              user_id=current_user.id,
                              feedback=1)
            elif request.form['submit'] == 'Dislike':
                fb = Feedback(feed_id=(str(current_user.id) + '_' +
                                       movie.imdb_id),
                              movie_id=movie.imdb_id,
                              user_id=current_user.id,
                              feedback=-1)
            db.session.add(fb)
            db.session.commit()
            return redirect(url_for('movies', page_num=page_num))
    elif request.method == 'GET':
        return render_template('movies.html', title='Movies', movies=movies)
    return render_template('movies.html', title='Movies', movies=movies)
Example #18
0
def feedback():
    if request.method == 'GET':
        questionList = Question.questionList()
        print(questionList)
        questions = {}
        x = 0
        for i in questionList:
            questions[x] = questionList[x]
            x = x + 1
        return questions
    elif request.method == 'POST':
        print(request.form)
        id = request.form['id']
        answers = request.form['answer'].replace('[',
                                                 '').replace(']',
                                                             '').split(',')
        questions = request.form['stuff'].replace('[',
                                                  '').replace(']',
                                                              '').split(',')
        print(id)
        print(answers)
        print(questions)
        Feedback.addFeedback(current_user.id, questions, answers, id)
Example #19
0
def index():
    form = FeedbackForm()
    if form.validate_on_submit():
        feedback = Feedback(body=form.feedback.data, author=current_user)
        db.session.add(feedback)
        db.session.commit()
        flash('Your post is now live!')
        return redirect(url_for('index'))
    page = request.args.get('page', 1, type=int)
    few_feedback = current_user.followed_few_feedback().paginate(
        page, app.config['POSTS_PER_PAGE'], False)
    return render_template('index.html',
                           title='Home',
                           form=form,
                           few_feedback=few_feedback)
Example #20
0
def feedback():
    form = forms.FeedbackForm()

    if form.validate_on_submit():
        name = form.name.data
        text = form.text.data

        feedback = {'name': name, 'text': text}

        f = Feedback(name=name, text=text)
        db.session.add(f)
        db.session.commit()

        return render_template('thanks.html', feedback=feedback)

    return render_template('feedback.html', form=form)
Example #21
0
def add_feedback():
    form = AddFeedbackForm()

    if form.validate_on_submit():
        feedback = Feedback(
            name=form.name.data, 
            email=form.email.data,
            details=form.details.data,
        )
        db.session.add(feedback)
        db.session.commit()

        flash('Successfully sent feedback!')
        return redirect(url_for('index'))

    return render_template('./public_templates/feedback_form.html', title="Feedback form", form=form)
Example #22
0
def feedback():
    formpage = FeedbackForm()

    if formpage.validate_on_submit():
        event = Event.query.filter_by(id=session.get('event_id')).first()
        student = Student.query.filter_by(id=session.get('id')).first()
        print "Your feedback's been posted bro"
        feedback = Feedback(student_id=student.id,
                            event_id=event.id,
                            title=formpage.title.data,
                            content=formpage.content.data)

        db.session.add(feedback)
        db.session.commit()
        flash('Your feedback has been posted', 'success')
        return redirect(url_for('home'))

    return render_template('feedback_post.html', formpage=formpage)
Example #23
0
def post(user):
    """check if code matches a team. if yes, join the team, and return team"""

    data = request.get_json()

    feedback = Feedback(user=user, text=data["text"])

    db.session.add(feedback)
    db.session.commit()

    message = f"{user.username} suggests: {data['text']}"

    send_message({"phone_number": os.environ.get("NICO_PHONE_NUMBER")},
                 message)

    message = "Thanks! Feedback received."
    print(message)
    db.session.close()
    return make_response(jsonify({"message": message}), 200)
Example #24
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        message = form.message.data

        # логика БД здесь
        feedback = Feedback(name=name, email=email, message=message)
        db.session.add(feedback)
        db.session.commit()

        send_mail("New Feedback", current_app.config['MAIL_DEFAULT_SENDER'], 'mail/feedback.html',
                  name=name, email=email)

        flash("Message Received", "success")
        return redirect(url_for('.contact'))

    return render_template('contact.html', form=form)
Example #25
0
 def add_feedback(self):
     if current_user.is_authenticated and current_user.id_prefix == 'u' and User.query.get(
             current_user.id):
         user_id = current_user.id
         mobile = current_user.mobile
     else:
         user_id = 0
         mobile = ''
     feedback = Feedback(feedback=self.feedback.data,
                         contact=self.contact.data,
                         user_id=user_id)
     db.session.add(feedback)
     db.session.commit()
     send_email(current_app.config['FEEDBACK_EMAILS'],
                '用户反馈',
                USER_FEEDBACK,
                feedback=feedback.feedback,
                contact=feedback.contact,
                mobile=mobile)
Example #26
0
def feedbackform():
    title = request.args.get('title', None)
    form = FeedbackForm(fbSubject=title)
    if request.method == 'POST':
        if 'submit' in request.form:
            if form.validate_on_submit():
                feedback = Feedback(item=form.fbSubject.data,
                                    fname=form.yourname.data,
                                    contact=form.contact.data,
                                    copyright=form.copyright.data,
                                    privacy=form.privacy.data,
                                    message=form.message.data)
                db.session.add(feedback)
                db.session.commit()
                flash('Thank you, your feedback about: {} has been recorded'.
                      format(form.fbSubject.data))
                return redirect(url_for('map1'))
        else:
            return redirect(url_for('map1'))
    return render_template('FeedBackForm.html', title=title, form=form)
Example #27
0
def submit():
    if request.method == 'POST':
        user = request.form['user']
        worker = request.form['worker']
        rating = request.form['rating']
        comments = request.form['comments']

        if user == '' or worker == '':
            return render_template('index.html',
                                   message='Please enter '
                                   'required fields')

        if db.session.query(Feedback).filter(
                Feedback.user == user).count() == 0:
            data = Feedback(user, worker, rating, comments)
            db.session.add(data)
            db.session.commit()
            send_mail(user, worker, rating, comments)
            return render_template('success.html')
        return render_template('index.html',
                               message='You have already '
                               'submitted feedback')
def feedback():
    feedback_form = FeedbackForm()
    all_feedback = Feedback.query.filter_by(user_id=current_user.id).all()

    if feedback_form.validate_on_submit():
        new_feedback = Feedback(user_id=current_user.id,
                                job_id=feedback_form.job.data,
                                body=feedback_form.body.data)

        db.session.add(new_feedback)
        db.session.commit()

        flash('Feedback submitted.', 'success')
        return redirect(url_for('user.feedback'))

    data = {
        'title': 'Your Feedback',
        'form': feedback_form,
        'all_feedback': all_feedback
    }

    return render_template('user/feedback.html', **data)
Example #29
0
def feedback():
    form = FeedbackForm()
    if form.validate_on_submit():
        msg = Feedback(feedback=form.feedback.data, author=current_user)
        db.session.add(msg)
        db.session.commit()
        flash('Message sent succesfully!')
        return redirect(url_for('feedback'))
    page = request.args.get('page', 1, type=int)
    msgs = Feedback.query.order_by(Feedback.timestamp.desc()).paginate(
        page, 9, False)  # 6 is the posts per page
    next_url = url_for('feedback',
                       page=msgs.next_num) if msgs.has_next else None
    prev_url = url_for('feedback',
                       page=msgs.prev_num) if msgs.has_prev else None
    rows = math.ceil(len(msgs.items) / 3)
    return render_template('feedback.html',
                           form=form,
                           posts=msgs.items,
                           next_url=next_url,
                           prev_url=prev_url,
                           rows=rows)
Example #30
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        message = form.message.data

        feedback = Feedback(name=name, email=email, message=message)
        db.session.add(feedback)
        db.session.commit()

        msg_body = f'You have recieved a new feedback from {name} <{email}>'

        send_mail('New Feedback',
                  current_app.config['MAIL_DEFAULT_SENDER'],
                  'mail/feedback.html',
                  name=name,
                  email=email)

        flash('Message Received', 'success')
        return redirect(url_for('.contact'))

    return render_template('contact.html', form=form)
Example #31
0
def feedback():
    form = FeedbackForm()
    if request.method == 'POST':
        name = request.form['name']
        topic = request.form['topic']
        email = request.form['email']
        text = request.form['text']
        if len(name) > 2 and len(topic) > 2 and '@' in email:
            try:
                feedback = Feedback(name=name,
                                    topic=topic,
                                    email=email,
                                    text=text)
                db.session.add(feedback)
                db.session.commit()
                flash('Сообщение отправлено', category='success')
            except:
                flash('Ошибка отправки - ошибка сервера', category='error')
        else:
            flash(
                'Ошибка отправки (имя, тема должны содержать хотябы 3 символа и почта должна быть валидна)',
                category='error')
    return render_template('feedback.html', form=form)
Example #32
0
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))