Esempio n. 1
0
	def get(self):
		# get all milestones
		milestones = Milestone.query().order(Milestone.goalMiles)

		# render milestones.html with all milestones
		self.render('html/milestones.html', {
			'milestones' : milestones
		})
Esempio n. 2
0
	def get(self):
		# get the chosen milestone
		modify_id = self.request.get('id')

		chosen_milestone = Milestone.query(Milestone.city_name == modify_id).get()

		self.render('html/modifyMilestone.html', {
			'milestone' : chosen_milestone
		})
Esempio n. 3
0
	def post(self):
		try:
			# get the city name of the milestone that they wish to delete
			deleteChoice = self.request.get('id')

			toDelete = Milestone.query(Milestone.city_name == deleteChoice).get()
			
			# delete from the datastore
			toDelete.key.delete()

			self.redirect('/milestones')
		except Exception as e:
			self.response.write('<html><body>Error deleting milestone!<br>')
			self.response.write(e)
			self.response.write(BACK_BUTTON)
			logging.error(e)
Esempio n. 4
0
	def post(self):
		modify_id = self.request.get('id')
		chosen_milestone = Milestone.query(Milestone.city_name == modify_id).get()

		try:
			# get the new values
			newCity = self.request.get('city')
			newMiles = self.request.get('miles')

			# update the milestone and add changes to datastore
			chosen_milestone.city_name = newCity
			chosen_milestone.goalMiles = float(newMiles)
			chosen_milestone.put()

			self.redirect('/milestones')
		except Exception, e:
			logging.error(e)
			self.response.write('<html><body>Error modifying milestone!<br>')
			self.response.write(e)
			self.response.write(BACK_BUTTON)
Esempio n. 5
0
    def get(self):
        # a list of teachers that have completed their milestone objective
        teacherList = []

        # get a list of all teachers
        allTeachers = Teacher.query()

        # iterate through all teachers
        for teacher in allTeachers:
            # get the current milestone for the teacher
            if not teacher.currentMilestone:
                currentMilestone = Milestone.query().order(Milestone.goalMiles).get()
                teacher.currentMilestone = currentMilestone.key
                teacher.put()
            else:
                currentMilestone = teacher.currentMilestone.get()
            
            # if the totalClassMiles of a teacher is >= its current milestone goal:
            if teacher.totalClassMiles >= currentMilestone.goalMiles:
                # add the teacher to the list
                teacherList.append((teacher.name, currentMilestone.city_name))

                # find the next milestone and assign it to the teacher
                nextMilestone = Milestone.query(Milestone.goalMiles > int(teacher.totalClassMiles)).order(Milestone.goalMiles).get()

                # check if there is a milestone
                if nextMilestone:
                    teacher.currentMilestone = nextMilestone.key
                    teacher.put()

        # if the teacherList is not empty
        if teacherList:
            # create an email to send to the teacher with the names of the teacher
            rowTemplate = Template("""
                <tr>
                    <td>$teacher</td>
                    <td>$milestone</td>
                </tr>
            """)


            body = """
            <html><body>
                <center><h2>Milestone Reached!</h2></center>
                The following teachers have reached their milestones:<br>
                <table width='30%' border='1'>
                    <tr>
                        <th>Teacher Name</th>
                        <th>Milestone</th>
                    </tr>
            """

            # for every teacher name that has passed their milestone
            for t, m in teacherList:
                body = body + rowTemplate.substitute(teacher=t, milestone=m)

            body = body + """
                </table>
            </body></html>
            """

            subject = 'A Milestone Has Been Reached! ' + str(date.today())
            app_id = app_identity.get_application_id()
            mail.send_mail_to_admins("support@"+app_id+".appspotmail.com", subject, body, html=body)