Subversion Repositories SmartDukaan

Rev

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

Rev 12647 Rev 12649
Line 2264... Line 2264...
2264
        except:
2264
        except:
2265
            print "Error: unable to send email."
2265
            print "Error: unable to send email."
2266
            
2266
            
2267
def sendAlertForCantCompete(timestamp):
2267
def sendAlertForCantCompete(timestamp):
2268
    cantCompeteItemsList = session.query(AmazonScrapingHistory).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
2268
    cantCompeteItemsList = session.query(AmazonScrapingHistory).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
2269
    print "type of cantCompeteItemList ",type(cantCompeteItemsList)
-
 
2270
    print "after conversion ",type(list(cantCompeteItemsList))
2269
    print cantCompeteItemsList
2271
    if cantCompeteItemsList is None or len(cantCompeteItemsList)==0:
2270
    if cantCompeteItemsList is None or len(cantCompeteItemsList)==0:
2272
        return
2271
        return
2273
    xstr = lambda s: s or ""
2272
    xstr = lambda s: s or ""
2274
    message="""<html>
2273
    message="""<html>
2275
            <body>
2274
            <body>
Line 2291... Line 2290...
2291
            <th>Proposed SP<th>
2290
            <th>Proposed SP<th>
2292
            <th>Inventory</th>
2291
            <th>Inventory</th>
2293
            <th>Sales History</th>
2292
            <th>Sales History</th>
2294
            </tr></thead>
2293
            </tr></thead>
2295
            <tbody>"""
2294
            <tbody>"""
2296
    cantCompeteItems =  sorted(list(cantCompeteItemsList), key=itemgetter('ourInventory'))
2295
    cantCompeteItems = sorted(list(cantCompeteItemsList), key=lambda x: x.ourInventory, reverse=True)
2297
    for cantCompeteItem in cantCompeteItems:
2296
    for cantCompeteItem in cantCompeteItems:
2298
        amScraping = cantCompeteItem
2297
        amScraping = cantCompeteItem
2299
        item = Item.query.filter_by(id=amScraping.item_id).one()
2298
        item = Item.query.filter_by(id=amScraping.item_id).one()
2300
        if amScraping.warehouseLocation==1:
2299
        if amScraping.warehouseLocation==1:
2301
            sku='FBA'+str(amScraping.item_id)
2300
            sku='FBA'+str(amScraping.item_id)