Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     if not self.wrap_check_sign_result():
         return self.render_to_response(dict())
     content = request.POST.get('content')
     session = request.POST.get('session', None)
     user = WeUser.objects.filter(session=session)
     # if not user.exists():
     #     self.message = 'session 不存在或已过期'
     #     self.status_code = SW.ERROR_PERMISSION_DENIED
     #     return self.render_to_response({})
     # user = user[0]
     if content:
         is_advice = True if request.POST.get(
             'is_advice') == 'true' else False
         scene_id = request.POST.get("scene_id")
         form_id = request.POST.get('form_id', '')
         new_feedback = Feedback(content=content)
         new_feedback.form_id = form_id
         new_feedback.feed_type = 2 if is_advice else 1
         if user.exists():
             new_feedback.author = user[0]
         if scene_id:
             scenes = Scene.objects.filter(id=scene_id)
             if scenes.exists():
                 new_feedback.scene = scenes[0]
         new_feedback.save()
         return self.render_to_response({})
     self.message = '参数缺失'
     self.status_code = SW.ERROR_DATA
     return self.render_to_response({})
Ejemplo n.º 2
0
 def save(self):
     feedback = Feedback(text=self.cleaned_data['text'],
                         date=datetime.now(),
                         wealth=self.wealth)
     feedback.save()
     send_mail('New feedback!', feedback.text, SENDER_EMAIL,
               [FEEDBACK_EMAIL])
Ejemplo n.º 3
0
 def save(self):
   feedback = Feedback(
       text=self.cleaned_data['text'],
       date=datetime.now(),
       wealth=self.wealth)
   feedback.save()
   send_mail('New feedback!', feedback.text, SENDER_EMAIL, [FEEDBACK_EMAIL])
def add_feedback(request, product_id):
    if request.method == 'POST':
        feedback = Feedback(user=request.user,
                            text=request.POST.get("text"),
                            rate=int(request.POST.get("rate")),
                            datetime=datetime.now(),
                            product=BaseProduct.objects.get(id=product_id))
        feedback.save()
        if request.FILES:
            for photo in request.FILES.getlist("photos"):
                image = Image(image=photo)
                image.save()
                feedback.images.add(image)
            feedback.save()

    return HttpResponseRedirect(f"/product/{product_id}")
Ejemplo n.º 5
0
def feedback(request):
    if request.method=='POST':
        fm=FeedbackFrom(request.POST)
        if fm.is_valid():
            nm=fm.cleaned_data['name']
            tp=fm.cleaned_data['problem']
            mg=fm.cleaned_data['message']
            current_dt=timezone.now()
            reg=Feedback(name=nm,problem=tp,message=mg,datetime=current_dt)
            reg.save()
            messages.success(request,'Thank you for your valuable feedback, it will help us to improve your experience.')
        return redirect('home')
    else:
        fm=FeedbackFrom()
    
    context={
        'feedback_active':'active',
        'feedback_disabled':'disabled',
        'form':fm
        }
    return render(request,'core/feedback.html',context)