How to use the result.models.Student.objects.get function in result

To help you get started, we’ve selected a few result examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Abdoulrasheed / django-school-management / result / views.py View on Github external
def user_profile(request, id):
    """ Show profile of any selected user """
    if request.user.id == id:
        return redirect("/profile/")

    current_semester = Semester.objects.get(is_current_semester=True)
    user = User.objects.get(pk=id)
    if user.is_lecturer:
        courses = Course.objects.filter(allocated_course__lecturer__pk=id).filter(semester=current_semester)
        context = {
            "user": user,
            "courses": courses,
            }
        return render(request, 'account/user_profile.html', context)
    elif user.is_student:
        level = Student.objects.get(user__pk=id)
        courses = TakenCourse.objects.filter(student__user__id=id, course__level=level.level)
        context = {
            "user_type": "student",
            'courses': courses,
            'level': level,
            'user':user,
        }
        return render(request, 'account/user_profile.html', context)
    else:
        context = {
            "user": user,
            "user_type": "superuser"
            }
        return render(request, 'account/user_profile.html', context)
github Abdoulrasheed / django-school-management / result / views.py View on Github external
def course_registration(request):
    if request.method == 'POST':
        ids = ()
        data = request.POST.copy()
        data.pop('csrfmiddlewaretoken', None) # remove csrf_token
        for key in data.keys():
            ids = ids + (str(key),)
        for s in range(0,len(ids)):
            student = Student.objects.get(user__pk=request.user.id)
            course = Course.objects.get(pk=ids[s])
            obj = TakenCourse.objects.create(student=student, course=course)
            obj.save()
            messages.success(request, 'Courses Registered Successfully!')
        return redirect('course_registration')
    else:
        student = Student.objects.get(user__pk=request.user.id)
        taken_courses = TakenCourse.objects.filter(student__user__id=request.user.id)
        t = ()
        for i in taken_courses:
            t += (i.course.pk,)
        current_semester = Semester.objects.get(is_current_semester=True)
        courses = Course.objects.filter(level=student.level).exclude(id__in=t)
        all_courses = Course.objects.filter(level=student.level)

        no_course_is_registered = False # Check if no course is registered
github Abdoulrasheed / django-school-management / result / views.py View on Github external
def course_registration(request):
    if request.method == 'POST':
        ids = ()
        data = request.POST.copy()
        data.pop('csrfmiddlewaretoken', None) # remove csrf_token
        for key in data.keys():
            ids = ids + (str(key),)
        for s in range(0,len(ids)):
            student = Student.objects.get(user__pk=request.user.id)
            course = Course.objects.get(pk=ids[s])
            obj = TakenCourse.objects.create(student=student, course=course)
            obj.save()
            messages.success(request, 'Courses Registered Successfully!')
        return redirect('course_registration')
    else:
        student = Student.objects.get(user__pk=request.user.id)
        taken_courses = TakenCourse.objects.filter(student__user__id=request.user.id)
        t = ()
        for i in taken_courses:
            t += (i.course.pk,)
        current_semester = Semester.objects.get(is_current_semester=True)
        courses = Course.objects.filter(level=student.level).exclude(id__in=t)
        all_courses = Course.objects.filter(level=student.level)

        no_course_is_registered = False # Check if no course is registered
        all_courses_are_registered = False

        registered_courses = Course.objects.filter(level=student.level).filter(id__in=t)
        if registered_courses.count() == 0: # Check if number of registered courses is 0
        	no_course_is_registered = True

        if registered_courses.count() == all_courses.count():
github Abdoulrasheed / django-school-management / result / views.py View on Github external
semester.alignment = TA_LEFT
    semester.fontName = "Helvetica"
    semester.fontSize = 8
    semester.leading = 18
    semester_title = "<b>Total Units : " + str(second_semester_unit) + "</b>"
    semester_title = Paragraph(semester_title, semester)
    Story.append(semester_title)

    Story.append(Spacer(1, 2))
    style = getSampleStyleSheet()
    certification = style["Normal"]
    certification.alignment = TA_JUSTIFY
    certification.fontName = "Helvetica"
    certification.fontSize = 8
    certification.leading = 18
    student = Student.objects.get(user__pk=request.user.id)
    certification_text = "CERTIFICATION OF REGISTRATION: I certify that <b>" + str(request.user.get_full_name().upper()) + "</b>\
    has been duly registered for the <b>" + student.level + " level </b> of study in the department\
    of INFORMATION MANAGEMENT TECHNOLOGY and that the courses and units registered are as approved by the senate of the University"
    certification_text = Paragraph(certification_text, certification)
    Story.append(certification_text)

    # FIRST SEMESTER ENDS HERE

    logo = MEDIA_ROOT + "/logo/android-chrome-144x144.png"
    im = Image(logo, 1.5*inch, 1.5*inch)
    im.__setattr__("_offs_x", -228)
    im.__setattr__("_offs_y", 625)
    Story.append(im)

    picture =  BASE_DIR + request.user.get_picture()
    im = Image(picture, 1.0*inch, 1.0*inch)
