Example #1
0
 def get_or_404(self, bom_id):
     try:
         bom = Bom.get_by_id(long(bom_id))
         if bom:
             return bom
     except ValueError:
         pass
     self.abort(404)
Example #2
0
 def get(self, bom_id):
     # TODO:
     #   check user
     bom = Bom.get_by_id(long(bom_id))
     if bom:
         bom.delete()
         time.sleep(0.5)  # give db some time to write
         self.add_message('BOM deleted!', 'success')
         self.redirect(self.uri_for('boms'))
     else:
         self.abort(404)
Example #3
0
 def get(self, bom_id):
     # TODO:
     #   check user
     bom = Bom.get_by_id(long(bom_id))
     if bom:
         bom.delete()
         time.sleep(0.5)  # give db some time to write
         self.add_message('BOM deleted!', 'success')
         self.redirect(self.uri_for('boms'))
     else:
         self.abort(404)
Example #4
0
 def post(self, bom_id):
     name = self.request.get('name')
     public = self.request.get('public')
     bom = Bom.get_by_id(long(bom_id))
     if bom:
         self.response.headers.add_header('content-type', 'application/json', 
                                          charset='utf-8')
         ret = 'false'
         if name:
             bom.name = name
         if public:
             if public == 'true':
                 bom.public = True
             elif public == 'false':
                 bom.public = False
         if name or public:
             try:
                 bom.put(self.user_id)
             except AuthWriterError as ex:
                 ret = str(ex)
         self.response.out.write('{"error":'+ret+'}')
     else:
         self.abort(404)
Example #5
0
 def post(self, bom_id):
     name = self.request.get('name')
     public = self.request.get('public')
     bom = Bom.get_by_id(long(bom_id))
     if bom:
         self.response.headers.add_header('content-type',
                                          'application/json',
                                          charset='utf-8')
         ret = 'false'
         if name:
             bom.name = name
         if public:
             if public == 'true':
                 bom.public = True
             elif public == 'false':
                 bom.public = False
         if name or public:
             try:
                 bom.put(self.user_id)
             except AuthWriterError as ex:
                 ret = str(ex)
         self.response.out.write('{"error":' + ret + '}')
     else:
         self.abort(404)