Changeset - 1ddcb2e4badd
[Not reviewed]
0 3 1
Ben Sturmfels (bsturmfels) - 2 years ago 2021-11-19 06:56:44
ben@sturm.com.au
Move fundraising goal end times into database.
4 files changed with 26 insertions and 15 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/fundgoal/migrations/0003_fundraisinggoal_fundraiser_endtime.py
Show inline comments
 
new file 100644
 
# -*- 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),
 
        ),
 
    ]
www/conservancy/apps/fundgoal/models.py
Show inline comments
...
 
@@ -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
www/conservancy/local_context_processors.py
Show inline comments
...
 
@@ -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:
www/conservancy/templates/base_conservancy.html
Show inline comments
...
 
@@ -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">
0 comments (0 inline, 0 general)