github Abdoulrasheed / django-school-management / result / views.py View on Github external
def view_result(request):
    student = Student.objects.get(user__pk=request.user.id)
    current_semester = Semester.objects.get(is_current_semester=True)
    courses = TakenCourse.objects.filter(student__user__pk=request.user.id, course__level=student.level)
    result = Result.objects.filter(student__user__pk=request.user.id)
    current_semester_grades = {}

    previousCGPA = 0
    previousLEVEL = 0

    for i in result:
        if not int(i.level) - 100 == 0: # TODO think n check the logic
            previousLEVEL = i.level
            try:
                a = Result.objects.get(student__user__pk=request.user.id, level=previousLEVEL, semester="Second")
                previousCGPA = a.cgpa
                break
            except:
github Abdoulrasheed / django-school-management / result / views.py View on Github external
def profile(request):
    """ Show profile of any user that fire out the request """
    current_semester = Semester.objects.get(is_current_semester=True)
    if request.user.is_lecturer:
        courses = Course.objects.filter(allocated_course__lecturer__pk=request.user.id).filter(semester=current_semester)
        return render(request, 'account/profile.html', {"courses": courses,})
    elif request.user.is_student:
        level = Student.objects.get(user__pk=request.user.id)
        courses = TakenCourse.objects.filter(student__user__id=request.user.id, course__level=level.level)
        context = {
        'courses': courses,
        'level': level,
        }
        return render(request, 'account/profile.html', context)
    else:
        staff = User.objects.filter(is_lecturer=True)
        return render(request, 'account/profile.html', { "staff": staff })
github Abdoulrasheed / django-school-management / result / views.py View on Github external
style = getSampleStyleSheet()
    Story.append(Spacer(1,0.1*inch))
    department = style["Normal"]
    department.alignment = TA_CENTER
    department.fontName = "Helvetica"
    department.fontSize = 9
    department.leading = 18
    department_title = "<b>DEPARTMENT OF INFORMATION MANAGEMENT TECHNOLOGY</b>"
    department_title = Paragraph(department_title, department)
    Story.append(department_title)
    Story.append(Spacer(1,.3*inch))
    
    title = "<b><u>STUDENT REGISTRATION FORM</u></b>"
    title = Paragraph(title.upper(), normal)
    Story.append(title)
    student = Student.objects.get(user__pk=request.user.id)

    style_right = ParagraphStyle(name='right', parent=styles['Normal'])
    tbl_data = [
        [Paragraph("<b>Registration Number : " + request.user.username.upper() + "</b>", styles["Normal"])],
        [Paragraph("<b>Name : " + request.user.get_full_name().upper() + "</b>", styles["Normal"])],
        [Paragraph("<b>Session : " + current_session.session.upper() + "</b>", styles["Normal"]), Paragraph("<b>Level: " + student.level + "</b>", styles["Normal"])
        ]]
    tbl = Table(tbl_data)
    Story.append(tbl)
    Story.append(Spacer(1, 0.6*inch))

    style = getSampleStyleSheet()
    semester = style["Normal"]
    semester.alignment = TA_LEFT
    semester.fontName = "Helvetica"
    semester.fontSize = 9
github Abdoulrasheed / django-school-management / result / views.py View on Github external
def course_drop(request):
    if request.method == 'POST':
        ids = ()
        data = request.POST.copy()
        data.pop('csrfmiddlewaretoken', None) # remove csrf_token
        for key in data.keys():
            ids = ids + (str(key),)
        for s in range(0,len(ids)):
            student = Student.objects.get(user__pk=request.user.id)
            course = Course.objects.get(pk=ids[s])
            obj = TakenCourse.objects.get(student=student, course=course)
            obj.delete()
            messages.success(request, 'Successfully Dropped!')
        return redirect('course_registration')