Exemple #1
0
def home(clg, arnge):
    form = filterForm()
    db = models.students()
    college = db.showCollege()
    college_arr = [
        ('', 'Select College'),
    ]
    if request.method == "POST":
        if form.validate_on_submit():
            college_data = form.filter_college.data
            arrange_data = form.filter_arrange.data
            return redirect(
                url_for('home', clg=college_data, arnge=arrange_data))
        elif request.form["search"]:
            id = request.form["search"]
            return redirect(url_for('searched', id_number=id))
        elif not request.form["search"]:
            flash('Please Enter an I.D Number', 'danger')
            return redirect(url_for('land'))
    for item in college:
        college_arr.append((item[0], ("(" + item[0] + ")  " + item[1])))
    form.filter_college.choices = [item for item in college_arr]
    db = models.students(college=clg, filter=arnge)
    students = db.showAll()
    form.filter_college.data = clg
    form.filter_arrange.data = arnge
    return render_template('index.html', students=students, form=form)
Exemple #2
0
def deptByCollege(get_college):
    form = registerForm()

    if get_college != 'SGS':
        db = models.students(college=get_college)
        dept = db.showDept()
        form.register_department.choices = [(item[1]) for item in dept]

        deptArray = [{
            "college_code": "Choose...",
            "id": 0,
            "name": "Select Department",
            "name_value": ""
        }]
        for item in dept:
            deptObj = {}
            deptObj['id'] = item[0]
            deptObj['name_value'] = item[1]
            deptObj['name'] = item[1]
            deptObj['college_code'] = item[2]
            deptArray.append(deptObj)
        return jsonify({'department': deptArray})
    else:
        db = models.students(college=get_college)
        dept = db.showSGSdept()
        form.register_department.choices = [(item[1]) for item in dept]
        deptArray = [{
            "college_code": "Choose...",
            "id": 0,
            "name": "Select Department",
            "name_value": " "
        }]
        for item in dept:
            deptObj = {}
            deptObj['id'] = item[0]
            deptObj['name_value'] = item[1]
            deptObj['name'] = item[1]
            deptObj['college_code'] = item[2]
            deptArray.append(deptObj)
        return jsonify({'department': deptArray})
Exemple #3
0
def courseByDept(get_college, get_dept):
    form = registerForm()
    if get_college != 'SGS':
        db = models.students(dept=get_dept)
        course = db.showCourse()

        courseArray = [{
            "code": "",
            "college_code": "",
            "department": "Choose...",
            "name": "Select Course"
        }]
        for item in course:
            courseObj = {}
            courseObj['department'] = item[0]
            courseObj['code'] = item[1]
            courseObj['name'] = item[2]
            courseObj['college_code'] = item[4]
            courseArray.append(courseObj)
        return jsonify({'course': courseArray})
    else:
        db = models.students(dept=get_dept)
        course = db.showSGScourse()

        courseArray = [{
            "code": "",
            "college_code": "",
            "department": "Choose...",
            "name": "Select Course"
        }]
        for item in course:
            courseObj = {}
            courseObj['department'] = item[0]
            courseObj['code'] = item[1]
            courseObj['name'] = item[2]
            courseObj['college_code'] = item[4]
            courseArray.append(courseObj)
        return jsonify({'course': courseArray})
Exemple #4
0
def searched(id_number):
    if request.method == "POST":
        if request.form["search"]:
            id = request.form["search"]
            return redirect(url_for('searched', id_number=id))
        elif not request.form["search"]:
            flash('Please Enter an I.D Number', 'danger')
            return redirect(url_for('land'))
    student = models.students(id_number=id_number)
    students = student.search()
    try:
        return render_template('searched.html',
                               banner="Searched Student",
                               title='Search',
                               students=students)
    except Exception:
        flash('Sorry student not found', 'danger')
        return redirect(url_for('home', fltr='id'))