Move fundraising goal end times into database.

This commit is contained in:
Ben Sturmfels 2021-11-19 17:56:44 +11:00
parent b4c438322c
commit 1ddcb2e4ba
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
4 changed files with 26 additions and 15 deletions

View file

@ -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),
),
]

View file

@ -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

View file

@ -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:

View file

@ -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 %}
<div class="fundraiser-top-text ph3 pt2 pb3">
<div class="mw8 center ph2 ph4-ns">
<div class="mt2 mb3 tc">