Skip to content
Snippets Groups Projects
Commit e56acb9e authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add funding to the template

parent 38a1fe12
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ class Migration(migrations.Migration): ...@@ -24,7 +24,7 @@ class Migration(migrations.Migration):
('year', models.PositiveIntegerField()), ('year', models.PositiveIntegerField()),
('duration', models.PositiveIntegerField(help_text='In months')), ('duration', models.PositiveIntegerField(help_text='In months')),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='funding', to='people.PersonPage')), ('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='funding', to='people.PersonPage')),
('source', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='wagtailcore.Page')), ('source', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='wagtailcore.Page')),
], ],
options={ options={
'ordering': ['sort_order'], 'ordering': ['sort_order'],
......
...@@ -79,9 +79,7 @@ class Funding(Orderable): ...@@ -79,9 +79,7 @@ class Funding(Orderable):
duration = models.PositiveIntegerField(help_text='In months') duration = models.PositiveIntegerField(help_text='In months')
source = models.ForeignKey( source = models.ForeignKey(
'wagtailcore.Page', 'wagtailcore.Page',
blank=True, on_delete=models.PROTECT,
null=True,
on_delete=models.SET_NULL
) )
panels = [ panels = [
...@@ -172,6 +170,10 @@ class PersonPage(BasePage): ...@@ -172,6 +170,10 @@ class PersonPage(BasePage):
InlinePanel('funding', label='Funding'), InlinePanel('funding', label='Funding'),
] ]
@property
def total_funding(self):
return sum(funding.value for funding in self.funding.all())
class PersonIndexPage(BasePage): class PersonIndexPage(BasePage):
subpage_types = ['PersonPage'] subpage_types = ['PersonPage']
......
...@@ -52,6 +52,18 @@ ...@@ -52,6 +52,18 @@
<h3>{{ item.get_service_display }}</h3> <h3>{{ item.get_service_display }}</h3>
<p>{{ item.profile_url }}</p> <p>{{ item.profile_url }}</p>
{% endfor %} {% endfor %}
<h2>Funding to date</h2>
{% for funding in page.funding.all %}
<table>
<tr>
<td>{{ funding.year }}</td>
<td>${{ funding.value }}</td>
<td>{{ funding.duration }} months</td>
<td><a href="{% pageurl funding.source %}">{{ funding.source }}</a></td>
</tr>
</table>
{% endfor %}
<p>Total FUnding: {{ page.total_funding }}</p>
</div> </div>
</section> </section>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment