Exemplo n.º 1
0
def logged_in_describe_fundraiser(request,slug):
	try:
		profile = Profile.objects.get(slug=slug)
	except:
		profile = None 

	form = LoggedInFundraiserDescribeForm(request.POST or None)

	describe = DescribeFundraiser(request,form)

	if describe.form_is_valid():
		title = form.cleaned_data['title']
		organization = profile.organization
		description = form.cleaned_data['description']

		if describe.fundraiser_is_unique(title=title,organization=organization,description=description):
			describe.create_fundraiser_with_profile()
			return HttpResponseRedirect(reverse('choose_fundraiser'))
		else:
			title = 'Woops, choose a more unique fundraiser name, there already exists one with the same name.'
			messages.error(request,title)
			return HttpResponseRedirect(reverse('describe_fundraiser'))
		

	template = 'fundraiser/describe_logged_in.html'
	context = {
		'profile' : profile,
		'form' : form
	}
	return render(request,template,context)
Exemplo n.º 2
0
def describe_fundraiser(request):
	
	try:
		del request.session['session_finalized_order']
	except:
		request.session['session_finalized_order'] = None
	
	if request.POST:
		form = FundraiserDescribeForm(request.POST,request.FILES)
	else:
		form = FundraiserDescribeForm(None)
	
	describe = DescribeFundraiser(request,form)
	
	if describe.form_is_valid():

		title         = form.cleaned_data['title']
		organization  = form.cleaned_data['organization']
		description   = form.cleaned_data['description']
		try:
			org_photo = request.FILES['org_photo']
		except:
			org_photo = None

		if describe.fundraiser_is_unique(title=title,organization=organization,description=description,org_photo=org_photo):
			describe.create_fundraiser_with_profile()
			# session = SessionVariable(request)
			# user = session.user().username
			# user_is_authenticated = session.user_is_logged_in()
			# create_fundraiser_with_profile_task.delay(user_is_authenticated,user,title,organization,description,org_photo)
			return HttpResponseRedirect(reverse('choose_fundraiser'))
		else:
			title = 'Woops, choose a more unique fundraiser name, there already exists one with the same name.'
			messages.error(request,title)
			return HttpResponseRedirect(reverse('describe_fundraiser'))

	
	context = {'form' : form}
	template = 'fundraiser/describe.html'

	return render(request,template,context,context_instance=RequestContext(request, processors=[get_home_variables]))