当前位置: 首页>>代码示例>>Python>>正文


Python service.Info类代码示例

本文整理汇总了Python中psi.app.service.Info的典型用法代码示例。如果您正苦于以下问题:Python Info类的具体用法?Python Info怎么用?Python Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_or_update_inventory_transaction

 def create_or_update_inventory_transaction(self):
     from psi.app.models.inventory_transaction import InventoryTransactionLine, InventoryTransaction
     from psi.app.models.enum_values import EnumValues
     if self.type.code == const.DIRECT_SHIPPING_TYPE_KEY:
         it_type = EnumValues.get(const.SALES_OUT_INV_TRANS_TYPE_KEY)
     else:
         it_type = EnumValues.get(const.FRANCHISE_SALES_OUT_INV_TRANS_TYPE_KEY)
     it = self.inventory_transaction
     if it is None:
         it = InventoryTransaction()
         it.type = it_type
         self.inventory_transaction = it
     it.date = self.date
     it.organization = self.organization
     for line in self.lines:
         itl = line.inventory_transaction_line
         if itl is None:
             itl = InventoryTransactionLine()
         itl.quantity = -line.quantity
         itl.product = line.product
         itl.price = line.price
         itl.in_transit_quantity = 0
         itl.inventory_transaction = it
         line.inventory_transaction_line = itl
         self.update_saleable_qty_in_purchase_inv_lines(line)
     Info.get_db().session.add(it)
开发者ID:betterlife,项目名称:psi,代码行数:26,代码来源:shipping.py

示例2: init_image_service

def init_image_service(app):
    """
    Initialize image store service
    """
    image_store = app.config['IMAGE_STORE_SERVICE']
    if image_store is not None:
        Info.set_image_store_service(image_store(app))
开发者ID:betterlife,项目名称:psi,代码行数:7,代码来源:__init__.py

示例3: _handle_image_delete

def _handle_image_delete(mapper, conn, target):
    """
    Delete the local or remote image from 3rd service when delete the image.
    if path is not empty, assume local storage, delete using after_delete
    listener, if public_id is not null, assume using cloud service, delete
    using public_id.
    :param mapper:
    :param conn:
    :param target: image object to be deleted
    :return:
    """
    # TODO.xqliu The delete of image is not working for local image store
    Info.get_image_store_service().remove(target.path, target.public_id)
开发者ID:betterlife,项目名称:psi,代码行数:13,代码来源:image.py

示例4: init_all

def init_all(app, migrate=True):
    init_logging(app)
    # === Important notice to the maintainer ===
    # This line was use to database = init_db(app)
    # But we found session can not be cleaned among different
    # Unit tests, so we add this to avoid issue
    # sqlalchemy-object-already-attached-to-session
    # http://stackoverflow.com/questions/24291933/sqlalchemy-object-already-attached-to-session
    # A similar issue was captured on
    # https://github.com/jarus/flask-testing/issues/32
    # Please don't try to modify the follow four lines.
    # Please don't try to modify the follow four lines.
    # Please don't try to modify the follow four lines.
    if Info.get_db() is None:
        database = init_db(app)
    else:
        database = Info.get_db()
        database.init_app(app)
    security = init_flask_security(app, database)
    init_migrate(app, database)
    if migrate:
        with app.app_context():
            upgrade(directory=MIGRATION_DIR)

    init_https(app)
    init_admin_views(app, database)
    babel = init_babel(app)
    api = init_flask_restful(app)
    init_reports(app, api)
    init_jinja2_functions(app)
    # init_debug_toolbar(app)
    init_image_service(app)
    socket_io = init_socket_io(app)
    define_route_context(app, database, babel)

    # define a context processor for merging flask-admin's template context
    # into the flask-security views.
    @security.context_processor
    def security_context_processor():
        from flask import url_for
        return dict(
            get_url=url_for
        )

    @app.teardown_appcontext
    def shutdown_session(exception=None):
        database = Info.get_db()
        database.session.remove()

    return socket_io
开发者ID:betterlife,项目名称:psi,代码行数:50,代码来源:__init__.py

示例5: sales_amount_report

def sales_amount_report(r_type, r_period):
    limit = get_limit(r_period)
    sql = sqls.SALES_AMOUNT_REPORT_SQL.format('WEEK', 'WW', limit) \
        if r_period == 'week' \
        else sqls.SALES_AMOUNT_REPORT_SQL.format('MONTH', 'Mon', limit)
    results = Info.get_db().engine.execute(sql).fetchall()
    labels, totals = [], []
    for r in results:
        labels.append("{0}, {1}".format(int(r[0]), gettext(r[2])))
        totals.append(float(r[3]))
    avg = str(format_util.format_decimal(sum(totals) / float(len(totals)))) if len(totals) > 0 else 0
    labels.reverse()
    totals.reverse()
    ct = gettext(r_type.capitalize())
    cp = gettext(r_period.capitalize())
    label_tot = gettext('Total Sales {0} Per {1}').format(ct, cp)
    label_avg = gettext('Average Sales {0}(Past {1} {2}(s)): {3}').format(ct, 24, cp, avg)
    return dict(
        data={
            "labels": labels,
            "details": {
                "average_amount": {
                    "label": label_avg,
                    "data": [avg] * len(totals),
                    "style": "average"
                },
                "total": {
                    "label": label_tot,
                    "data": totals,
                    "style": "major"
                }
            }
        },
        status='success'
    )
开发者ID:betterlife,项目名称:psi,代码行数:35,代码来源:sales_order_reports.py

示例6: test_logic

 def test_logic():
     fixture.login_as_admin(self.test_client)
     user, password = object_faker.user(role_names=[
         'franchise_sales_order_create',
         'franchise_sales_order_view',
         'franchise_sales_order_edit',
         'product_view'
     ])
     franchise_so_type = EnumValues.get(FRANCHISE_SO_TYPE_KEY)
     sales_order = object_faker.sales_order(creator=user,
                                            number_of_line=1,
                                            type=franchise_so_type)
     db_util.save_objects_commit(sales_order, user)
     so_id = sales_order.id
     shipped_status = EnumValues.get(SO_SHIPPED_STATUS_KEY)
     fixture.login_user(self.test_client, user.email, password)
     rv = self.test_client.put('/api/sales_order/' + str(so_id),
                               follow_redirects=True,
                               data=dict(status_id=shipped_status.id))
     self.assertIn(b'message', rv.data)
     self.assertIn(b'Status update successfully', rv.data)
     self.assertEqual(rv.status_code, 200)
     so_from_db = Info.get_db().session.query(SalesOrder).get(so_id)
     self.assertIsNotNone(so_from_db)
     self.assertEquals(SO_SHIPPED_STATUS_KEY, so_from_db.status.code)
开发者ID:betterlife,项目名称:psi,代码行数:25,代码来源:sales_order_api_test.py

示例7: put

 def put(self, sales_order_id):
     try:
         args = parser.parse_args()
         status_id = args['status_id']
         session = Info.get_db().session
         sales_order = session.query(SalesOrder).get(sales_order_id)
         status = session.query(EnumValues).get(status_id)
         if status is not None and status.type.code == SO_STATUS_KEY:
             if sales_order.status.code == SO_CREATED_STATUS_KEY:
                 if status.code == SO_SHIPPED_STATUS_KEY or status.code == SO_DELIVERED_STATUS_KEY:
                     sales_order.status_id = status_id
                     shipping = SalesOrderService.create_or_update_shipping(sales_order)
                     session.add(sales_order)
                     session.add(shipping)
                     SalesOrderService.update_related_po_status(sales_order, PO_SHIPPED_STATUS_KEY)
                 elif status.code == SO_INVALID_STATUS_KEY:
                     sales_order.status_id = status_id
                     session.add(sales_order)
                     po = SalesOrderService.update_related_po_status(sales_order, PO_REJECTED_STATUS_KEY)
                     recvs = po.po_receivings
                     for recv in recvs:
                         session.delete(recv)
                 session.commit()
                 return dict(message=gettext('Status update successfully'), status='success'), 200
             else:
                 return dict(message=gettext('Status update not allowed'), status='error'), 201
         else:
             return dict(message=gettext('Invalid sales order status parameter'), status='error'), 201
     except Exception as e:
         return dict(message=gettext('Failed to change sales order status<br>{0}').format(e.message), status='error'), 201
