Subversion Repositories SmartDukaan

Rev

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

Rev 5213 Rev 5217
Line 198... Line 198...
198
        ds_item.startDate = None
198
        ds_item.startDate = None
199
    if item.retireDate:
199
    if item.retireDate:
200
        ds_item.retireDate = to_py_date(item.retireDate)
200
        ds_item.retireDate = to_py_date(item.retireDate)
201
    else:
201
    else:
202
        ds_item.retireDate = None
202
        ds_item.retireDate = None
-
 
203
 
-
 
204
    if item.expectedArrivalDate:
-
 
205
        ds_item.expectedArrivalDate = to_py_date(item.expectedArrivalDate)
-
 
206
    else:
-
 
207
        ds_item.expectedArrivalDate = None
-
 
208
    
-
 
209
    if item.comingSoonStartDate:
-
 
210
        ds_item.comingSoonStartDate = to_py_date(item.comingSoonStartDate)
-
 
211
    else:
-
 
212
        ds_item.comingSoonStartDate = None
-
 
213
    
203
    
214
    
204
    ds_item.feature_id = item.featureId
215
    ds_item.feature_id = item.featureId
205
    ds_item.feature_description = item.featureDescription
216
    ds_item.feature_description = item.featureDescription
206
    
217
    
207
    if ds_item.bestDealText or item.bestDealText:
218
    if ds_item.bestDealText or item.bestDealText:
Line 285... Line 296...
285
    ds_item.updatedOn = datetime.datetime.now()
296
    ds_item.updatedOn = datetime.datetime.now()
286
    if item.startDate:
297
    if item.startDate:
287
        ds_item.startDate = to_py_date(item.startDate)
298
        ds_item.startDate = to_py_date(item.startDate)
288
    if item.retireDate:
299
    if item.retireDate:
289
        ds_item.retireDate = to_py_date(item.retireDate)
300
        ds_item.retireDate = to_py_date(item.retireDate)
-
 
301
    if item.comingSoonStartDate:
-
 
302
        ds_item.comingSoonStartDate = to_py_date(item.comingSoonStartDate)
290
    
303
    if item.expectedArrivalDate:
-
 
304
        ds_item.expectedArrivalDate = to_py_date(item.expectedArrivalDate)    
291
    if item.mrp:
305
    if item.mrp:
292
        ds_item.mrp = item.mrp
306
        ds_item.mrp = item.mrp
293
    if item.sellingPrice:
307
    if item.sellingPrice:
294
        ds_item.sellingPrice = item.sellingPrice
308
        ds_item.sellingPrice = item.sellingPrice
295
    if item.weight:
309
    if item.weight:
Line 1003... Line 1017...
1003
    '''
1017
    '''
1004
    query = get_best_deals_counting_query(obj, category, brand)
1018
    query = get_best_deals_counting_query(obj, category, brand)
1005
    query = query.group_by(Item.catalog_item_id).order_by(desc(Item.bestDealValue))
1019
    query = query.group_by(Item.catalog_item_id).order_by(desc(Item.bestDealValue))
1006
    return query
1020
    return query
1007
 
1021
 
-
 
1022
def get_coming_soon(category=-1):
-
 
1023
    '''
-
 
1024
    Returns the Coming Soon items in the given category. Ignores the category if it's passed as -1.
-
 
1025
    '''
-
 
1026
    query = get_coming_soon_query(Item, category, None)
-
 
1027
    items = query.all()
-
 
1028
    return get_thrift_item_list(items)
-
 
1029
 
-
 
1030
def get_coming_soon_count(category=-1):
-
 
1031
    '''
-
 
1032
    Returns the count of coming in the given category.
-
 
1033
    Ignores the category if it's -1.
-
 
1034
    '''
-
 
1035
    count = get_coming_soon_counting_query(func.count(distinct(Item.catalog_item_id)), category, None).scalar()
-
 
1036
    if count is None:
-
 
1037
        count = 0
-
 
1038
    return count
-
 
1039
 
-
 
1040
def get_coming_soon_catalog_ids(start_index, stop_index, brand, category=-1):
-
 
1041
    '''
-
 
1042
    Returns the catalog_item_ids of coming soon items for the given brand and category.
-
 
1043
    Ignores the category if it's passed as -1 and the brand if it's passed as None.
-
 
1044
    '''
-
 
1045
    query = get_coming_soon_query(Item, category, brand)
-
 
1046
    coming_soon_items = query.all()[start_index:stop_index]
-
 
1047
    return [item.catalog_item_id for item in coming_soon_items]
-
 
1048
 
-
 
1049
def get_coming_soon_counting_query(obj, category, brand):
-
 
1050
    '''
-
 
1051
    Returns the query to be used to select the coming soon product in the given brand and category.
-
 
1052
    Ignores the category if it's passed as -1 and the brand if it's passed as None. 
-
 
1053
    '''
-
 
1054
    query = session.query(obj).filter_by(status=status.COMING_SOON)
-
 
1055
    if category != -1:
-
 
1056
        all_categories = [category]
-
 
1057
        child_categories = get_child_categories(category)
-
 
1058
        if child_categories is not None:
-
 
1059
            all_categories = all_categories + child_categories 
-
 
1060
        query = query.filter(Item.category.in_(all_categories))
-
 
1061
    if brand is not None:
-
 
1062
        query = query.filter_by(brand=brand)
-
 
1063
    return query
-
 
1064
 
-
 
1065
def get_coming_soon_query(obj, category, brand):
-
 
1066
    '''
-
 
1067
    Returns the query to be used to get the coming soon products in the given category and brand.
-
 
1068
    Ignores the category if it's passed as -1 and the brand if it's passed as None.
-
 
1069
    '''
-
 
1070
    query = get_coming_soon_counting_query(obj, category, brand)
-
 
1071
    query = query.group_by(Item.catalog_item_id).order_by(asc(Item.comingSoonStartDate))
-
 
1072
    return query
-
 
1073
 
1008
def get_latest_arrivals(limit, category=-1):
1074
def get_latest_arrivals(limit, category=-1):
1009
    '''
1075
    '''
1010
    Returns up to limit number of Latest Arrivals in the given category.
1076
    Returns up to limit number of Latest Arrivals in the given category.
1011
    '''
1077
    '''
1012
    categories = []
1078
    categories = []