예제 #1
0
def add_subject_save(request):
    if request.method != "POST":
        return HttpResponse("<h2>Method Not Allowed</h2>")
    else:
        subject_name = request.POST.get("subject_name")
        course_id = request.POST.get("course")
        session_year_id = request.POST.get("session_year")
        course = Courses.objects.get(id=course_id)
        staff_id = request.POST.get("staff")
        staff = CustomUser.objects.get(id=staff_id)
        c_n = Courses.objects.filter(id=course_id)
        cor = []
        for c in c_n:
            cor.append(c.course_name)
        course_name = cor[0]

        try:

            subject = Subjects(subject_name=subject_name,
                               course_name=course_name,
                               course_id=course,
                               session_year_id_id=session_year_id,
                               staff_id=staff)
            subject.save()
            messages.success(request, "Successfully Added Subject")
            return HttpResponseRedirect(reverse("add_subject"))
        except:
            messages.error(request, "Failed to Add Subject {}")
            return HttpResponseRedirect(reverse("add_subject"))
def add_subject_save(request):
    if request.method != "POST":
        messages.error(request, "Method Not Allowed!")
        return redirect('add_subject')
    else:
        subject_name = request.POST.get('subject')
        subject_description = request.POST.get('subject')

        course_id = request.POST.get('course')
        course = Courses.objects.get(id=course_id)

        staff_id = request.POST.get('staff')
        staff = CustomUser.objects.get(id=staff_id)

        try:
            subject = Subjects(subject_name=subject_name,
                               subject_description=subject_description,
                               course_id=course,
                               staff_id=staff)
            subject.save()
            messages.success(request, "Subject Added Successfully!")
            return redirect('add_subject')
        except:
            messages.error(request, "Failed to Add Subject!")
            return redirect('add_subject')
예제 #3
0
def add_subject_save(request):
    if request.method != "POST":
        messages.error(request, "Method Not Allowed!")
        return redirect('add_subject')
    else:
        subject_name = request.POST.get('subject')
        try:
            subject = Subjects(subject_name=subject_name)
            subject.save()
            messages.success(request, "Subject Added Successfully!")
            return redirect('add_subject')
        except:
            messages.error(request, "Failed to Add Subject!")
            return redirect('add_subject')
예제 #4
0
def add_subject_save(request):
    if request.method != "POST":
        return render("<h2>Method not allowed</h2>")
    else:
        subject_name = request.POST.get("subject_name")
        staff_id = request.POST.get("staff")
        staff = CustomUser.objects.get(id=staff_id)
        if (not subject_name):
            messages.error(request, "Failed to Add Subject")
            return HttpResponseRedirect("/add_subject")
        else:
            subject = Subjects(subject_name=subject_name, staff_id=staff)
            subject.save()
            messages.success(request, "Successfully Added Subject")
            return HttpResponseRedirect("/add_subject")
예제 #5
0
def add_subject_save(request):
    if request.method != "POST":
        return HttpResponse("<h2>Method Not Allowed</h2>")
    else:
        subject_name = request.POST.get("subject_name")
        course_id = request.POST.get("course")
        course = Courses.objects.get(id=course_id)
        staff_id = request.POST.get("staff")
        staff = CustomUser.objects.get(id=staff_id)
        try:
            subject = Subjects(subject_name=subject_name, course_id=course, staff_id=staff)
            subject.save()
            messages.success(request, "Successfully Added Subject")
            return HttpResponseRedirect(reverse("add_subject"))
        except:
            messages.error(request, "Failed to Add Subject")
            return HttpResponseRedirect(reverse("add_subject"))
예제 #6
0
def add_subject_save(request):
    if request.method == 'POST':
        subject_name = request.POST.get('subject_name')
        course_id = request.POST.get('course')
        course = Courses.objects.get(id=course_id)

        staff_id = request.POST.get('staff')
        staff = CustomUser.objects.get(id=staff_id)

        subject = Subjects(subject_name=subject_name,
                           course_id=course,
                           staff_id=staff)
        subject.save()
        messages.success(request, 'Successfully Added Subject')
        return HttpResponseRedirect('/add_subject')
    else:
        messages.error(request, 'Failed to Add Subject')
        return HttpResponseRedirect('/add_subject')
def add_subject_save(request):
    if request.method != "POST":
        return HttpResponse("<h2>Method not Allowed</h2>")
    else:
        subject_name = request.POST.get("subject_name")
        course_id = request.POST.get("course")
        course = Courses.objects.get(id=course_id)
        staff_id = request.POST.get("staff")
        staff = CustomUser.objects.get(id=staff_id)

        try:
            subject = Subjects(subject_name=subject_name,
                               course_id=course,
                               staff_id=staff)
            subject.save()
            messages.success(request, "Subject Añadido Satisfactoriamente")
            return HttpResponseRedirect(reverse("add_subject"))
        except:
            messages.error(request, "Subject no se añadio")
            return HttpResponseRedirect(reverse("add_subject"))
예제 #8
0
def add_subject_save(request):
    if request.method != "POST":
        messages.error(request, "Method Not Allowed!")
        return redirect('add_subject')
    else:
        subject_name = request.POST.get('subject')
        price = request.POST.get('price')

        staff_id = request.POST.get('staff')
        staff = CustomUser.objects.get(id=staff_id)

        try:
            subject = Subjects(subject_name=subject_name,
                               price=price,
                               staff_id=staff)
            subject.save()
            messages.success(request, "Fənn Artırıdı!")
            return redirect('add_subject')
        except:
            messages.error(request, "Fənn Artırılarkən Xəta Baş Verdi!")
            return redirect('add_subject')
예제 #9
0
def add_subject_save(request):
    if request.method != "POST":
        messages.error(request, "Method Not Allowed!")
        return redirect('add_subject')
    else:
        subject_name = request.POST.get('subject')

        course_id = request.POST.get('course')
        course = Courses.objects.get(id=course_id)

        staff_id = request.POST.get('staff')
        staff = CustomUser.objects.get(id=staff_id)

        try:
            subject = Subjects(subject_name=subject_name,
                               course_id=course,
                               staff_id=staff)
            subject.save()
            messages.success(request, "تم إضافة الدرس بنجاح")
            return redirect('add_subject')
        except:
            messages.error(request, "فشل في إضافة الدرس")
            return redirect('add_subject')