示例#1
0
文件: __init__.py 项目: shredz/Tool
	def make_deals(self):
		results	= ValueManager.translate_bytes(self.get_deals())
		results = json.loads(results)
		if results['count'] > 0:
			products = results['products']['Product']
			for product in products:
				deal = CDeal ()
				deal.sku 	=		product['sku']
				deal.mid 	=		product['advertiserId']
				deal.isbn 	=		product['isbn']
				deal.m_sku 	=		product['manufacturerSku']
				deal.purchase_url 	=		product['buyUrl']
				deal.description 	=		product['description']
				deal.retailprice 	=		product['retailPrice']
				deal.upc 	=		product['upc']
				deal.manufacturer_name 	=		product['manufacturerName']
				deal.advertiser_name 	=		product['advertiserName']
				deal.currency 	=		product['currency']
				deal.deal_id 	=		product['adId']
				deal.price_amount 	=		product['salePrice']
				deal.price 	=		product['price']
				deal.catalog_id 	=		product['catalogId']
				deal.image_url 	=		product['imageUrl']
				deal.title 	=		product['name']
				
				deal.category	=	Category.objects.get(id=1)
				try:
					deal.save()
				except Exception, ex:
					print ex.message
示例#2
0
文件: views.py 项目: shredz/Tool
def import_deals(request):
    results = CJ.get_deals()
    results = ValueManager.translate_bytes(results)
    results = json.loads(results)

    if results["count"] > 0:
        products = results["products"]["Product"]
        for product in products:
            try:
                dealOnep = datetime.datetime.now()

                dealClose = datetime.datetime(
                    dealOnep.year,
                    int(dealOnep.month) + 2,
                    dealOnep.day,
                    dealOnep.hour,
                    dealOnep.minute,
                    dealOnep.second,
                    dealOnep.microsecond,
                )

                dealExp = datetime.datetime(
                    dealOnep.year,
                    int(dealOnep.month) + 4,
                    dealOnep.day,
                    dealOnep.hour,
                    dealOnep.minute,
                    dealOnep.second,
                    dealOnep.microsecond,
                )

                deal = Deal(
                    title=product["name"],
                    description=product["description"],
                    category=Category.objects.get(id=1),
                    image_url=product["imageUrl"],
                    deal_id=product["adId"],
                    advertiser_name=product["advertiserName"],
                    manufacturer_name=product["manufacturerName"],
                    price=product["salePrice"],
                    value=product["price"],
                    currency=product["currency"],
                    deal_open=dealOnep,
                    deal_close=dealClose,
                    expiration_date=dealExp,
                    sku=product["sku"],
                    upc=product["upc"],
                    catalog_id=product["catalogId"],
                    purchase_url=product["buyUrl"],
                    is_free=False,
                    is_featured=False,
                )
                deal.save()
            except Exception, ex:
                return HttpResponse(ex)
示例#3
0
文件: __init__.py 项目: shredz/Tool
	def make_reports(self, date = '10/13/2011'):
		
		results	= ValueManager.translate_bytes(self.get_daily_reports(date))
		reports = json.loads(results)
		
		print "totalResults : ", reports["totalResults"]
				
		if reports["totalResults"] == '0':
			print "NO RESULTS FOUND FOR PARTICULAR DATE", date
		elif reports["totalResults"] == '1':
			print "JUST ONE REPORT TODAY"
			rep = Report.create_from_dic (reports["publisherCommissions"]["PublisherCommissionV2"])
			self.make_spiff_activity(rep)
		else:
			print "MORE REPORTS!!"
			
			for report in reports["publisherCommissions"]["PublisherCommissionV2"]:
				rep = Report.create_from_dic (report)
				self.make_spiff_activity(rep)