Exemplo n.º 1
0
 def __json__(self, o, cId, uId):
     for key in self.__mapper__.columns.keys():
         if key in ['items', 'form', 'page_name']:
             continue
         elif key == 'page_id':
             if (is_exist(o, key) == False
                     or is_empty(str(o[key])) == True):
                 id = None
             else:
                 id = o[key]
             setattr(self, key, id)
         elif key == 'page_auth':
             if (is_exist(o, key) == False or is_empty(o[key]) == True):
                 auth = None
             else:
                 auth = o[key]
             setattr(self, key, auth)
         elif key == 'page_id_seq':
             if (is_exist(o, key) == False or is_empty(o[key]) == True):
                 seq = None
             else:
                 seq = o[key]
             setattr(self, key, seq)
         elif is_exist(o, key) == False and key in [
                 'page_flag', 'page_deleted', 'page_layout', 'page_open'
         ]:
             setattr(self, key, 0)
         elif key == 'company_id':
             setattr(self, key, cId)
         elif key == 'updated_id':
             setattr(self, key, uId)
         elif key == 'updated_time':
             setattr(self, key, datetime.datetime.now())
         else:
             setattr(self, key, o[key])
Exemplo n.º 2
0
def putcodes():
    auth = {}
    codes = None
    result = []
    if request.method == 'POST':
        if request.json is not None:
            auth = request.json.get('auth')
            codes = request.json.get('codes')
        else:
            auth['code'] = request.form.get('code')
            auth['flag'] = request.form.get('flag')
            code = {}
            code['value'] = request.form.get('value')
            code['filename'] = request.form.get('filename')
            codes = []
            codes.append(code)

        if codes is None or len(codes) <= 0:
            obj = {}
            obj['name'] = None
            obj['data'] = 'ファイルデータは必須です。'
            result.append(obj)
            return jsonify(result), 200

    result = put_codes(auth, codes)
    if (is_exist(auth, 'flag') == False or auth['flag'] != 'json') and result is not None:
        return make_response_zip(result, True)
    else:
        if result is None:
            result = { 'msg': 'Json Data is error !!!' }
        return jsonify(result), 200
Exemplo n.º 3
0
def pdf():
    obj = {}
    if request.method == 'POST':
        if request.json is not None:
            if is_json(request.json):
                obj = request.json
        else:
            obj = get_forms(request)

    # options = {}
    # options['orientation'] = 'Portrait'
    # obj['options'] = options
    result = get_pdf(obj)
    if result is not None and is_exist(result, 'msg') == False:
        response = make_response()
        filename = result['filename']
        fullpath = result['path'] + '/' + filename
        response.data = open(fullpath, 'rb').read()
        response.headers['Content-Disposition'] = "attachment; filename=" + filename
        response.mimetype = 'application/pdf'

        delete_dir(result['path'])
        return response
    else:
        if result is None:
            result = { 'msg': 'Json Data is error !!!' }
        return jsonify(result), 200
Exemplo n.º 4
0
 def update(self, page):
     try:
         obj = self.get(page['page_id'])
         for key in obj.__mapper__.columns.keys():
             if is_exist(page, key) == True:
                 setattr(obj, key, page[key])
         self.db.session.commit()
     except:
         self.db.session.rollback()
         raise
Exemplo n.º 5
0
 def __json__(self, o):
     for key in self.__mapper__.columns.keys():
         if key == 'option_id':
             if (is_exist(o, key) == False or is_empty(o[key]) == True):
                 id = None
             else:
                 id = o[key]
             setattr(self, key, id)
         else:
             setattr(self, key, o[key])
Exemplo n.º 6
0
 def __json__(self, o, cId, uId):
     for key in self.__mapper__.columns.keys():
         if key == 'server_id':
             if (is_exist(o, key) == False
                     or is_empty(str(o[key])) == True):
                 id = None
             else:
                 id = o[key]
             setattr(self, key, id)
         elif key == 'page_group_id':
             setattr(self, key, pgId)
         else:
             setattr(self, key, o[key])
Exemplo n.º 7
0
 def update(self, form):
     try:
         obj = self.get(form['form_id'])
         for key in obj.__mapper__.columns.keys():
             if is_exist(form, key) == True or key == 'class_name':
                 if key == 'class_name':
                     setattr(obj, key, form['className'])
                 else:
                     setattr(obj, key, form[key])
         self.db.session.commit()
     except:
         self.db.session.rollback()
         raise
Exemplo n.º 8
0
 def update(self, schema):
     try:
         obj = self.get(schema['schema_id'])
         for key in obj.__mapper__.columns.keys():
             if is_exist(schema, key) == True or key == 'object_type':
                 if key == 'object_type':
                     setattr(obj, key, schema['type'])
                 else:
                     setattr(obj, key, schema[key])
         self.db.session.commit()
     except:
         self.db.session.rollback()
         raise
Exemplo n.º 9
0
 def __json__(self, o, pId):
     for key in self.__mapper__.columns.keys():
         if key == 'form_id':
             if (is_exist(o, key) == False or is_empty(o[key]) == True):
                 id = None
             else:
                 id = o[key]
             setattr(self, key, id)
         elif key == 'page_id':
             setattr(self, key, pId)
         elif key == 'class_name':
             setattr(self, key, o['className'])
         else:
             setattr(self, key, o[key])
Exemplo n.º 10
0
 def __json__(self, o, fId):
     for key in self.__mapper__.columns.keys():
         if key == 'schema_id':
             if (is_exist(o, key) == False or is_empty(o[key]) == True):
                 id = None
             else:
                 id = o[key]
             setattr(self, key, id)
         elif key == 'form_id':
             setattr(self, key, fId)
         elif key == 'object_type':
             setattr(self, key, o['type'])
         else:
             setattr(self, key, o[key])