Changeset - ce6174de6d4b
[Not reviewed]
Merge
0 5 9
eximious - 2 years ago 2018-11-19 21:00:11
deb@seagl.org
Merge branch 'master' of ssh://k.sfconservancy.org/website
6 files changed:
0 comments (0 inline, 0 general)
www/conservancy/apps/fundgoal/admin.py
Show inline comments
 
from django.contrib import admin
 
from conservancy.apps.fundgoal.models import FundraisingGoal
 
from conservancy.apps.fundgoal import models as fundgoal_models
 

	
 
class FundraisingGoalAdmin(admin.ModelAdmin):
 
    list_display = ('fundraiser_code_name', 'fundraiser_goal_amount')
 

	
 
admin.site.register(FundraisingGoal, FundraisingGoalAdmin)
 
class GoalProviderAdmin(admin.ModelAdmin):
 
    fields = [
 
        'fundraising_goal',
 
        'provider_name',
 
    ]
 

	
 
admin.site.register(fundgoal_models.FundraisingGoal, FundraisingGoalAdmin)
 
admin.site.register(fundgoal_models.GoalProvider, GoalProviderAdmin)
www/conservancy/apps/fundgoal/migrations/0001_initial.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.10.7 on 2018-11-18 12:09
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    initial = True
 

	
 
    dependencies = [
 
    ]
 

	
 
    operations = [
 
        migrations.CreateModel(
 
            name='FundraisingGoal',
 
            fields=[
 
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 
                ('fundraiser_code_name', models.CharField(max_length=200, unique=True)),
 
                ('fundraiser_goal_amount', models.DecimalField(decimal_places=2, max_digits=10)),
 
                ('fundraiser_so_far_amount', models.DecimalField(decimal_places=2, max_digits=10)),
 
                ('fundraiser_donation_count', models.IntegerField()),
 
                ('fundraiser_donation_count_disclose_threshold', models.IntegerField()),
 
            ],
 
            options={
 
                'ordering': ('fundraiser_code_name',),
 
            },
 
        ),
 
    ]
www/conservancy/apps/fundgoal/migrations/0002_goalprovider.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.10.7 on 2018-11-18 12:11
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 
import django.db.models.deletion
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('fundgoal', '0001_initial'),
 
    ]
 

	
 
    operations = [
 
        migrations.CreateModel(
 
            name='GoalProvider',
 
            fields=[
 
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 
                ('provider_name', models.CharField(max_length=512)),
 
                ('fundraising_goal', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fundgoal.FundraisingGoal')),
 
            ],
 
        ),
 
    ]
www/conservancy/apps/fundgoal/migrations/__init__.py
Show inline comments
 
new file 100644
www/conservancy/apps/fundgoal/models.py
Show inline comments
 
import random
 

	
 
from django.db import models
 
from decimal import *
 

	
 
class FundraisingGoal(models.Model):
 
    """Conservancy fundraiser Goal"""
...
 
@@ -14,7 +15,30 @@ class FundraisingGoal(models.Model):
 
        return self.fundraiser_code_name
 

	
 
    def percentage_there(self):
 
        return (self.fundraiser_so_far_amount / self.fundraiser_goal_amount ) * Decimal('100.00')
 
        return (self.fundraiser_so_far_amount / self.fundraiser_goal_amount ) * 100
 
    
 
    class Meta:
 
        ordering = ('fundraiser_code_name',)
 

	
 
    def providers(self):
 
        return GoalProvider.objects.filter(fundraising_goal=self)
 

	
 
    def random_providers(self, k=None):
 
        providers = self.providers()
 
        if not providers.exists():
 
            return None
 
        elif k is None:
 
            return random.choice(providers)
 
        else:
 
            return random.sample(providers, k)
 

	
 

	
 
class GoalProvider(models.Model):
 
    fundraising_goal = models.ForeignKey(
 
        'FundraisingGoal',
 
        on_delete=models.CASCADE,
 
    )
 
    provider_name = models.CharField(max_length=512)
 

	
 
    def __unicode__(self):
 
        return self.provider_name
www/conservancy/local_context_processors.py
Show inline comments
...
 
@@ -9,7 +9,7 @@ def fundgoal_lookup(fundraiser_sought):
 
        return None
 

	
 
def sitefundraiser(request):
 
    return {'sitefundgoal': fundgoal_lookup('fy-2018-main-match') }
 
    return {'sitefundgoal': fundgoal_lookup('cy2018-end-year-match') }
 

	
 
if conservancy.settings.FORCE_CANONICAL_HOSTNAME:
 
    _HOST_URL_VAR = {'host_url': 'https://' + conservancy.settings.FORCE_CANONICAL_HOSTNAME}

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)