コード例 #1
0
def student_apply_leave_save(request):
    if request.method == 'POST':
        leave_date = request.POST.get('leave_date')
        leave_msg = request.POST.get('leave_reason')
        student_obj = Students.objects.get(admin=request.user.id)
        leave_report = LeaveReportStudent(student_id=student_obj,
                                          leave_date=leave_date,
                                          leave_message=leave_msg,
                                          leave_status=0)
        leave_report.save()
        messages.success(request, 'Successfully Applied for Leave')
        return HttpResponseRedirect(reverse('student_apply_leave'))
    else:
        messages.error(request, 'Failed Applied for Leave')

        return HttpResponseRedirect(reverse('student_apply_leave'))
コード例 #2
0
def student_apply_leave_save(request):
    if request.method!="POST":
        return HttpResponseRedirect(reverse("student_apply_leave"))
    else:
        leave_date=request.POST.get("leave_date")
        leave_msg=request.POST.get("leave_msg")

        student_obj=Students.objects.get(admin=request.user.id)
        try:
            leave_report=LeaveReportStudent(student_id=student_obj,leave_date=leave_date,leave_message=leave_msg,leave_status=0)
            leave_report.save()
            messages.success(request, "Successfully Applied for Leave")
            return HttpResponseRedirect(reverse("student_apply_leave"))
        except:
            messages.error(request, "Failed To Apply for Leave")
            return HttpResponseRedirect(reverse("student_apply_leave"))
コード例 #3
0
def student_apply_leave_save(request):
    if request.method != "POST":
        messages.error(request, "Invalid Method")
        return redirect('student_apply_leave')
    else:
        leave_date = request.POST.get('leave_date')
        leave_message = request.POST.get('leave_message')

        student_obj = Students.objects.get(admin=request.user.id)
        try:
            leave_report = LeaveReportStudent(student_id=student_obj, leave_date=leave_date, leave_message=leave_message, leave_status=0)
            leave_report.save()
            messages.success(request, "Applied for Leave.")
            return redirect('student_apply_leave')
        except:
            messages.error(request, "Failed to Apply Leave")
            return redirect('student_apply_leave')
コード例 #4
0
def student_apply_leave_save(request):
    if request.method != "POST":
        messages.error(request, "Invalid Method")
        return redirect('student_apply_leave')
    else:
        leave_date = request.POST.get('leave_date')
        leave_message = request.POST.get('leave_message')

    if leave_message and leave_date:
        student_obj = Students.objects.get(admin=request.user.id)
        try:
            leave_report = LeaveReportStudent(student_id=student_obj, leave_date=leave_date, leave_message=leave_message, leave_status=0)
            leave_report.save()
            messages.success(request, "Tərk Etmə Üçün Müraciət Edildi.")
            return redirect('student_apply_leave')
        except:
            messages.error(request, "Tərk Etmə Üçün Müraciət Edərkən Xəta Baş Verdi")
            return redirect('student_apply_leave')
    messages.error(request, "Tərk Etmə Tarixini Və (ya) Səbəbini Boş Qoya Bilməzsiniz!")
    return redirect('student_apply_leave')