Subversion Repositories SmartDukaan

Rev

Rev 4283 | Rev 4307 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4283 Rev 4295
Line 968... Line 968...
968
    try:
968
    try:
969
        log_risky_flag(item_id, risky)
969
        log_risky_flag(item_id, risky)
970
    except:
970
    except:
971
        print "Not able to log risky flag change"
971
        print "Not able to log risky flag change"
972
    item.risky = risky
972
    item.risky = risky
973
    if not risky and item.status == status.PAUSED:
973
    if not risky and item.status == status.PAUSED_BY_RISK:
974
        change_item_status(item.id, status.ACTIVE)
974
        change_item_status(item.id, status.ACTIVE)
975
    session.commit()
975
    session.commit()
976
    
976
    
977
def get_items_by_vendor_category(vendor_category):
977
def get_items_by_vendor_category(vendor_category):
978
    if not vendor_category:
978
    if not vendor_category:
Line 1223... Line 1223...
1223
    warehouse_ids = [warehouse.id for warehouse in Warehouse.query.filter_by(vendor_id=vendor_id).all()]
1223
    warehouse_ids = [warehouse.id for warehouse in Warehouse.query.filter_by(vendor_id=vendor_id).all()]
1224
    pending_items_inventory = []
1224
    pending_items_inventory = []
1225
    if warehouse_ids:
1225
    if warehouse_ids:
1226
        pending_items_inventory = session.query(CurrentInventorySnapshot.item_id, func.sum(CurrentInventorySnapshot.availibility), func.sum(CurrentInventorySnapshot.reserved)).filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).group_by(CurrentInventorySnapshot.item_id).having(func.sum(CurrentInventorySnapshot.reserved) > 0).all()
1226
        pending_items_inventory = session.query(CurrentInventorySnapshot.item_id, func.sum(CurrentInventorySnapshot.availibility), func.sum(CurrentInventorySnapshot.reserved)).filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).group_by(CurrentInventorySnapshot.item_id).having(func.sum(CurrentInventorySnapshot.reserved) > 0).all()
1227
    return pending_items_inventory
1227
    return pending_items_inventory
-
 
1228
 
-
 
1229
def get_product_notifications(start_datetime):
-
 
1230
    '''
-
 
1231
    Returns a list of Product Notification objects each representing user requests for notification
-
 
1232
    '''
-
 
1233
    query = ProductNotification.query
-
 
1234
    
-
 
1235
    if start_datetime:
-
 
1236
        query = query.filter(ProductNotification.addedOn > start_datetime)
-
 
1237
    
-
 
1238
    notifications = query.order_by(desc('addedOn')).all()
-
 
1239
    return notifications
-
 
1240
 
-
 
1241
def get_product_notification_request_count(start_datetime):
-
 
1242
    '''
-
 
1243
    Returns list of items and the counts of product notification requests
-
 
1244
    '''
-
 
1245
    print start_datetime
-
 
1246
    query = session.query(ProductNotification, func.count(ProductNotification.email).label('count'))
-
 
1247
    
-
 
1248
    if start_datetime:
-
 
1249
        query = query.filter(ProductNotification.addedOn > start_datetime)
1228
    
1250
    
-
 
1251
    counts = query.group_by(ProductNotification.item_id).order_by(desc('count')).all()
-
 
1252
    return counts
-
 
1253
 
1229
def close_session():
1254
def close_session():
1230
    if session.is_active:
1255
    if session.is_active:
1231
        print "session is active. closing it."
1256
        print "session is active. closing it."
1232
        session.close()
1257
        session.close()
1233
 
1258