예제 #1
0
def obj_hash2url(obj, hash_attr, set_null=True):
    hash_value = getattr(obj, hash_attr)
    try:
        url_value = file.get_file_url(hash_value)
    except:
        url_value = ''

    url_attr = hash_attr.replace('hash', 'url')
    setattr(obj, url_attr, url_value)

    if set_null:
        setattr(obj, hash_attr, None)
예제 #2
0
def _get_certification_with_url(restaurant_id):
    cert = cert_base.get(restaurant_id)

    file_names = ['identity_card_image_front',
               'identity_card_image_back',
               'health_card_image_front',
               'health_card_image_back',
               'license_image',
               'restaurant_service_license_copy']
    for file_name in file_names:
        obj = getattr(cert, file_name, None)
        if obj:
            try:
                url=file_base.get_file_url(obj, isprivate=True)
                if url:
                    setattr(
                        cert, file_name, url)
            except Exception as e:
                continue
    return cert
예제 #3
0
파일: cert.py 프로젝트: liuzelei/walis
def _get_certification_with_url(restaurant_id):
    cert = cert_base.get(restaurant_id)

    file_names = [
        "identity_card_image_front",
        "identity_card_image_back",
        "health_card_image_front",
        "health_card_image_back",
        "license_image",
        "restaurant_service_license_copy",
    ]
    for file_name in file_names:
        obj = getattr(cert, file_name, None)
        if obj:
            try:
                url = file_base.get_file_url(obj, isprivate=True)
                if url:
                    setattr(cert, file_name, url)
            except Exception as e:
                continue
    return cert
예제 #4
0
def query(status=None, order_id=None, pay_platform=None, offset=None, limit=None):
    resource = refund_base.query(status, order_id, pay_platform, offset, limit)
    for item in resource.drawback_process_records:
        # create opt log (only one row at now)
        item.optlog = []
        if item.process_user_id and item.bank_drawback_process_record:
            admin = user_service.get_user(item.process_user_id)
            item.optlog.append({
                'time': datetime.fromtimestamp(int(item.retry_at)).strftime('%Y-%m-%d %H:%M:%S'),
                'admin': admin.username,
                'detail': u'提交打款账号'
            })
        # process_user_id maybe changed in the future, don't expose it to front
        delattr(item, 'process_user_id')
        # complete img url
        if item.bank_drawback_process_record and item.bank_drawback_process_record.image_hash:
            item.image_url = file_utils.get_file_url(
                item.bank_drawback_process_record.image_hash
            )
        # convert order_id as string, that to prevent exceeding the maximum
        # integer in javascript
        item.order_id = str(item.order_id)
    return ttype2dict(resource)