def post(self, post_code, kit_id): v = { 'post_code': post_code, 'kit_id': kit_id, 'mk': self.request.get("mk") } v = simple_validate(v) if v['valid']: supplies = [] quantities = [] # PR AKA Post Reqest Dictionary PR = self.request.POST for post_item in PR: if post_item.split("_")[0] == 'supply': supply = db.get(PR[post_item]) supplies.append(supply.key()) qty_find = "qty_" + post_item.split("_")[-1] quantities.append(int(PR[qty_find])) new_sr = SupplyRequest(supplies=supplies, quantities=quantities, date=datetime.now(), delivery_event=None, status="Requested", medkit=v["MedKit"], post_default=v["MedKit"].post_default) if PR['volunteer_notes'] != "": new_sr.volunteer_notes = PR['volunteer_notes'] new_sr.put() redirect = "/%s/%s/status?k=%s" % (post_code, kit_id, v['mk']) self.redirect(redirect) else: self.response.write.out('something unexpected happened')
def post(self, post_code, kit_id): v = {'post_code': post_code, 'kit_id': kit_id, 'mk': self.request.get("mk")} v = simple_validate(v) if v['valid']: supplies = [] quantities = [] # PR AKA Post Reqest Dictionary PR = self.request.POST for post_item in PR: if post_item.split("_")[0] == 'supply': supply = db.get(PR[post_item]) supplies.append(supply.key()) qty_find = "qty_" + post_item.split("_")[-1] quantities.append(int(PR[qty_find])) new_sr = SupplyRequest( supplies = supplies, quantities = quantities, date = datetime.now(), delivery_event = None, status = "Requested", medkit = v["MedKit"], post_default = v["MedKit"].post_default ) if PR['volunteer_notes'] != "": new_sr.volunteer_notes = PR['volunteer_notes'] new_sr.put() redirect = "/%s/%s/status?k=%s" % (post_code, kit_id, v['mk']) self.redirect(redirect) else: self.response.write.out('something unexpected happened')
def get(self, post_code): v = simple_validate({"post_code": post_code}) if v["valid"]: all_requests = SupplyRequest.all().filter("post_default =", v["post_default"]).order("-date") v["DeliveryEvent"] = DeliveryEvent v["requests"] = utilities.sr_improver(all_requests) html = render.page(self, "templates/postadmin/requests_table.html", v) self.response.out.write(html) else: self.response.out.write("Post not found")
def get(self, post_code): v = simple_validate({'post_code': post_code}) if v['valid']: all_requests = SupplyRequest.all().filter( "post_default =", v["post_default"]).order("-date") v['DeliveryEvent'] = DeliveryEvent v['requests'] = utilities.sr_improver(all_requests) html = render.page(self, "templates/postadmin/requests_table.html", v) self.response.out.write(html) else: self.response.out.write("Post not found")
def fix_medkit_request_relationship(): num_fixed = 1 for kit in MedKit.all(): for request in kit.supply_requests: old = db.get(request) if old == None: continue new = SupplyRequest( date = old.date, delivery_event = old.delivery_event, quantities = old.quantities, supplies = old.supplies, status = old.status, status_notes = old.status_notes, volunteer_notes = old.volunteer_notes, medkit = kit, post_default = kit.post_default, ) new.put() old.delete() num_fixed += 1 return str(num_fixed) + " supply requests reinputed into the database!"
def get(self, post_code, kit_id): v = {} v['post_code'] = post_code v['kit_id'] = kit_id v['mk'] = self.request.get('k') v = simple_validate(v) if v['valid']: request_query = SupplyRequest.all().filter('medkit =', v["MedKit"]).order("-date") v['requests'] = utilities.sr_improver(request_query) html = render.page(self, "templates/volunteer/status_table.html", v) self.response.out.write(html) else: render.not_found(self)
def fix_medkit_request_relationship(): num_fixed = 1 for kit in MedKit.all(): for request in kit.supply_requests: old = db.get(request) if old == None: continue new = SupplyRequest( date=old.date, delivery_event=old.delivery_event, quantities=old.quantities, supplies=old.supplies, status=old.status, status_notes=old.status_notes, volunteer_notes=old.volunteer_notes, medkit=kit, post_default=kit.post_default, ) new.put() old.delete() num_fixed += 1 return str(num_fixed) + " supply requests reinputed into the database!"
def get(self, post_code, kit_id): v = {} v['post_code'] = post_code v['kit_id'] = kit_id v['mk'] = self.request.get('k') v = simple_validate(v) if v['valid']: request_query = SupplyRequest.all().filter( 'medkit =', v["MedKit"]).order("-date") v['requests'] = utilities.sr_improver(request_query) html = render.page(self, "templates/volunteer/status_table.html", v) self.response.out.write(html) else: render.not_found(self)