Example #1
0
 def post(self):
     username = self.session['username']
     logging.info(username)
     student = Student.query(Student.user_name == username).fetch()[0]
     if self.request.get('first_pass') == self.request.get('second_pass'): #check if passwords match
         logging.info(self.request.get('first_pass'))
         if student.change_password(self.request.get('first_pass')): # password change successful
             student.put()
             self.redirect('/')
         else:
             template = JINJA_ENVIRONMENT.get_template('templates/StudentAccountSettingsPage.html')
             self.response.write(template.render({'user': student}))
     else:
         template = JINJA_ENVIRONMENT.get_template('templates/StudentAccountSettingsPage.html')
         self.response.write(template.render({'user': student, 'password_match': False}))
Example #2
0
 def get(self):
     username = self.session['username']
     logging.info(username)
     students = Student.query(Student.user_name == username).fetch()
     student = students[0]
     if student:
         logging.info(student)
         template = JINJA_ENVIRONMENT.get_template('templates/StudentAccountSettingsPage.html')
         self.response.write(template.render({'user': student}))
     else:
         html="""<html>
         <head><meta http-equiv="refresh" content="3;URL='/'"><title>Redirect</title></head>
         <body style="color: red;"> Invalid Credentials, you are being redirected.</body></html>
         """
         self.response.write(html)
Example #3
0
 def get(self):
     if 'username' in self.session and self.session['username']:
         username = self.session['username']
         students = Student.query(Student.user_name == username).fetch()
         if students:
             student = students[0]
             template = JINJA_ENVIRONMENT.get_template('templates/StudentHomePage.html')
             self.response.write(template.render({
                 'answered_questions': student.get_answered_questions,
                 'unanswered_questions': student.get_unanswered_questions,
                 'user': student.first_name+" "+student.last_name
             }))
         else:
             self.response.write("Invalid Credentials")
             self.redirect('/')
     else:
         self.response.write("Invalid Credentials")
         self.redirect('/')
Example #4
0
 def get(self):
     if 'username' in self.session and self.session['username']:
         username = self.session['username']
         students = Student.query(Student.user_name == username).fetch()
         if students:
             template = JINJA_ENVIRONMENT.get_template('templates/submitquestion.html')
             self.response.write(template.render({
                 'submitagain': False,
                 'emptyfield': False
             }))
         else:
             html = """<html>
             <head><meta http-equiv="refresh" content="3;URL='/'"><title>Redirect</title></head>
             <body style="color: red;"> Invalid Credentials, you are being redirected.</body></html>
             """
             self.response.write(html)
     else:
         html="""<html>
         <head><meta http-equiv="refresh" content="3;URL='/'"><title>Redirect</title></head>
         <body style="color: red;"> Invalid Credentials, you are being redirected.</body></html>
         """
         self.response.write(html)
Example #5
0
 def get(self):
     unanswered_questions = Question.query(Question.unAnswered == True).order(-Question.date_created).fetch()
     recent_questions = Question.query().order(-Question.date_answered).fetch(6)
     students = Student.query().fetch()
     if 'username' in self.session and self.session['username']:
         username = self.session['username']
         profs = Professor.query(Professor.user_name == username).fetch()
         qqtab = 1
         if self.request.get('NewQ'):
             qqtab = 1
         elif self.request.get('RecentQ'):
             qqtab = 2
         elif self.request.get('ByStudent'):
             qqtab = 3
         elif self.request.get('FAQs'):
             self.redirect('/FAQADMIN')
         if profs:
             template = JINJA_ENVIRONMENT.get_template('templates/QuestionQueue.html')
             self.response.write(template.render({
                 'QQTAB': qqtab,
                 'unanswered_questions': unanswered_questions,
                 'recent_questions': recent_questions,
                 'students': students
             }))
         else:
             html = """<html>
             <head><meta http-equiv="refresh" content="3;URL='/'"><title>Redirect</title></head>
             <body style="color: red;"> Invalid Credentials, you are being redirected.</body></html>
             """
             self.response.write(html)
     else:
         html="""<html>
         <head><meta http-equiv="refresh" content="3;URL='/'"><title>Redirect</title></head>
         <body style="color: red;"> Invalid Credentials, you are being redirected.</body></html>
         """
         self.response.write(html)
Example #6
0
 def tearDown(self):
     student = Student.query(
         Student.first_name == self.student.first_name).fetch()
     if student:
         student.key.delete()