def post(self): self.session[LOGIN_NEXT_PAGE_KEY] = self.URL if not isUserAdmin(self): self.session[LOGIN_NEXT_PAGE_KEY] = self.URL self.redirect("/") return codes = {} for field in self.request.arguments(): code = field[:4] if not codes.has_key(code): codeObj = {} else: codeObj = codes[code] if (field[4:8]=="_cst"): codeObj['cost'] = int(self.request.get(field)) else: codeObj['limit'] = int(self.request.get(field)) codes[code] = codeObj sortedCodes = sorted(codes.keys()) deliveryCosts = [] for code in sortedCodes: updateZipCodeEntry(code, codes.get(code)['cost'], codes.get(code)['limit']) deliveryCosts.append(code + " " + str(codes.get(code)['cost']) + " " + str(codes.get(code)['limit'])) rawCodes = ZipCodes.all().get() if (rawCodes == None): rawCodes = ZipCodes() rawCodes.deliveryCosts = deliveryCosts rawCodes.put() updateZipCodeScript(rawCodes) self.redirect("/editZipCodes")
def get(self): if not isUserAdmin(self): self.session[LOGIN_NEXT_PAGE_KEY] = self.URL self.redirect("/") return rawCodes = ZipCodes.all().get() if (rawCodes == None): rawCodes = ZipCodes() zipCodeList = createZipCodeList() rawCodes.deliveryCosts = zipCodeList rawCodes.put() codes = [] for code in rawCodes.deliveryCosts: parts=code.rsplit(" ") codes.append( { 'code':parts[0], 'cost':parts[1], 'limit':parts[2] }) template_values = { 'codes':codes } template = jinja_environment.get_template('templates/admin/zipCodeEditor.html') self.printPage("dashboard", template.render(template_values), False, False)