def put(self, **kwargs):
        if "id" in kwargs:
            k = ndb.Key(res_dat.School, "Default")
            schl = res_dat.School.get_by_id(int(kwargs["id"]), parent=k)

        else:
            self.response.set_status(403, message="Must specify School id")
            return

        name = self.request.get("name")
        students = self.request.get("students")
        teachers = self.request.get("teachers")

        if name:
            chk = res_dat.School.query(res_dat.School.name == name).get()

            if chk is None:
                schl.name = name

            else:
                self.response.set_status(403, message="School name is already taken.")
                return

        if students:
            schl.students = int(students)

        if teachers:
            schl.teachers = int(teachers)

        schl.put()
        res_dat.showResponse(self, schl.to_dict())
예제 #2
0
    def put(self, **kwargs):
        k = ndb.Key(res_dat.School, 'Default')
        SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
        crs = res_dat.Course.get_by_id(int(kwargs['cid']), parent=SC.key)
        q = res_dat.Question.get_by_id(int(kwargs['id']), parent=crs.key)

        body = self.request.get('body')
        answer = self.request.get('answer')

        if answer:
            q.answer = answer

        if body:
            chk = res_dat.Question.query(res_dat.Question.body == body,
                                         ancestor=crs.key).get()

            if (chk is None):

                q.body = body

            else:

                self.response.set_status(403, message="Question exists")

        q.put()
        res_dat.showResponse(self, q.to_dict())
    def put(self, **kwargs):
        k = ndb.Key(res_dat.School, 'Default')
        SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
        teach = res_dat.Teacher.get_by_id(int(kwargs['id']), parent=SC.key)

        fname = self.request.get('fname')
        lname = self.request.get('lname')
        username = self.request.get('username')
        password = self.request.get('password')

        if fname:
            teach.fname = fname

        if lname:
            teach.lname = lname

        if password:
            teach.password = password

        if username:
            chk = res_dat.Teacher.query(
                res_dat.Teacher.username == username).get()

            if (chk is None):

                teach.username = username
                teach.put()

            else:

                self.response.set_status(403, message="Username taken")
                return

        res_dat.showResponse(self, teach.to_dict())
	def put(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		teach = res_dat.Teacher.get_by_id(int(kwargs['id']), parent=SC.key)

		fname = self.request.get('fname')
		lname = self.request.get('lname')
		username = self.request.get('username')
		password = self.request.get('password')

		if fname:
			teach.fname = fname

		if lname:
			teach.lname = lname

		if password:
			teach.password = password

		if username:
			chk=res_dat.Teacher.query(res_dat.Teacher.username==username).get()

			if (chk is None):

				teach.username = username
				teach.put()

			else:

				self.response.set_status(403, message="Username taken")
				return

		res_dat.showResponse(self, teach.to_dict())
	def put(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		crs = res_dat.Course.get_by_id(int(kwargs['cid']), parent=SC.key)
		q = res_dat.Question.get_by_id(int(kwargs['id']), parent=crs.key)

		body = self.request.get('body')
		answer = self.request.get('answer')

		if answer:
			q.answer = answer

		if body:
			chk=res_dat.Question.query(res_dat.Question.body==body, ancestor=crs.key).get()

			if (chk is None):

				q.body = body

			else:

				self.response.set_status(403, message="Question exists")

		q.put()
		res_dat.showResponse(self, q.to_dict())
	def put(self, **kwargs):
		if 'id' in kwargs:
			k = ndb.Key(res_dat.School, 'Default')
			schl = res_dat.School.get_by_id(int(kwargs['id']), parent=k)
		
		else:
			self.response.set_status(403, message="Must specify School id")
			return

		name = self.request.get('name')
		students = self.request.get('students')
		teachers = self.request.get('teachers')

		if name:
			chk = res_dat.School.query(res_dat.School.name==name).get()
	
			if (chk is None):
				schl.name = name

			else:
				self.response.set_status(403, message="School name is already taken.")
				return


		if students:
			schl.students = int(students)

		if teachers:
			schl.teachers = int(teachers)

		schl.put()
		res_dat.showResponse(self, schl.to_dict())
예제 #7
0
 def put(self, **kwargs):
     k = ndb.Key(res_dat.School, 'Default')
     SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
     crs = res_dat.Course.get_by_id(int(kwargs['cid']), parent=SC.key)
     stud = res_dat.Student.get_by_id(int(kwargs['id']), parent=SC.key)
     if crs not in stud.courses:
         stud.courses.append(crs.key)
         stud.put()
     res_dat.showResponse(self, stud.to_dict())
	def put(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		crs = res_dat.Course.get_by_id(int(kwargs['cid']), parent=SC.key)
		stud = res_dat.Student.get_by_id(int(kwargs['id']), parent=SC.key)
		if crs not in stud.courses:
			stud.courses.append(crs.key)
			stud.put()
		res_dat.showResponse(self, stud.to_dict())
예제 #9
0
 def get(self):
     curPage = self.request.url
     resources = {
         'school': curPage + 'school',
         'teacher': curPage + 'teacher',
         'student': curPage + 'student',
         'course': curPage + 'course',
         'question': curPage + 'question'
     }
     res_dat.showResponse(self, resources)
	def get(self, **kwargs):

		if 'id' in kwargs:
			k = ndb.Key(res_dat.School, 'Default')
			SC = res_dat.School.get_by_id(int(kwargs['id']), parent=k).to_dict()
			res_dat.showResponse(self, SC)		

		else:
			SCList = res_dat.School.query().fetch()
		
			res_dat.responseList(self, SCList)
    def get(self, **kwargs):

        if "id" in kwargs:
            k = ndb.Key(res_dat.School, "Default")
            SC = res_dat.School.get_by_id(int(kwargs["id"]), parent=k).to_dict()
            res_dat.showResponse(self, SC)

        else:
            SCList = res_dat.School.query().fetch()

            res_dat.responseList(self, SCList)
예제 #12
0
    def post(self, **kwargs):

        fname = self.request.get('fname')
        lname = self.request.get('lname')
        username = self.request.get('username')
        password = self.request.get('password')
        courses = self.request.get_all('courses')
        grade = self.request.get('grade')

        k = ndb.Key(res_dat.School, 'Default')
        SC = res_dat.School.get_by_id(int(kwargs['id']), parent=k)
        stud = res_dat.Student(parent=SC.key)

        if fname:
            stud.fname = fname

        else:
            self.response.set_status(401, message="fname required")

        if lname:
            stud.lname = lname

        else:
            self.response.set_status(401, message="fname required")

        if password:
            stud.password = password

        else:
            self.response.set_status(401, message="password required")

        if courses:
            stud.courses = courses

        if grade:
            stud.grade = grade

        if username:
            chk = res_dat.Student.query(
                res_dat.Student.username == username).get()

            if (chk is None):

                stud.username = username
                stud.put()
                res_dat.showResponse(self, stud.to_dict())

            else:

                self.response.set_status(403, message="Username taken")

        else:
            self.response.set_status(401, message="fname required")
	def post(self, **kwargs):

		fname = self.request.get('fname')
		lname = self.request.get('lname')
		username = self.request.get('username')
		password = self.request.get('password')
		courses = self.request.get_all('courses')
		grade = self.request.get('grade')

		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['id']), parent=k)
		stud = res_dat.Student(parent=SC.key)

		if fname:
			stud.fname = fname

		else:
			self.response.set_status(401, message="fname required")

		if lname:
			stud.lname = lname

		else:
			self.response.set_status(401, message="fname required")

		if password:
			stud.password = password

		else:
			self.response.set_status(401, message="password required")

		if courses:
			stud.courses = courses

		if grade:
			stud.grade = grade

		if username:
			chk=res_dat.Student.query(res_dat.Student.username==username).get()

			if (chk is None):

				stud.username = username
				stud.put()
				res_dat.showResponse(self, stud.to_dict())

			else:

				self.response.set_status(403, message="Username taken")

		else:
			self.response.set_status(401, message="fname required")
	def put(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		crs = res_dat.Course.get_by_id(int(kwargs['id']), parent=SC.key)

		name = self.request.get('name')

		if name:
			chk = res_dat.Course.query(res_dat.Course.name==name, ancestor=SC.key).get()
	
			if (chk is None):
				crs.name = name
				crs.put()
				res_dat.showResponse(self, crs.to_dict())


			else:
				self.response.set_status(403, message="School name is already taken.")
				return
    def post(self):

        sname = self.request.get("name")

        if not sname:
            self.response.set_status(400, message="name required")
            return

        chk = res_dat.School.query(res_dat.School.name == sname).get()

        if chk is None:

            k = ndb.Key(res_dat.School, "Default")
            schl = res_dat.School(parent=k)
            schl.name = sname
            schl.put()
            res_dat.showResponse(self, schl.to_dict())

        else:

            self.response.set_status(403, message="School name is already taken.")
	def post(self):
	
		sname = self.request.get('name')

		if not sname:
			self.response.set_status(400, message="name required")
			return

		chk = res_dat.School.query(res_dat.School.name==sname).get()
	
		if (chk is None):
		
			k = ndb.Key(res_dat.School, 'Default')
			schl = res_dat.School(parent=k)
			schl.name = sname
			schl.put()
			res_dat.showResponse(self, schl.to_dict())

		else:
	
			self.response.set_status(403, message="School name is already taken.")
	def post(self, **kwargs):

		name = self.request.get('name')

		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['id']), parent=k)
		crs = res_dat.Course(parent=SC.key)

		if name:
			chk=res_dat.Course.query(res_dat.Course.name==name, ancestor=SC.key).get()

			if (chk is None):

				crs.name = name
				crs.put()
				res_dat.showResponse(self, crs.to_dict())

			else:

				self.response.set_status(403, message="Username taken")

		else:
			self.response.set_status(401, message="fname required")
	def get(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		crs = res_dat.Course.get_by_id(int(kwargs['cid']), parent=SC.key)
		q = res_dat.Question.get_by_id(int(kwargs['id']), parent=crs.key)
		res_dat.showResponse(self, q.to_dict())
	def get(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		stud = res_dat.Student.get_by_id(int(kwargs['id']), parent=SC.key)
		res_dat.showResponse(self, stud.to_dict())
	def get(self, **kwargs):
		k = ndb.Key(res_dat.School, 'Default')
		SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
		teach = res_dat.Teacher.get_by_id(int(kwargs['id']), parent=SC.key)
		res_dat.showResponse(self, teach.to_dict())
예제 #21
0
 def get(self, **kwargs):
     k = ndb.Key(res_dat.School, 'Default')
     SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
     stud = res_dat.Student.get_by_id(int(kwargs['id']), parent=SC.key)
     res_dat.showResponse(self, stud.to_dict())
	def get(self):
		curPage = self.request.url
		resources = {'school': curPage + 'school', 'teacher': curPage + 'teacher', 'student': curPage + 'student', 'course': curPage + 'course', 'question': curPage + 'question'}
		res_dat.showResponse(self, resources)
예제 #23
0
 def get(self, **kwargs):
     k = ndb.Key(res_dat.School, 'Default')
     SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
     crs = res_dat.Course.get_by_id(int(kwargs['cid']), parent=SC.key)
     q = res_dat.Question.get_by_id(int(kwargs['id']), parent=crs.key)
     res_dat.showResponse(self, q.to_dict())
 def get(self, **kwargs):
     k = ndb.Key(res_dat.School, 'Default')
     SC = res_dat.School.get_by_id(int(kwargs['sid']), parent=k)
     teach = res_dat.Teacher.get_by_id(int(kwargs['id']), parent=SC.key)
     res_dat.showResponse(self, teach.to_dict())