def feedback_add(db: Session, feedback_content: schemas.Feedback_data): validate_customer(db=db, customer_id=feedback_content.customer_id) validate_order(db=db, order_id=feedback_content.order_id) add_content = models.Feedback(**feedback_content.dict()) db.add(add_content) db.commit() db.refresh(add_content) return {"Feedback Added"}
def feedback(request): if request.method == "POST": c = models.Feedback( feedback=request.POST.get("feedback"), path=request.POST.get('path'), ) c.save() c.upvote(request.user) if request.is_ajax(): return HttpResponse(simplejson.dumps({"feedback": "accepted"}), mimetype="json") return HttpResponseRedirect(app_settings.FEEDBACK_THANKS_URL)
def post(self): parser = reqparse.RequestParser() parser.add_argument('userId', type=int, required=True) parser.add_argument('content', required=True) parser.add_argument('postTime', required=True, type=DateTime) data = parser.parse_args() feedback = models.Feedback() for key, value in data.iteritems(): setattr(feedback, key, value) db.session.add(feedback) # 似乎插入操作需要进行一遍数据库访问操作才可以应用到数据库当中去 models.Community.query.first()
def feedback(request): if request.method == "POST": context = { key: value for key, value in request.POST.items() if key not in ['feedback', 'path', 'csrfmiddlewaretoken'] } try: context_json = simplejson.dumps(context) except: context_json = '' c = models.Feedback( feedback=request.POST.get("feedback"), user=request.user, path=request.POST.get('path'), extra=context_json, ) c.save() c.upvote(request.user) if app_settings.FEEDBACK_SEND_MAIL and app_settings.FEEDBACK_FROM: context.update({ 'id': c.id, 'feedback': c.feedback, 'path': c.path, 'user': request.user, 'request': request, }) if app_settings.FEEDBACK_REPLY_TO_USER: headers = {'reply-To': request.user.email} else: headers = {} email = EmailMessage( app_settings.FEEDBACK_SUBJECT % context, app_settings.FEEDBACK_BODY % context, app_settings.FEEDBACK_FROM, app_settings.FEEDBACK_TO, headers=headers, ) email.send(fail_silently=True) if request.is_ajax(): return HttpResponse(simplejson.dumps({ "feedback": "accepted", 'msg': 'Bien reçu, merci de votre participation' }), mimetype="json") return HttpResponseRedirect(app_settings.FEEDBACK_THANKS_URL)
def give_feedback(): form = models.Feedback() if request.method == "POST": manager = form.name.data logged_in = session['name'] employee = Employees.query.get(logged_in) if (employee.manager == manager): try: f = open("feedback.txt", "a") f.write('\n' + form.name.data + "\n" + form.message.data) flash("feedback submitted successfully") logging.info("feedback submitted successfully ") except Exception as e: logging.error("cannot submit feedback") flash("cannot submit feedback please try again") else: logging.error("cannot submit feedback") flash("u can give feedback for ur manager only") return render_template('/submitFeedback.html', form=form)
def givefeedback(): """Ticketing system givefeedback route. HTTP Request Methods: POST Output: JSON""" if DEBUG_FLAG: print("Feedback route visited.") # Pull the text out of the feedback form POST data. feedbackText = flask.request.form["form-feedback-text"] # Check to see how long it is excluding spaces, tabs, and newlines. if len("".join(feedbackText.split())) < 30: return json.dumps({"status": "failure"}) newFeedback = models.Feedback(text=feedbackText, creatorID=flask_login.current_user.id) models.db.session.add(newFeedback) models.db.session.commit() # Once it is safely stored in the DB, then go ahead and send off an email. return json.dumps({"status": "success"})
def volunteer_add_feedback(resume_id): resume_requested = models.Resume.objects().with_id(resume_id) if request.method == "POST" and resume_requested.lock is False: try: # Tells the feedback display page that the feedback was freshly created and saved. state = "saved" created = datetime.now() current_resume = models.Resume.objects().with_id(resume_id) feedback = models.Feedback() feedback.last_updated = created feedback.first_section = models._Section() feedback.second_section = models._Section() feedback.third_section = models._Section() feedback.fourth_section = models._Section() feedback.fifth_section = models._Section() feedback.resume = current_resume feedback.first_section.name = CONSTANTS.FIRST_SECTION feedback.first_section.rating = request.form.get('rating_1') feedback.first_section.content = request.form.get('content_1') feedback.second_section.name = CONSTANTS.SECOND_SECTION feedback.second_section.rating = request.form.get('rating_2') feedback.second_section.content = request.form.get('content_2') feedback.third_section.name = CONSTANTS.THIRD_SECTION feedback.third_section.rating = request.form.get('rating_3') feedback.third_section.content = request.form.get('content_3') feedback.fourth_section.name = CONSTANTS.FOURTH_SECTION feedback.fourth_section.rating = request.form.get('rating_4') feedback.fourth_section.content = request.form.get('content_4') feedback.fifth_section.name = CONSTANTS.FIFTH_SECTION feedback.fifth_section.rating = request.form.get('rating_5') feedback.fifth_section.content = request.form.get('content_5') feedback.validate() feedback.resume.update(lock=True) # associate feedback to resume owner feedback.user = feedback.resume.user # associate it to volunteer volunteer = models.User.objects.with_id(current_user.id) feedback.volunteer = volunteer feedback.save() # push feedback onto resume feedback_list reference list models.Resume.objects(id=resume_id).update_one( push__feedback_list=feedback) current_resume.save() return redirect('/feedback/%s/%s/%s' % (feedback.resume.id, feedback.id, state)) except ValidationError as e: print "Error:", e flash('Remplir tous les champs') template_data = { 'title': 'Donner feedback', 'content': None, 'resume': models.Resume.objects().with_id(resume_id) } return render_template('feedback/edit.html', **template_data) elif resume_requested.lock is True: return render_template('404.html') else: template_data = { 'title': 'Donner Feedback', 'content': None, 'resume': models.Resume.objects().with_id(resume_id) } return render_template('feedback/edit.html', **template_data)