开发者ID:betterlife,项目名称:psi,代码行数:30,代码来源:sales_order.py

示例8: get_total

def get_total(report_type, period_type, period_number, year):
    if report_type == 'amount_compare_with_last_period':
        sql = sqls.GET_AMOUNT_BY_YEAR_SQL.format(period_type, period_number, year)
    elif report_type == 'profit_compare_with_last_period':
        sql = sqls.GET_PROFIT_BY_YEAR_SQL.format(period_type, period_number, year)
    results = Info.get_db().engine.execute(sql).fetchall()
    return results[0][0]
开发者ID:betterlife,项目名称:psi,代码行数:7,代码来源:sales_order_reports.py

示例9: update_related_po_status

 def update_related_po_status(sales_order, status_code):
     purchase_order = SalesOrderService.get_related_po(sales_order)
     session = Info.get_db().session
     if purchase_order is not None:
         status = EnumValues.get(status_code)
         purchase_order.status = status
         session.add(purchase_order)
     return purchase_order
开发者ID:betterlife,项目名称:psi,代码行数:8,代码来源:sales_order.py

示例10: save_objects_commit

def save_objects_commit(*objects):
    """
    Save objects and commit to database
    :param objects: Objects to save
    """
    db = Info.get_db()
    save_objects(objects)
    db.session.commit()
开发者ID:betterlife,项目名称:psi,代码行数:8,代码来源:db_util.py

示例11: get_related_po

 def get_related_po(sales_order):
     rt = EnumValues.get(const.FRANCHISE_PO_TO_SO_RT_KEY)
     session = Info.get_db().session
     related_value, purchase_order = None, None
     if sales_order.type.code == const.FRANCHISE_SO_TYPE_KEY:
         related_value = session.query(RelatedValues).filter_by(to_object_id=sales_order.id, relation_type_id=rt.id).first()
     if related_value is not None:
         purchase_order = session.query(PurchaseOrder).get(related_value.from_object_id)
     return purchase_order
开发者ID:betterlife,项目名称:psi,代码行数:9,代码来源:sales_order.py

示例12: cleanup_database

def cleanup_database(app_context):
    with app_context:
        db = Info.get_db()
        db.session.remove()
        db.engine.execute('DROP TABLE alembic_version')
        db.engine.execute('DROP VIEW sales_order_detail')
        db.session.commit()
        db.reflect()
        db.drop_all()
开发者ID:betterlife,项目名称:psi,代码行数:9,代码来源:fixture.py

示例13: save_objects

def save_objects(objects):
    """
    Save objects without commit them to database
    :param objects: objects to save 
    """
    db = Info.get_db()
    for obj in objects:
        if obj is not None:
            db.session.add(obj)
开发者ID:betterlife,项目名称:psi,代码行数:9,代码来源:db_util.py

示例14: filter_by_organization

def filter_by_organization(object_type, user=current_user):
    """
    Filter object by user's organization
    :param object_type: Object type to filter
    :param user: User('s Organization) to use for the filter
    :return: List of object filter by the user's organisation
    """
    db = Info.get_db()
    return db.session.query(object_type).filter_by(organization_id=user.organization_id).all()
开发者ID:betterlife,项目名称:psi,代码行数:9,代码来源:db_util.py

示例15: delete_by_id

def delete_by_id(obj_type, id_to_del, commit=True):
    """
    Delete model object by value
    :type obj_type: db.Model
    :type id_to_del: int
    """
    db = Info.get_db()
    obj = db.session.query(obj_type).get(id_to_del)
    db.session.delete(obj)
    if commit:
        db.session.commit()
开发者ID:betterlife,项目名称:psi,代码行数:11,代码来源:db_util.py


注:本文中的psi.app.service.Info类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。