def detail(request, challenge_id): nav_selected = "challenges" challenge = get_object_or_404(Challenge.objects.select_related(), id=challenge_id) if request.user.is_authenticated(): initial = { 'first_name': request.user.first_name, 'last_name': request.user.last_name, 'email': request.user.email, } profile = request.user.get_profile() if profile.geom: initial['geom'] = profile.geom.formatted_address else: initial = {} form = PetitionForm(challenge=challenge, data=(request.POST or None), initial=initial) if form.is_valid(): form.save() messages.success(request, _('Thanks for your support')) from groups.views import group_join for group_id in request.POST.getlist("join_group"): group_join(request, group_id) return redirect('challenges_detail', challenge_id=challenge_id) supporters = Support.objects.filter(challenge=challenge).order_by("-pledged_at") has_manager_privileges = challenge.has_manager_privileges(request.user) groups_to_join = challenge.groups.all() groups_to_join = groups_to_join.filter(is_external_link_only=False) if request.user.is_authenticated(): groups_to_join = groups_to_join.exclude(groupusers__user=request.user) return render_to_response('challenges/detail.html', locals(), context_instance=RequestContext(request))
def detail(request, challenge_id): nav_selected = "challenges" challenge = get_object_or_404(Challenge.objects.select_related(), id=challenge_id) if request.user.is_authenticated(): initial = { 'first_name': request.user.first_name, 'last_name': request.user.last_name, 'email': request.user.email, } if request.user.get_profile().location: initial['zipcode'] = request.user.get_profile().location.zipcode else: initial = {} form = PetitionForm(challenge=challenge, data=(request.POST or None), initial=initial) if form.is_valid(): form.save() messages.success(request, 'Thanks for your support') return redirect('challenges_detail', challenge_id=challenge_id) supporters = Support.objects.filter( challenge=challenge).order_by("-pledged_at")[:12] return render_to_response('challenges/detail.html', locals(), context_instance=RequestContext(request))
def detail(request, challenge_id): nav_selected = "challenges" challenge = get_object_or_404(Challenge.objects.select_related(), id=challenge_id) if request.user.is_authenticated(): initial = { 'first_name': request.user.first_name, 'last_name': request.user.last_name, 'email': request.user.email, } if request.user.get_profile().location: initial['zipcode'] = request.user.get_profile().location.zipcode else: initial = {} form = PetitionForm(challenge=challenge, data=(request.POST or None), initial=initial) if form.is_valid(): form.save() messages.success(request, 'Thanks for your support') return redirect('challenges_detail', challenge_id=challenge_id) supporters = Support.objects.filter(challenge=challenge).order_by("-pledged_at")[:12] return render_to_response('challenges/detail.html', locals(), context_instance=RequestContext(request))