From 1ddcb2e4baddbaeb74c681b4b545073070aee874 2021-11-19 06:56:44 From: Ben Sturmfels Date: 2021-11-19 06:56:44 Subject: [PATCH] Move fundraising goal end times into database. --- diff --git a/www/conservancy/apps/fundgoal/migrations/0003_fundraisinggoal_fundraiser_endtime.py b/www/conservancy/apps/fundgoal/migrations/0003_fundraisinggoal_fundraiser_endtime.py new file mode 100644 index 0000000000000000000000000000000000000000..e7878417798c64da504ff24b082b7f6b17c25cef --- /dev/null +++ b/www/conservancy/apps/fundgoal/migrations/0003_fundraisinggoal_fundraiser_endtime.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2021-11-19 01:45 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fundgoal', '0002_goalprovider'), + ] + + operations = [ + migrations.AddField( + model_name='fundraisinggoal', + name='fundraiser_endtime', + field=models.DateTimeField(null=True), + ), + ] diff --git a/www/conservancy/apps/fundgoal/models.py b/www/conservancy/apps/fundgoal/models.py index 2bb5d6d71694b9352555aec99d15692d49ffe34e..870d61c4887a59a5f6c07439b319bdf334f8ec48 100644 --- a/www/conservancy/apps/fundgoal/models.py +++ b/www/conservancy/apps/fundgoal/models.py @@ -5,11 +5,12 @@ from django.db import models class FundraisingGoal(models.Model): """Conservancy fundraiser Goal""" - fundraiser_code_name = models.CharField(max_length=200, blank=False, unique=True) - fundraiser_goal_amount = models.DecimalField(max_digits=10, decimal_places=2) + fundraiser_code_name = models.CharField(max_length=200, blank=False, unique=True) + fundraiser_goal_amount = models.DecimalField(max_digits=10, decimal_places=2) fundraiser_so_far_amount = models.DecimalField(max_digits=10, decimal_places=2) fundraiser_donation_count = models.IntegerField() fundraiser_donation_count_disclose_threshold = models.IntegerField() + fundraiser_endtime = models.DateTimeField(null=True) def __unicode__(self): return self.fundraiser_code_name diff --git a/www/conservancy/local_context_processors.py b/www/conservancy/local_context_processors.py index 89d465f845544bdd2a650c6a827281444bbdd547..9dfe96323af89e8fe60708e2470590fbc875f93a 100644 --- a/www/conservancy/local_context_processors.py +++ b/www/conservancy/local_context_processors.py @@ -5,14 +5,6 @@ import conservancy.settings from conservancy.apps.fundgoal.models import FundraisingGoal as FundraisingGoal SITE_FUNDGOAL = 'cy2021-end-year-match' -# FIXME: Move this information into the model. -FUNDGOAL_ENDTIMES = { - # Noon UTC = the end of the previous day anywhere on Earth (AOE) - 'cy2018-end-year-match': DateTime(2019, 1, 16, 12, tzinfo=UTC), - 'cy2019-end-year-match': DateTime(2020, 1, 16, 12, tzinfo=UTC), - 'cy2020-end-year-match': DateTime(2021, 1, 16, 12, tzinfo=UTC), - 'cy2021-end-year-match': DateTime(2021, 1, 16, 12, tzinfo=UTC), -} def fundgoal_lookup(fundraiser_sought): try: @@ -23,9 +15,8 @@ def fundgoal_lookup(fundraiser_sought): def sitefundraiser(request): return { - 'datetime_now': DateTime.now(UTC), + 'datetime_now': DateTime.now(), 'sitefundgoal': fundgoal_lookup(SITE_FUNDGOAL), - 'sitefundgoal_endtime': FUNDGOAL_ENDTIMES[SITE_FUNDGOAL], } if conservancy.settings.FORCE_CANONICAL_HOSTNAME: diff --git a/www/conservancy/templates/base_conservancy.html b/www/conservancy/templates/base_conservancy.html index 9a61beaff54013fea9cddd7a917944a3ef66feb8..1d3df6be4f7917d38f7a4184a2c32aa6fa44c79c 100644 --- a/www/conservancy/templates/base_conservancy.html +++ b/www/conservancy/templates/base_conservancy.html @@ -105,10 +105,9 @@ * this_match_remaining: this_match_goal - this_match_so_far {% endcomment %} - -{% if sitefundgoal and sitefundgoal.fundraiser_so_far_amount and datetime_now < sitefundgoal_endtime %} +{% if sitefundgoal and sitefundgoal.fundraiser_so_far_amount and datetime_now < sitefundgoal.fundraiser_endtime %} {% with this_match_goal=sitefundgoal.fundraiser_goal_amount this_match_so_far=sitefundgoal.fundraiser_so_far_amount %} -{% with this_match_remaining=this_match_goal|subtract:this_match_so_far sitefundgoal_timeleft=sitefundgoal_endtime|subtract:datetime_now %} +{% with this_match_remaining=this_match_goal|subtract:this_match_so_far sitefundgoal_timeleft=sitefundgoal.fundraiser_endtime|subtract:datetime_now %}