Пример #1
0
	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
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
	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)
Пример #4
0
def after_connect(request , net_user , network):
	try:
		account = Account.objects.get(uid=net_user['id'])
		
		###
		if request.user.is_authenticated():
			if account.spiffuser.id != request.user.id:
				account.spiffuser = User.instance(request.user)
				
				
				## WARN TO GO WITH THAT ACCOUNT INSTEAD		
		###
		
		backend = get_backends()[0]
		account.spiffuser.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
		userlogin(request,account.spiffuser)
		
		if network == "facebook":
			account.oauth_token = net_user['access_token']
		elif network == "twitter":
			account.oauth_token = net_user['access_token'].key
			account.oauth_token_secret = net_user['access_token'].secret
		account.save()
		
	except Account.DoesNotExist:
		needs_username_correction = False
		
		if request.user.is_authenticated():
			user = User.instance(request.user)
		else:
			country = Country.objects.get(id=1)
				
			phonenumber = PhoneNumber(
				countrycode = 0,
				carriercode = 0,
				number 		= 0,
			)
			phonenumber.save()
				
			address = Address(
				zipcode 		= '',
				street_line_1	= '',	
				street_line_2	= '',
				city			= '',
				state			= '',
				country			= country,
				location 		= country.location,
				phonenumebr		= phonenumber
			)
			
			try:
				loc = get_field(net_user,"location",network)
				address.street_line_1	= loc
				address.city			= loc
			except:
				pass
				
			address.save()
			
			username = get_field(net_user,"username",network)
			
			
			try:
				User.objects.get(username=username)
				username = get_field(net_user,"id",network)
				needs_username_correction = True
				request.session['needs_username_correction'] = True
			except:
				pass
			
			user = User (
				username		= username,
				email			= get_field(net_user,"email",network),
				password		= "******",
				first_name		= '',
				last_name		= '',
				dob				= datetime.datetime.now(),
				gender			= '',
				address			= address,
				verification	= User.create_verification("1",True),
				is_active		= True,
				is_staff		= True,
				points			= 0,
			)
			
			try:
				user.first_name		= get_field(net_user,'first_name',network),
				user.last_name		= get_field(net_user,'last_name',network),
				user.gender			= ValueManager.translate_gender(get_field(net_user,'gender',network))
			except:
				pass
			
			user.save()
			
			backend = get_backends()[0]
			user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
			userlogin(request,user)
		
		token = net_user['access_token']
		del net_user['access_token']
		
		account = Account(
			uid					= get_field(net_user,'id',network),
			oauth_token			= "",
			oauth_token_secret	= "",
			other_data			= json.dumps(net_user),
			spiffuser			= user,
			account_type		= network
		)
		account.save()
		
		if network == "facebook":
			account.oauth_token 		= token
		elif network == "twitter":
			account.oauth_token 		= token.key
			account.oauth_token_secret 	= token.secret
			
		if needs_username_correction:
			return HttpResponseRedirect("/members/profile/")		
			
	return HttpResponseRedirect("/")