Exemplo n.º 1
0
 def GET(self, xid):
     assert (str(xid).isdigit())
     if not check_right (xid):
         print 'try to read an unauthrithm data, %s record id:%s , user id:%s'  %  ('insp_value',xid, get_user())
         raise web.notfound()
     
     data = {}
     data['record'] = m_insp_value.get_one ({"id",int(xid)})
     return render ('admin/insp_value_read.html', data = data)
Exemplo n.º 2
0
    def GET(self, xid):
        assert (str(xid).isdigit())
        if not check_right(xid):
            print 'try to read an unauthrithm data, %s record id:%s , user id:%s' % (
                'insp_value', xid, get_user())
            raise web.notfound()

        data = {}
        data['record'] = m_insp_value.get_one({"id", int(xid)})
        return render('admin/insp_value_read.html', data=data)
Exemplo n.º 3
0
    def POST(self, xid):
        #xid = web.input(xid=0).get('xid')
        assert (str(xid).isdigit())
        xid = int(xid)

        request = web.input()
        input_fields = [
            'insp_value_insp_plan_id',
            'insp_value_insp_item_id',
            'insp_value_value',
            'insp_value_remark',
        ]
        nonul_fields = [
            'insp_value_insp_plan_id',
            'insp_value_insp_item_id',
            'insp_value_value',
            'insp_value_remark',
        ]  #user input fileds, can not be emtpy

        #检查用户是否有权限
        if xid != 0 and not self.check_right(xid):
            print 'try to save an unauthrithm data, %s record id:%s , user id:%s' % (
                'insp_value', xid, get_user())
            raise web.notfound()

        #检查是否存在 不能为空的字段 输入为空
        if not self.check_input(request, nonul_fields):
            print 'try to edit data, but found some not-null parameter null'
            return default_error('some parameter empty')

        data = {}
        if xid == 0:  #new record
            print 'add new record into database for table insp_value'
            data["id"] = 0
            data['create_date'] = get_date()
            data['create_user_id'] = get_user()
        else:
            print 'update record into database for table insp_value'
            data = m_insp_value.get_one(**{'id': xid})
            if not data:
                print 'try to update record into database, but fail'
                raise web.notfound()
            data['update_date'] = get_date()
            data['update_user_id'] = get_user()
        for field in input_fields:
            new_field = field.replace('insp_value_', '', 1)
            data[new_field] = request.get(field, '')

        #if xid=0 then add   ;  otherwise  update
        m_insp_value.upsert("id", **data)
        return web.seeother('/admin/insp_value' + "_list")
Exemplo n.º 4
0
 def GET(self,xid):
     assert (str(xid).isdigit())
     xid  = int(xid)
     
     if xid and not self.check_right (xid):
         print 'try to edit unauthorization data, table:%s,  id:%s'  %   ( 'insp_value', xid)
         return default_error ()
     
     data = {}
     if xid:
         data = m_insp_value.get_one (**{"id": int(xid)})
         if not data:
             print 'Error, try to edit record but not found data, table:%s,  id:%s'   % ('insp_value', xid)
             raise web.notfound()
     return render ('admin/insp_value_edit.html', data = data)
Exemplo n.º 5
0
    def GET(self, xid):
        assert (str(xid).isdigit())
        xid = int(xid)

        if xid and not self.check_right(xid):
            print 'try to edit unauthorization data, table:%s,  id:%s' % (
                'insp_value', xid)
            return default_error()

        data = {}
        if xid:
            data = m_insp_value.get_one(**{"id": int(xid)})
            if not data:
                print 'Error, try to edit record but not found data, table:%s,  id:%s' % (
                    'insp_value', xid)
                raise web.notfound()
        return render('admin/insp_value_edit.html', data=data)
Exemplo n.º 6
0
 def GET(self,xid):
     assert (str(xid).isdigit())
     
     xid  = int(xid)
     data = {}
     if not xid:
         #add 
         pass
     elif not check (xid):
         print 'try to edit an unauthrithm data, table %s, id:%s , user id:%s'  %  ('insp_value',xid, get_user())
         raise web.notfound()
     else:
         data['record'] = m_insp_value.get_one ({"key":"id", "value": int(xid)})
         if not data['record']:
             print 'Error, try to edit record but not found data, table:%s,  id:%s'   % ('insp_value', xid)
             raise web.notfound()
     return render ('admin/insp_value_edit.html', data = data)
Exemplo n.º 7
0
 def POST(self,xid):
     #xid = web.input(xid=0).get('xid')
     assert (str(xid).isdigit())
     xid  = int(xid)
     
     request = web.input()
     input_fields = [ 'insp_value_insp_plan_id',  'insp_value_insp_item_id',  'insp_value_value',  'insp_value_remark', ]
     nonul_fields = [ 'insp_value_insp_plan_id',  'insp_value_insp_item_id',  'insp_value_value',  'insp_value_remark', ]    #user input fileds, can not be emtpy
     
     #检查用户是否有权限
     if xid!=0 and not self.check_right (xid):
         print 'try to save an unauthrithm data, %s record id:%s , user id:%s'  %  ('insp_value',xid, get_user())
         raise web.notfound()
     
     #检查是否存在 不能为空的字段 输入为空
     if not self.check_input (request, nonul_fields):
         print 'try to edit data, but found some not-null parameter null'
         return default_error('some parameter empty')
     
     data = {}
     if xid==0:   #new record
         print 'add new record into database for table insp_value'
         data["id"] = 0
         data['create_date']    = get_date()
         data['create_user_id'] = get_user()
     else:
         print 'update record into database for table insp_value'
         data = m_insp_value.get_one ( ** {'id': xid})
         if not data:
             print 'try to update record into database, but fail'
             raise web.notfound()
         data['update_date']    = get_date()
         data['update_user_id'] = get_user()
     for field in input_fields:
         new_field = field.replace('insp_value_','',1)
         data[new_field] = request.get(field,'')
     
     #if xid=0 then add   ;  otherwise  update
     m_insp_value.upsert ("id",**data)
     return web.seeother('/admin/insp_value'+"_list")
Exemplo n.º 8
0
    def GET(self, xid):
        assert (str(xid).isdigit())

        xid = int(xid)
        data = {}
        if not xid:
            #add
            pass
        elif not check(xid):
            print 'try to edit an unauthrithm data, table %s, id:%s , user id:%s' % (
                'insp_value', xid, get_user())
            raise web.notfound()
        else:
            data['record'] = m_insp_value.get_one({
                "key": "id",
                "value": int(xid)
            })
            if not data['record']:
                print 'Error, try to edit record but not found data, table:%s,  id:%s' % (
                    'insp_value', xid)
                raise web.notfound()
        return render('admin/insp_value_edit.html', data=data)