Changeset - 621ace848827
[Not reviewed]
0 2 1
Brett Smith (brett) - 5 years ago 2018-11-18 19:39:18
brett@sfconservancy.org
fundgoal: Add goal providers.
3 files changed with 44 insertions and 2 deletions:
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/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/models.py
Show inline comments
 
from django.db import models
 
from decimal import *
 

	
 
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_so_far_amount = models.DecimalField(max_digits=10, decimal_places=2)
 
    fundraiser_donation_count = models.IntegerField()
 
    fundraiser_donation_count_disclose_threshold = models.IntegerField()
 

	
 
    def __unicode__(self):
 
        return self.fundraiser_code_name
 

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

	
 

	
 
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
0 comments (0 inline, 0 general)