Beispiel #1
0
def dashboard(request):
	if request.user.is_authenticated():
		params = {}
		
		params["user"] = User.instance(request.user)
	
		#1- activities chart
		params["activities"]	=	Activity.chart(params["user"],5)
		
		#2- my deals [deals he is interested in]
		params["mydeals"] =	UserDeal.objects.filter(user=params["user"]).extra(order_by=['-added'])[:5]
		
		#3- friends
		params["friends"] = params["user"].friends
		
		#4- recent activities
		params["recent_points"] = Activity.recent(params["user"],5)
		
		
		#-5 rewards
		
		
		#-6 invite
		params["iform"] = InvitationForm()
		
		
		
		
		
		return Response.render("members/dashboard.html",params,request)
	else:
		return Response.send_to_login(request)
Beispiel #2
0
def settings_view(request):
	if request.user.is_authenticated():
		if request.method == 'POST': 
			for cid in request.POST: 
				try:
					c = Config.objects.get(id=cid)
					c.value = request.POST[cid]
					c.save()
				except:
					pass
		
		configList = User.instance(request.user).get_all_config()
		
		clm 		= 1
		total_clm	= 2
		
		table = []
		row   = {}
		
		for title in configList:
			row[title] = configList[title]
			clm = clm + 1
			if clm > total_clm:
				table.append(row)
				row = {}
		
		table.append(row)
		
		c = {"table":table}
		
		c.update(csrf(request))	
		return Response.render("members/settings.html", c , request)
	else:
		return Response.send_to_login(request)
Beispiel #3
0
def share_deal(request,deal_id):
	if not request.user.is_authenticated():
		return Response.send_to_login(request)
	
	user = User.instance(request.user)
	facebook = Account.get_for_user(user,"facebook")
	
	if not facebook:
		return HttpResponse("Not connected TO facebook YET")
		
	
	try:
		deal = Deal.objects.get(id=deal_id)		
		deal = Deal.assign_left([deal])[0]
		deal.link = "http://ldev.spiffcity.com/spiffs/deal/"+str(deal.id)+"/"
		
		##TODO create activity to get points
		
		deal.shared(user)
		
		##
		
		return Response.render("spiffs/fbshare.html",{"deal":deal,"fb_api_key":settings.CRED['FACEBOOK_APP_ID'],"access_token":facebook.oauth_token},request)
		
		#fb = Facebook(settings.CRED['FACEBOOK_APP_ID'] ,settings.CRED['FACEBOOK_APP_SECRET'],settings.CRED['FACEBOOK_RETURN_URL'])
		#data = fb.share_deal(facebook, deal)
		#Response.html(data)
		#return Response.render("spiffs/deal.html",{"deal":deal},request)
		
	except Deal.DoesNotExist, dne :
		Response.not_found()
Beispiel #4
0
def new_deals(request,page):	
	new_deals	 = Deal.objects.list_new(int(page) , 20)
	
	left = new_deals[0:10]
	right = new_deals[10:20]
	
	#Response.html(len(new))
	
	return Response.render("spiffs/new_deals.html" , {"deals": [left , right] , "page" : page , "nextpage" : int(page) + 1 },request)
Beispiel #5
0
def index(request):
	if not request.user.is_authenticated():
		return Response.send_to_login(request)
	
	user = User.instance(request.user)
	params = {"errors":[]}
	
	params["facebook"] = Account.get_for_user(user,"facebook")
	params["twitter"] = Account.get_for_user(user,"twitter")
		
	return Response.render("social/social.html",params,request)
Beispiel #6
0
def deals (request,page):
	if request.user.is_authenticated():
		user = User.instance(request.user)
		layout = user.get_config("Layout").value
	else:
		layout = 0
	
	deals, names = front_page(request, layout, "CJ" , int(page))	
	
	#return Response.html(len(deals))
	if len(deals) == 0:
		return Response.html("<!-- END -->")
	
	params = {'deals' :  deals , "names" : names,"layout":layout}
	return Response.render("spiffs/schemes/"+str(layout)+".html" , params,request)
Beispiel #7
0
def deal(request,deal_type,deal_id):
	try:
		if deal_type == "CJ":
			deal = CDeal.objects.get(id=deal_id)
			#TRACKING = "&sid=%s" % (request.user.id)
			
		elif deal_type == "LS":
			deal = LDeal.objects.get(id=deal_id)
			#TRACKING = "&u1=%s" % (request.user.id)
			
		else:
			deal = Deal.objects.get(id=deal_id)
			#TRACKING = "&u1=%s&sid=%s" % (request.user.id, request.user.id)
		
		
		deal.purchase_url  = "/spiffs/v/%s/%s/" % (deal_type, deal.id)
		deal.link = "http://dev.spiffcity.com/spiffs/deal/%s/%s/" % (deal_type, deal.id)
		return Response.render("spiffs/deal.html",{"deal":deal},request)
		
	except Deal.DoesNotExist, dne :
		Response.not_found()
Beispiel #8
0
def invite(request):
	if not request.user.is_authenticated():
		return Response.send_to_login(request)
	
	message = None
	
	if request.method == 'POST': 
		form = InvitationForm(request.POST)
		if form.is_valid():	
			
			
			p = Prospect(
							email = form.cleaned_data['email'],
							first_name	= form.cleaned_data['first_name'],
							last_name = form.cleaned_data['last_name'],
							source	= "Invitation"
							)
			p.save()
			
			
			
			invitation = Invitation(			
						sender 		= User.instance(request.user),
						prospect 	= p
					)
			invitation.create_curl()
			invitation.save()
			invitation.sendmail()
		
			message = "An invitation has been sent to %s " % (p.email)
			form = InvitationForm()	
		else:
			pass
	else:
		form = InvitationForm()
	
	return Response.render ("members/invite.html",{"form" : form , "appId" : settings.CRED["FACEBOOK_APP_ID"], "message" : message},request)
Beispiel #9
0
								"username" 		: un,
								"email" 		: em,
								"first_name" 	: fn,
								"last_name" 	: ln,
								"gender" 		: user.gender,
								"dob" 			: user.dob,
								"zipcode" 		: user.address.zipcode,
								"street_line_1" : user.address.street_line_1,
								"street_line_2" : user.address.street_line_2,
								"city" 			: user.address.city,
								"state" 		: user.address.state,
								"country" 		: user.address.country.id,
							}
						)
		param['errors'] = False		
	return Response.render ('members/profile.html',param,request)
	

def signup (request):
	if request.user.is_authenticated():
		return HttpResponseRedirect('/members/')
			
	if request.method == 'POST': 
		form = SignupForm(request.POST)
		
		
		if form.is_valid():
			email1		= form.cleaned_data['email']
			email2		= form.cleaned_data['email2']
		
			if email1 != email2:
Beispiel #10
0
def index(request):
	return Response.render("general/main.html" , {},request)
Beispiel #11
0
def groupon(request):
	return Response.render("general/groupon.html",{},request)
Beispiel #12
0
def merchants(request):
	return Response.render("general/merchants.html",{},request)
Beispiel #13
0
def about(request):
	return Response.render("general/aboutus.html",{},request)
Beispiel #14
0
def howitworks(request):
	return Response.render("general/howitworks.html",{},request)
Beispiel #15
0
def search(request):
	if request.method == "POST":
		keyword = request.POST['str']
		params = {'deals' : Deal.search(keyword) }
		return Response.render("spiffs/deals.html" , params,request)
Beispiel #16
0
def show_deal(request,page):	
	catgs = Category.objects.values('title').distinct()[:10]
	return Response.render("spiffs/show_deal.html" , {'catgs': catgs},request)