Пример #1
0
    def post(self):
        request_id = self.request.get('_id')

        try:
            ride_type = RideType.get_by_id(int(request_id))
        except ValueError:
            ride_type = RideType()
            request_id = None

        form_data = RideTypeForm(self.request.POST, ride_type)

        if form_data.validate():
            # Save and redirect to admin home page
            form_data.populate_obj(ride_type)
            ride_type.put()
            self.redirect('/admin')
        else:
            # back to form for editing
            template = jinjaEnvironment.get_template(
                'template/ridetypeentry.html')
            template_values = make_user_links(self.request.uri)
            template_values['menu'] = make_admin_menu(
                page='admin/ridetypeentry')
            template_values['submitValue'] = 'Fix'
            template_values['form'] = form_data
            template_values['id'] = request_id
            self.response.out.write(template.render(template_values))
Пример #2
0
 def get(self):
     template = jinjaEnvironment.get_template('template/adminwelcome.html')
     template_values = make_user_links(self.request.uri)
     template_values['menu'] = make_admin_menu(page='admin')
     template_values['bikeTypes'] = BikeType.query().fetch()
     template_values['rideTypes'] = RideType.query().fetch()
     self.response.out.write(template.render(template_values))
Пример #3
0
    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))