示例#1
0
def get_student_by_lastname(last_name):
    temp = Student()
    temp.last_name = last_name
    queries = []
    query = Query()
    queries.append(query.last_name == last_name)
    query = reduce(lambda a, b: a & b, queries)
    student = student_db.get(query)
    return student
示例#2
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student
    student = Student.from_dict(student)
    if not subject:
        return student
def get_student_by_last_name(last_name):
    students = student_db.search(where('last_name') == last_name)

    if len(students) == 0:
        return 404, "Not found"
    student = Student.from_dict(students[0])

    return student
示例#4
0
def get_student_by_last_name(last_name):
    student = student_db.get(Query()['last_name'] == str(last_name))

    if not student:
        return student

    student = Student.from_dict(student)

    return student
def get_student_by_id_and_subject(student_id, subject):
    Q = Query()
    student = student_db.get((Q.student_id==student_id) & (Q.grades[subject]))
    # print('Find by id& subject', student_id, subject, student)
    if not student: 
        return student

    student = Student.from_dict(student)
    return student
示例#6
0
def get_student_by_last_name(last_name):
    query = Query()
    query = query.last_name == last_name
    try:
        res = student_db.search(query)[0]
    except:
        return None
    student = Student.from_dict(res)
    return student
示例#7
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student
    student = Student.from_dict(student)
    if subject == None:
        return student
    if subject in student.grades:
        return student
def get_student_by_last_name(last_name):
    #function for student add last name
    query = Query()
    student = student_db.get(query.last_name == last_name)
    print(student)
    if not student:
        return student
    student = Student.from_dict(student)
    return student
def get_student_by_last_name(last_name):
    Q = Query()
    student = student_db.get(Q.last_name==last_name)
    # print('by last name', last_name, student)
    if not student: 
        return student

    student = Student.from_dict(student)
    return student
示例#10
0
def get_student_by_id(student_id, subject):
    student = student_db.get(where('student_id')==student_id)
    # student = student_db.get(doc_id=int(student_id))  
    # print('Find by id', student_id, subject, student)
    if not student:
        return student
    student = Student.from_dict(student)
    if not subject:
        return student
示例#11
0
def get_student_by_last_name(last_name):
    User = Query()
    student = student_db.get(User.last_name == last_name)

    if not student:
        return "Not Found", 404

    student = Student.from_dict(student)
    return student, 200
示例#12
0
def get_student_by_last_name(last_name):

    S = Query()
    student = student_db.get(S.last_name == last_name)

    if not student:
        raise ValueError

    return Student.from_dict(student)
示例#13
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student
    student = Student.from_dict(student)
    if not subject:
        return student
    if subject not in student.grades:
        return 'student not found', 404
    return student
示例#14
0
def get_student_by_last_name(last_name):
    query = Query()
    students = student_db.search(query.last_name == last_name)
    if not students:
        return None
    student = students[0]
    if not student:
        return student
    student = Student.from_dict(student)
    return student
示例#15
0
def get_student(last_name):
    queries = []
    query = Query()
    #queries.append(query.last_name == last_name)
    #query = reduce(lambda a, b: a & b, queries)
    query = query.last_name == last_name
    res = student_db.search(query)
    if res:
        print(res, file=sys.stderr)
        return Student.from_dict(res[0])
示例#16
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return "Not Found", 404

    student = Student.from_dict(student)

    if not subject or subject in student.grades:
        return student, 200
    else:
        return 'Not found', 404
示例#17
0
def get_student_by_id(student_id, subject):
    if student_id == 666:
        return '666 is a bad number!', 400
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student
    student = Student.from_dict(student)
    if not subject:
        return student
    if subject in student.grades:
        return student
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student
    student = Student.from_dict(student)
    if not subject:
        return student
    elif student.grades.get(subject) is not None:
        return student
    else:
        return 'Not found', 404
示例#19
0
def get_student_by_last_name(last_name):
    query = Query()
    student = student_db.search(query.last_name == last_name)
    print(student, file=sys.stderr)

    if not student:
        return None

    if len(student) > 0:
        return Student.from_dict(student[0])

    return None
示例#20
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student

    student = Student.from_dict(student)
    if not subject:
        return student

    print(subject, file=sys.stderr)
    if subject in student.grades:
        return student
def get_student_by_id_and_subject(student_id, subject):
    #test 4 find student by subject and id
    student = student_db.get(doc_id=int(student_id))
    print(student)
    if not student:
        return student

    student = Student.from_dict(student)

    if subject in student.grades:
        return student
    else:
        return None
def get_student_by_id(student_id, subject):
    try:
        student = student_db.get(doc_id=int(student_id))
        print(student)
    except ValueError:
        return 'not found', 404
    if not student:
        raise ValueError
    student = Student.from_dict(student)

    if (subject and student.grades) and not subject in student.grades.keys():
        raise ValueError
    return student
示例#23
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        return student

    currentStudent = student
    student = Student.from_dict(student)
    if not subject:
        return student

    if subject not in currentStudent["grades"]:
        return 'subject not found in dictionary', 404

    return student
示例#24
0
def get_student_by_id(student_id, subject):

    student = student_db.get(doc_id=int(student_id))

    if not student:
        raise ValueError

    student = Student.from_dict(student)

    if not subject:
        return student
    elif subject in student.grades.keys():
        return student
    else:
        raise ValueError
示例#25
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))

    if not student:
        return student

    student = Student.from_dict(student)

    if (subject is not None) and (subject not in (student.grades.keys())):
        return 'Status code is 404', 404

    if not subject:
        return student

    return student
示例#26
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        print('student not found')
        return "student not found", 404
    student = Student.from_dict(student)
    if subject == None:
        print("no subject given")
        return student
    else:
        if not (student.grades[subject]):
            print("grade not found")
            return "grade not found", 404
        else:
            print("grade found")
            return student
示例#27
0
def get_student_by_id(student_id, subject):
    student = student_db.get(doc_id=int(student_id))
    if not student:
        print("GET: student is None")
        return student

    studentDict = student
    student = Student.from_dict(student)
    if not subject:
        print("GET: subject is None")
        return student

    if subject not in studentDict["grades"]:
        print("GET: subject not in student dictionary")
        return 'wrong subject', 404

    print("GET: last return statement")
    return student