Exemple #1
0
 def get(self):
     path = os.path.join(os.path.dirname(__file__),
                         'template/adminwelcome.html')
     template_values = makeUserLinks(self.request.uri)
     template_values['menu'] = makeAdminMenu(page='admin')
     template_values['bikeTypes'] = BikeType.all()
     template_values['rideTypes'] = RideType.all()
     self.response.out.write(template.render(path, template_values))
Exemple #2
0
 def get(self):
     template_values = makeUserLinks(self.request.uri)
     try:
         id = int(self.request.get('id'))
         bikeType = BikeType.get(db.Key.from_path('BikeType', id))
         template_values['submitValue'] = 'Update'
     except ValueError:
         bikeType = None
         id = None
         template_values['submitValue'] = 'Create'
     path = os.path.join(os.path.dirname(__file__),
                         'template/biketypeentry.html')
     template_values['menu'] = makeAdminMenu(page='admin/biketypeentry')
     template_values['form'] = BikeTypeForm(instance=bikeType)
     template_values['id'] = id
     self.response.out.write(template.render(path, template_values))
Exemple #3
0
    def post(self):
        try:
            id = int(self.request.get('_id'))
            bikeType = BikeType.get(db.Key.from_path('BikeType', id))
        except ValueError:
            bikeType = None
            id = None
        data = BikeTypeForm(data=self.request.POST, instance=bikeType)

        if data.is_valid():
            # Save and redirect to admin home page
            entity = data.save(commit=False)
            entity.put()
            self.redirect('/admin')
        else:
            # back to form for editing
            path = os.path.join(os.path.dirname(__file__),
                                'template/biketypeentry.html')
            template_values = makeUserLinks(self.request.uri)
            template_values['menu'] = makeAdminMenu(page='admin/biketypeentry')
            template_values['submitValue'] = 'Fix'
            template_values['form'] = data
            template_values['id'] = id
            self.response.out.write(template.render(path, template_values))