def student_feedback_save(request):
    if request.method == 'POST':
        feedack_msg = request.POST.get('feedback_msg')
        student_obj = Students.objects.get(admin=request.user.id)
        feedback = FeedBackStudent(student_id=student_obj,
                                   feedback=feedack_msg,
                                   feedback_reply='')
        feedback.save()
        messages.success(request, 'Successfully Sent Feedback')
        return HttpResponseRedirect(reverse('student_feedback'))
    else:
        messages.error(request, 'Failed Sent Feedback')
        return HttpResponseRedirect(reverse('student_feedback'))
def student_feedback_save(request):
    if request.method!="POST":
        return HttpResponseRedirect(reverse("student_feedback"))
    else:
        feedback_msg=request.POST.get("feedback_msg")

        student_obj=Students.objects.get(admin=request.user.id)
        try:
            feedback=FeedBackStudent(student_id=student_obj,feedback=feedback_msg,feedback_reply="")
            feedback.save()
            messages.success(request, "Successfully Sent Feedback")
            return HttpResponseRedirect(reverse("student_feedback"))
        except:
            messages.error(request, "Failed To Send Feedback")
            return HttpResponseRedirect(reverse("student_feedback"))
def student_feedback_save(request):
    if request.method != "POST":
        messages.error(request, "Invalid Method.")
        return redirect('student_feedback')
    else:
        feedback = request.POST.get('feedback_message')
        student_obj = Students.objects.get(admin=request.user.id)

        try:
            add_feedback = FeedBackStudent(student_id=student_obj, feedback=feedback, feedback_reply="")
            add_feedback.save()
            messages.success(request, "Feedback Sent.")
            return redirect('student_feedback')
        except:
            messages.error(request, "Failed to Send Feedback.")
            return redirect('student_feedback')
def student_feedback_save(request):
    if request.method != "POST":
        messages.error(request, "Invalid Method.")
        return redirect('student_feedback')
    else:
        feedback = request.POST.get('feedback_message')
        student_obj = Students.objects.get(admin=request.user.id)

    if feedback:

        try:
            add_feedback = FeedBackStudent(student_id=student_obj, feedback=feedback, feedback_reply="")
            add_feedback.save()
            messages.success(request, "Rəy Göndərildi.")
            return redirect('student_feedback')
        except:
            messages.error(request, "Rəy Göndərilərkən Xəta Baş Verdi.")
            return redirect('student_feedback')
    messages.error(request, "Rəy yazdığınızdan Əmin Olun!")
    return redirect('student_feedback')