示例#1
0
def update_timestamp(prefix=""):
    email = get_jwt_identity()
    data = {}
    if prefix:
        data[prefix + "." + 'meta.updated_on'] = get_current_time()
        data[prefix + "." + 'meta.updated_by'] = email
    else:
        data['meta.updated_on'] = get_current_time()
        data['meta.updated_by'] = email
    return data
示例#2
0
def custom_marshal(model, template, option='create', prefix=""):
    email = get_jwt_identity()
    data = marshal(model, template)
    if option == 'create':
        data['meta']['created_on'] = get_current_time()
        data['meta']['updated_on'] = get_current_time()
        data['meta']['created_by'] = email
        data['meta']['updated_by'] = email
    elif option == 'update' or option == 'delete':
        if prefix:
            mod_data = {}
            for key, value in data.items():
                mod_data[prefix + "." + key] = value
            mod_data[prefix + "." + 'meta.updated_on'] = get_current_time()
            mod_data[prefix + "." + 'meta.updated_by'] = email
            data = mod_data
        else:
            data['meta']['updated_on'] = get_current_time()
            data['meta']['updated_by'] = email
    return data
示例#3
0
from flask_restplus import fields
from app import api
from app.utils.date_utils import get_current_time
meta = api.model(
    'meta', {
        'is_deleted': fields.Boolean(default=False),
        'created_on': fields.DateTime(default=get_current_time()),
        'updated_on': fields.DateTime(default=get_current_time()),
        'created_by': fields.String(default='user'),
        'updated_by': fields.String(default='user')
    })

from flask_restplus import fields, reqparse
auth_parser = reqparse.RequestParser()
auth_parser.add_argument('Authorization', location='headers')
示例#4
0
def update_meta():
    email = get_jwt_identity()
    data = {}
    data['meta.updated_on'] = get_current_time()
    data['meta.updated_by'] = email
    return data