Example #1
0
def view_student(request, x, y, z):
    if not Student.objects.filter(id=x):
        d = {'fof': True}
        return render(request, 'message.html', d)

    d = get_teach_details(request)
    student_id = x
    id_card = get_idcard_details(student_id)
    if id_card:
        d.update(id_card)
    univ_details = get_univ_details(student_id)
    gen_details = get_general_details(student_id)
    if gen_details and univ_details:
        d['gen_details'] = True
        d.update(gen_details)
        d.update(univ_details)
        d['dob'] = str(d['dob'])
    extra_curr_details = extra_curricular(student_id)
    if extra_curr_details:
        d['ext_acts'] = True
        d.update(extra_curr_details)

    d['gen_edit'] = True

    d['no_sem'] = False
    d['lat_sems'] = (1, 2)  # constant
    # call a function here that gives available sems
    d['available'], d['not_available'], d['invalid_sems'] = get_sem_details_for(
        student_id)

    return render(request, 'teachers/student_view.html', d)
Example #2
0
def profile(request):
    details = get_page_details(request.user.username)
    details.update(get_idcard_details(request.user.username))
    details.update(get_univ_details(request.user.username))
    details['email'] = Student.objects.get(id=request.user.username).email
    details['mob_no'] = Details.objects.get(
        card_no=request.user.username).mobile_no
    return render(request, 'students/student_profile.html', details)
Example #3
0
def student_report(request):
    if Student.objects.filter(id=request.user.username):
        title = "404"
        error = ['Students cannot view this page!']
        return message(title, error, request)

    if request.method == "POST":
        student_id = request.POST.get('student_id', '')
        mentor_id = request.user.username

        sems_all_object = semester_1.objects.filter(student_id=student_id)
        length = len(sems_all_object)
        std = Student.objects.filter(id=student_id)

        sem1 = semester_1.objects.filter(student_id=student_id)
        sem2 = semester_2.objects.filter(student_id=student_id)
        sem3 = semester_3.objects.filter(student_id=student_id)
        sem4 = semester_4.objects.filter(student_id=student_id)
        sem5 = semester_5.objects.filter(student_id=student_id)
        sem6 = semester_6.objects.filter(student_id=student_id)
        sem7 = semester_7.objects.filter(student_id=student_id)
        sem8 = semester_8.objects.filter(student_id=student_id)
        total_table = total.objects.filter(student_id=student_id)

        # sem1_list=sem1.values()
        # to check wether the student in new or not
        total_marks = 0
        certificate = ''
        for i in total_table:
            total_marks = i.total

        for cert in std:
            certificate = cert.has_certificate
        new_entry = 0
        if len(sem1) == 0:
            p1 = semester_1.objects.create(student_id=student_id)
        if len(sem2) == 0:
            p2 = semester_2.objects.create(student_id=student_id)
        if len(sem3) == 0:
            p3 = semester_3.objects.create(student_id=student_id)
        if len(sem4) == 0:
            p4 = semester_4.objects.create(student_id=student_id)
        if len(sem5) == 0:
            p5 = semester_5.objects.create(student_id=student_id)
        if len(sem6) == 0:
            p6 = semester_6.objects.create(student_id=student_id)
        if len(sem7) == 0:
            p7 = semester_7.objects.create(student_id=student_id)
        if len(sem8) == 0:
            p8 = semester_8.objects.create(student_id=student_id)
        if len(total_table) == 0:
            p_total = total.objects.create(student_id=student_id)
            new_entry = 1
        details = get_idcard_details(student_id)
        d = get_teach_details(request)
        a = {
            'certificate': certificate,
            'total_marks': int(total_marks),
            'info_student': std,
            'mentor': mentor_id,
            'check': "0",
            'sem1': sem1,
            'sem2': sem2,
            'sem3': sem3,
            'sem4': sem4,
            'sem5': sem5,
            'sem6': sem6,
            'sem7': sem7,
            'sem8': sem8,
            'total': total_table,
            'new_entry': new_entry,
        }
        a.update(details)
        a.update(d)
        return render(request, 'makaut/student_view.html', a)
    else:  # GET request redirects
        return mentees(request)
