Ejemplo n.º 1
0
	def POST(self):
		web.header('Content-Type', 'application/json')
		web.header('Access-Control-Allow-Origin', '*')
		web.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')

		volunteerItem = simplejson.loads(web.data())

		existingVolunteer = Volunteer.GetByEmail(volunteerItem['volunteer_email'])

		if (existingVolunteer):
			return "{ status: 'Error - Volunteer Exists'}"

		else:              # not existing, create new database record
			newVolunteer = Volunteer( 
					volunteer_name = volunteerItem['volunteer_name'],
					volunteer_email = volunteerItem['volunteer_email'],
					volunteer_phone = volunteerItem['volunteer_phone'],
					address_street = volunteerItem['address_street'],
					address_street2 = volunteerItem['address_street2'],
					address_city = volunteerItem['address_city'],
					address_state = volunteerItem['address_state'],
					address_zipcode = volunteerItem['address_zipcode']
   								)	
			newVolunteer.put()

		return '{ "status": "Success"}'
Ejemplo n.º 2
0
 def post(self, post_code):
     v = simple_validate({"post_code": post_code})
     if v["valid"]:
         f = VolunteerForm(self.request.POST)
         if f.validate():
             new_v = Volunteer(
                 first_name=f.first_name.data,
                 last_name=f.last_name.data,
                 phone=f.phone.data,
                 email=f.email.data,
                 project=f.project.data,
                 sitelocation=f.sitelocation.data,
                 notes=f.notes.data,
                 cos=f.cos.data,
                 trainee_input="",
             )
             new_v.put()
             new_kit = MedKit(
                 date_issued=datetime.now(),
                 in_use=True,
                 delivery_events=[],
                 volunteer=new_v,
                 post_default=v["post_default"],
             )
             new_kit.put()
             v["Volunteer"] = new_v
             v["MedKit"] = new_kit
             html = render.page(self, "templates/postadmin/confirmation.html", v)
             self.response.out.write(html)
         else:
             self.response.out.write("invalid entry for one of the form items")
     else:
         render.not_found(self)
Ejemplo n.º 3
0
 def post(self, post_code):
     v = simple_validate({'post_code': post_code})
     if v['valid']:
         f = VolunteerForm(self.request.POST)
         if f.validate():
             new_v = Volunteer(
                 first_name=f.first_name.data,
                 last_name=f.last_name.data,
                 phone=f.phone.data,
                 email=f.email.data,
                 project=f.project.data,
                 sitelocation=f.sitelocation.data,
                 notes=f.notes.data,
                 cos=f.cos.data,
                 trainee_input="",
             )
             new_v.put()
             new_kit = MedKit(
                 date_issued=datetime.now(),
                 in_use=True,
                 delivery_events=[],
                 volunteer=new_v,
                 post_default=v["post_default"],
             )
             new_kit.put()
             v['Volunteer'] = new_v
             v['MedKit'] = new_kit
             html = render.page(self,
                                "templates/postadmin/confirmation.html", v)
             self.response.out.write(html)
         else:
             self.response.out.write(
                 "invalid entry for one of the form items")
     else:
         render.not_found(self)
Ejemplo n.º 4
0
	def POST(self):

		web.header('Access-Control-Allow-Origin',      '*')
		web.header('Access-Control-Allow-Credentials', 'true')

		volunteerItem = simplejson.loads(web.data())

		existingVolunteer = Volunteer.GetByEmail(volunteerItem['volunteer_email'])

		if (existingVolunteer):
			return "{ status: 'Error - Volunteer Exists'}"

		else:              # not existing, create new database record
			newVolunteer = Volunteer( 
					volunteer_name = volunteerItem['volunteer_name'],
					volunteer_email = volunteerItem['volunteer_email'],
					volunteer_phone = volunteerItem['volunteer_phone'],
					address_street = volunteerItem['address_street'],
					address_street2 = volunteerItem['address_street2'],
					address_city = volunteerItem['address_city'],
					address_state = volunteerItem['address_state'],
					address_zipcode = volunteerItem['address_zipcode']
   								)	
			newVolunteer.put()

		return "{ status: 'Success'}"