def post(self): request_id = self.request.get('_id') try: bike_type = BikeType.get_by_id(int(request_id)) except ValueError: bike_type = BikeType() request_id = None form_data = BikeTypeForm(self.request.POST, bike_type) if form_data.validate(): # Save and redirect to admin home page form_data.populate_obj(bike_type) bike_type.put() self.redirect('/admin') else: # back to form for editing template = jinjaEnvironment.get_template( 'template/biketypeentry.html') template_values = make_user_links(self.request.uri) template_values['menu'] = make_admin_menu( page='admin/biketypeentry') template_values['submitValue'] = 'Fix' template_values['form'] = form_data template_values['id'] = request_id self.response.out.write(template.render(template_values))
def get(self): template_values = make_user_links(self.request.uri) request_id = self.request.get('id') try: bike_type = BikeType.get_by_id(int(request_id)) template_values['submitValue'] = 'Update' except ValueError: bike_type = BikeType() request_id = None template_values['submitValue'] = 'Create' template = jinjaEnvironment.get_template('template/biketypeentry.html') template_values['menu'] = make_admin_menu(page='admin/biketypeentry') template_values['form'] = BikeTypeForm(obj=bike_type) template_values['id'] = request_id self.response.out.write(template.render(template_values))