Exemple #1
0
def home(request):
  """
      Donation home page. Return all of the
      donation objects that are found.
  """
  time_threshold = datetime.now() - timedelta(weeks=52)
  donations = dm.Donation.objects.filter(date__gt=time_threshold)
  anon_donations = dm.AnonDonation.objects.filter(date__gt=time_threshold)

  sorted_donations = sorted(list(chain(donations,
                                       anon_donations)),
                            key=attrgetter('date'), reverse=True)
  page = request.GET.get('page', 1)
  rendered_donations = donation_renderer(
      sorted_donations, page)

  template_values = {
      'page_title': 'Past Donations',
      'nav_donate': 'active',
      'donation_timeline': rendered_donations,
  }

  template_values.update(_get_donation_stats(
      donations, anon_donations))

  return template_values
Exemple #2
0
def donate(request):
  """
      Donate page returns the form for submitting a donation
  """

  template_values = {
      'page_title': 'Make a Donation',
      'nav_donate': 'active',
      'stripe_public_key': env['STRIPE_PUBLIC_KEY'],
  }

  template_values.update(_get_donation_stats())

  if request.user.is_authenticated():
    return user_donate(request, template_values)

  return anon_donate(request, template_values)