本文整理汇总了Python中models.Feedback.save方法的典型用法代码示例。如果您正苦于以下问题:Python Feedback.save方法的具体用法?Python Feedback.save怎么用?Python Feedback.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feedback
的用法示例。
在下文中一共展示了Feedback.save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: contact
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def contact(request):
if request.method == 'POST':
c={}
form = ContactForm(request.POST)
if form.is_valid():
feedback = Feedback()
try:
feedback.name = form.cleaned_data["con_name"]
feedback.email = form.cleaned_data["con_emailid"]
try:
feedback.mobile = str(form.cleaned_data["con_mobile"])
except:
feedback.mobile = ""
#if feedback.mobile is None:
# feedback.mobile = 0
feedback.value = form.cleaned_data["con_text"]
feedback.save()
c.update({"success":True})
except:
print sys.exc_info()[1]
return HttpResponse('Error in sending feedback'+str(vars(feedback))+str(sys.exc_info()[0]))
c.update(csrf(request))
return render_to_response('contact.html',c)
else:
c={}
c.update({"form":form})
c.update(csrf(request))
return render_to_response('contact.html',c)
c={}
c.update(csrf(request))
return render_to_response('contact.html',c)
示例2: feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def feedback(request):
_user = request.user
notes = request.POST.get("notes", None)
if not notes:
return Jsonify({"status":False, "error":1101, "error_message":"信息不足, 请重新输入。"})
fdback = Feedback(notes=notes, user_id=_user['uid'], state=0)
fdback.save()
return Jsonify({"status":True, "feedback":model_to_dict(fdback), "error":"", "error_message":""})
示例3: post
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def post(self, request):
form = self.form
if form.is_valid():
feedback = Feedback(message=form.cleaned_data["message"][:2000])
feedback.save()
return render_to_response("feedback_thanks.html", locals(), context_instance=RequestContext(request))
else:
return HttpResponseBadRequest("Invalid form")
示例4: feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def feedback():
feed = request.form['feedback']
user = request.form['user']
field = request.form['field']
senti = sentiment(feed)
u = Feedback(user=user, feed=feed, field=field, rating=senti)
u.save()
return json.dumps([{'status': 'done'}])
示例5: feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def feedback(request, result_id):
try:
rate_text = request.POST['rate-text']
rate_score = request.POST['score']
result = Result.objects.get(pk=result_id)
feedback = Feedback(rating=rate_score, text=rate_text, result=result)
feedback.save()
# TODO arikg: handle smaller exception
except Exception:
return redirect('/result/%s/' % result_id, {
'error_message': "Please fill in the rating and text",
})
return redirect('/thanks')
示例6: post
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def post(self, request):
form = self.form
if form.is_valid():
base_template = BASE_TEMPLATE
feedback = Feedback(
message=form.cleaned_data['message'][:2000],
url=form.cleaned_data['referrer'])
feedback.save()
return render_to_response(
"feedback_thanks.html",
locals(),
context_instance=RequestContext(request))
else:
return HttpResponseBadRequest("Invalid form")
示例7: feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def feedback(req):
if req.method == 'GET':
p = {'excellian': req.user.get_profile(), 'is_feedback': True,
'feedback': Feedback.objects.all().order_by('-message_date')}
p.update(csrf(req))
return render_to_response(TEMPLATE_PATH + "feedback.html", p,
context_instance=RequestContext(req))
elif req.method == 'POST':
feedback = Feedback()
feedback.excellian = req.user.get_profile()
feedback.message = req.POST.get('message', '').strip()
feedback.slug = _slugit(Feedback, feedback.message)
if feedback.message == '':
return _jsonResponse('Please enter a feedback message.')
feedback.save()
messages.add_message(req, messages.INFO, 'Feedback received. Thanks!')
return _jsonResponse({'redirect': '/feedback/'})
示例8: post_feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [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})
示例9: add
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [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)
)
示例10: feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def feedback(request):
if request.method == 'POST':
form = FeedbackForm(request.POST)
if form.is_valid():
data = Feedback(name=form.cleaned_data['name'], email=form.cleaned_data['email'], comment=form.cleaned_data['comment'])
data.save()
message = "Thanks for the feedback"
context = {'form':FeedbackForm(), 'message':message, 'count':request.session.get('count',0)}
return render(request, 'feedback/feedback.html', context)
else:
# If data is not valid, reload page with error
message = "Oops! Something went wrong!"
context = {'form':FeedbackForm(), 'message':message, 'count':request.session.get('count',0)}
return render(request, 'feedback/feedback.html', context)
else:
context = {'form':FeedbackForm(), 'count':request.session.get('count',0)}
return render(request, 'feedback/feedback.html', context)
示例11: render_feedback
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def render_feedback(request):
# get system status
systemStatus = SystemStatus()
systemStatus.get()
c = RequestContext(request, {"version": systemStatus.version, "is_message": False, "feedback": True})
c.update(csrf(request))
# save bug/feature in session if "Save" clicked
if request.method == "POST":
if "add" in request.POST:
issue = Feedback()
issue.type = request.POST["type"]
issue.description = request.POST["description"]
issue.status = "pending"
issue.save()
c.update({"is_message": True})
# get all bugs and features
bug_list = Feedback.objects.filter(type = "bug").order_by("-status")
feature_list = Feedback.objects.filter(type = "feature").order_by("-status")
c.update({"bug_list": bug_list, "feature_list": feature_list})
return render_to_response("feedback.html", c)
示例12: add
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [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)
)
示例13: response_msg
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import save [as 别名]
def response_msg(request):
raw_str = smart_str(request.raw_post_data)
print raw_str
msg = parse_xml(ET.fromstring(raw_str))
msg_type = msg.get('MsgType', '')
from_user_name = msg.get('FromUserName')
to_user_name = msg.get('ToUserName')
content = ''
print('MsgType ' + msg_type)
if msg_type == 'event':
event_type = msg.get('Event', '')
print('new event: ' + event_type)
if event_type == 'subscribe':
content = '欢迎关注要记账\n1.创建账本\n2.增加记录\n3.查询\n4.导出账单\n5.帮助\n6.删除账号并清空数据\n7.反馈'
return get_reply_xml(from_user_name, to_user_name, content)
elif msg_type == 'text':
content = msg.get('Content', '')
print('content: ' + content)
if mc.get(from_user_name + 'del') == '22':
if content == 'c' or content == 'C':
record_stamp = mc.get(from_user_name + 'ds')
u1 = User.objects.get(user=from_user_name)
pb = PayBooks.objects.filter(user=u1, stamp=record_stamp)
pb[0].delete()
content = '撤销成功'
return get_reply_xml(from_user_name, to_user_name, content)
# if op_sql.revoke_insert(from_user_name):
# content = '撤销成功'
# else:
# content = '撤销失败'
# mc.delete(from_user_name + 'del')
# return reply_server(from_user_name, to_user_name, content)
if mc.get(from_user_name) == '1':
print(mc.get(from_user_name) + ' name')
u1 = User.objects.filter(user=from_user_name)
if len(u1) == 0:
print('create user but not exist')
u1 = User(user=from_user_name, pwd=content)
u1.save()
content = '创建成功,此密码可以用来提取账单,如果你不幸忘记密码,请在反馈中联系[要记账]'
mc.delete(from_user_name)
else:
print('create user failed exist')
content = '创建失败,用户已经创建过密码'
mc.delete(from_user_name)
return get_reply_xml(from_user_name, to_user_name, content)
# if op_sql.create(from_user_name, content):
# content = '创建成功,此密码未来可以提取账单到电脑'
# logging.debug(content + ' enter if op_sql')
# mc.delete(from_user_name)
# else:
# content = '创建失败,用户已经创建过密码'
# mc.delete(from_user_name)
elif mc.get(from_user_name) == '2':
print(mc.get(from_user_name) + ' enter 2 content' + content)
#logging.debug('show content : ' + content)
tmp = content.split(' ')
if not is_number(tmp[0]):
content = '输入有误\n!格式不正确\n!金额不能为负数\n!用空格分隔\n请重新输入'
return get_reply_xml(from_user_name, to_user_name, content)
if len(tmp) == 2 and float(tmp[0]) > 0:
user_tmp = User.objects.filter(user=from_user_name)
if len(user_tmp) != 0:
record_time = time.strftime('%m%d%H%M%S')
pb = PayBooks(user=user_tmp[0],
money=tmp[0],
month=time.strftime('%m'),
year=time.strftime('%Y'),
remark=tmp[1],
stamp=record_time
)
pb.save()
content = '数据记录成功\n在3分钟内回复c\n可以撤销刚才数据'
mc.delete(from_user_name)
mc.set(from_user_name + 'ds', record_time, 300)
# if user want to revoke the previous opration
mc.set(from_user_name + 'del', '22', 180)
else:
print('insert error money format')
content = '数据记录失败,格式不对吧?还是没创建账户?'
mc.delete(from_user_name)
# if op_sql.insert(from_user_name, tmp[0], tmp[1]):
# logging.debug('insert enter')
# content = '数据记录成功\n在3分钟内回复c\n可以撤销刚才数据'
# mc.delete(from_user_name)
# # if user want to revoke the previous opration
# mc.set(from_user_name + 'del', '22', 180)
# else:
# logging.debug('insert error money')
# content = '数据记录失败,格式不对吧?还是没创建账户?'
# mc.delete(from_user_name)
else:
content = '输入有误\n!格式不正确\n!金额不能为负数\n!用空格分隔\n请重新输入'
return get_reply_xml(from_user_name, to_user_name, content)
elif mc.get(from_user_name) == '3':
'''高级查询
#.........这里部分代码省略.........