예제 #1
0
 def on_get(self, req, resp, sid):
     student = session.query(Student).filter_by(
         id=sid).first()  # Student.vratiStudenta(sid)
     if student:
         resp.status = HTTP_200
         # resp.body = json.dumps({'id': student.id, 'first_name': student.first_name,
         # 'last_name': student.last_name})
         dump = {
             'student': {
                 'id': student.id,
                 'first_name': student.first_name,
                 'last_name': student.last_name
             }
         }
         for p in student.predmeti:
             # ocena = session.query(Prijava).filter_by(student_id=student.id, predmet_id=p.id). \
             #     first().ocena
             prijava = session.query(Prijava).filter_by(
                 student_id=student.id,
                 predmet_id=p.id).order_by(Prijava.id.desc()).first()
             dump[p.id] = {
                 'course_name': p.naziv,
                 'year': p.godina,
                 'grade': prijava.ocena
             }
         resp.body = json.dumps(dump)
     else:
         resp.status = HTTP_401
예제 #2
0
 def on_get(self, req, resp, pid):
     predmet = session.query(Predmet).filter_by(id=pid).first()  # Student.vratiStudenta(sid)
     if predmet:
         resp.status = HTTP_200
         resp.body = json.dumps({'year': predmet.godina, 'course_name': predmet.naziv})
     else:
         resp.status = HTTP_401
예제 #3
0
    def on_get(self, req, resp):
        resp.status = HTTP_200  # This is the default status
        dump = {}
        for prijava in session.query(Prijava).all():
            dump[prijava.id] = {
                'student': {
                    'student_id': prijava.student_id,
                    'first_name': session.query(Student).filter_by(id=prijava.student_id).first().first_name,
                    'last_name': session.query(Student).filter_by(id=prijava.student_id).first().last_name
                },
                'course': {
                    'course_id': prijava.predmet_id,
                    'course_name': session.query(Predmet).filter_by(id=prijava.predmet_id).first().naziv,
                    'year': session.query(Predmet).filter_by(id=prijava.predmet_id).first().godina
                },
                'grade': prijava.ocena
            }

        resp.body = json.dumps(dump)
예제 #4
0
    def on_get(self, req, resp):
        resp.status = HTTP_200  # This is the default status
        dump = {}
        for std in session.query(Student).all():
            dump[std.id] = {
                'first_name': std.first_name,
                'last_name': std.last_name,
            }

        resp.body = json.dumps(dump)
예제 #5
0
    def on_get(self, req, resp):
        resp.status = HTTP_200  # This is the default status
        dump = {}
        i = 0
        for p in session.query(Predmet).all():
            dump[i] = {
                'year': p.godina,
                'course_name': p.naziv,
                'id': p.id
            }
            i += 1

        resp.body = json.dumps(dump)