Example #4
0
def general_details(request):
    # if a teacher comes here, well show the way out to them!
    if Teacher.objects.filter(id=request.user.username):
        title = "404"
        error = ['Teachers cannot view this page!']
        return message(title, error, request)

    details = get_idcard_details(request.user.username)
    if not details:
        error = ["Error getting student details"]

    if request.method == "POST":
        error = ""
        filled_forms = FormFills.objects.get(student=request.user.username)
        if filled_forms.is_gen_details_filled:
            error = ["Can't Overwrite existing data!"]
        else:
            stud = Student.objects.get(id=request.user.username)
            dob = request.POST['dob'].strip()
            blood_type = request.POST['blood_type'].strip()
            # HOUSE DETAILS
            guard = request.POST['guard'].strip()
            perm_add = request.POST['perm_add'].strip()
            loc_guard = request.POST['loc_guard'].strip()
            loc_add = request.POST['loc_add'].strip()
            # CONTACT NOs
            land_phone = request.POST['land_phone'].strip()
            g_mob_no = request.POST['g_mob_no'].strip()
            mob_no = request.POST['mob_no'].strip()
            # SCHOOL DETAILS
            # Class 10
            sc10_name = request.POST['sc10_name'].strip()
            sc10_med = request.POST['sc10_med'].strip()
            sc10_marks = request.POST['sc10_score'].strip()
            sc10_year = request.POST['sc10_year'].strip()
            sc10_add = request.POST['sc10_add'].strip()
            # Class 12
            sc12_name = request.POST['sc12_name'].strip()
            sc12_med = request.POST['sc12_med'].strip()
            sc12_marks = request.POST['sc12_score'].strip()
            sc12_year = request.POST['sc12_year'].strip()
            sc12_add = request.POST['sc12_add'].strip()
            # DIPLOMA SCORE
            if stud.is_lateral:
                dip_score = request.POST['dip_score'].strip()
            else:
                dip_score = -1

            if '' in [
                    dob, blood_type, guard, perm_add, g_mob_no, mob_no,
                    sc10_name, sc10_med, sc10_marks, sc10_year, sc10_add,
                    sc12_name, sc12_med, sc12_marks, sc12_year, sc12_add,
                    dip_score
            ]:
                error = ["All Compulsory Fields must be filled!"]

            # land phone no verification
            if len(land_phone) != 0:
                try:
                    land_phone = int(land_phone)
                    if len(str(land_phone)) > 11:
                        error = ["Land phone number too long!"]
                    elif len(str(land_phone)) == 8:
                        error = [
                            "Please provide STD code for Land phone.",
                            "example: 03322222222"
                        ]
                    elif len(str(land_phone)) < 8:
                        error = ["Land phone number too short!"]
                except ValueError:
                    error = ["land phone number can't contain characters!"]
            else:
                land_phone = None

            # mobile no verification
            try:
                g_mob_no = int(g_mob_no)
                mob_no = int(mob_no)
                if len(str(mob_no)) != 10 or len(str(g_mob_no)) != 10:
                    error = ["Mobile Number must be equal to 10 digits!"]
            except ValueError:
                error = [
                    "Mobile phone number can't contain characters!",
                    "Tip: No need for country code: (eg. +91 in India)"
                ]
            try:
                if int(sc12_year) - int(sc10_year) < 2:
                    error = [
                        "How did you pass class 10 and 12 in less then 2 years? Magic??"
                    ]

                elif int(sc10_year) - int(dob.split('-')[0]) < 15:
                    error = [
                        "Your dob and class 10 passout year doesn't add up!",
                        'Got multiple promotions in middle school? Contact your Mentor!'
                    ]

                elif float(sc10_marks) > 100 or float(sc12_marks) > 100:
                    error = [
                        "How did you get more than 100 in boards? Good handwriting?"
                    ]

                elif float(sc10_marks) < 30 or float(sc12_marks) < 30:
                    error = [
                        "Well, your board marks are fishy! contact Mentor or reCheck!"
                    ]
            except:
                error = ["Well year, marks, etc cannot be alphabets"]

            if not error:
                stud = Student.objects.get(id=request.user.username)
                details = Details.objects.create(card_no=request.user.username,
                                                 dob=dob,
                                                 blood_grp=blood_type,
                                                 guardian=guard,
                                                 perm_add=perm_add,
                                                 loc_guardian=loc_guard,
                                                 loc_add=loc_add,
                                                 land_phone=land_phone,
                                                 guardian_mobile_no=g_mob_no,
                                                 mobile_no=mob_no)
                if stud.is_lateral:
                    details.diploma_score = dip_score
                    details.save()
                sc10 = Class10.objects.create(student=request.user.username,
                                              medium=sc10_med,
                                              school_name=sc10_name,
                                              passing_year=sc10_year,
                                              school_address=sc10_add,
                                              score=sc10_marks)
                sc12 = Class12.objects.create(student=request.user.username,
                                              medium=sc12_med,
                                              school_name=sc12_name,
                                              passing_year=sc12_year,
                                              school_address=sc12_add,
                                              score=sc12_marks)
                forms = FormFills.objects.get(student=request.user.username)
                forms.is_gen_details_filled = True
                forms.save()
                sc10.save()
                sc12.save()
                d = {
                    'title': "Form saved!",
                    'success': True,
                }
            else:
                d = {'title': "ERROR", 'messages': error, 'error': True}
            return render(request, 'message.html', d)

    # for GET request
    else:
        filled_forms = FormFills.objects.get(student=request.user.username)
        stud = Student.objects.get(id=request.user.username)
        details = {
            **get_idcard_details(request.user.username),
            **get_univ_details(request.user.username),
            **get_general_details(request.user.username),
        }
        details['title'] = 'Student Details'
        details['is_lateral'] = stud.is_lateral
        if filled_forms.is_gen_details_filled:
            details['filled'] = True
        else:
            details['filled'] = False
        return render(request, 'students/details.html/', details)