Skip to content

Commit

Permalink
fix for notes
Browse files Browse the repository at this point in the history
change cleaning status to use funder financial year
  • Loading branch information
drkane committed Jan 17, 2025
1 parent 44314cd commit 7e13ea4
Show file tree
Hide file tree
Showing 19 changed files with 584 additions and 122 deletions.
1 change: 0 additions & 1 deletion docs/data_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ the `Funder` model in these attributes will be copied to the equivalent `FunderF
| `checked` | Whether this record has been checked by a user |
| `checked_on` | The time at which this record was marked as checked |
| `checked_by` | The user who marked this record as checked |
| `notes` | Any notes made about this financial year when checking |

#### FunderFinancialYear financial data

Expand Down
8 changes: 5 additions & 3 deletions jinja2/grantmakers/partials/funderyear.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
{% if funder_year.account_url %}
<br><a href="{{ funder_year.account_url }}" target="_blank">Accounts PDF</a>
{% endif %}
{% if funder_year.notes %}
{% if funder_year.notes.count() %}
<details>
<summary>Note</summary>
{{ funder_year.notes|markdownify|safe }}<br>
{% for note in funder_year.notes.all() %}
{{ note.note|markdownify|safe }}<br>
{% endfor %}
</details>
{% endif %}
</td>
Expand Down Expand Up @@ -245,7 +247,7 @@
<tr>
<td class="tr">Note</td>
<td colspan="{% if funder_year_py %}3{% else %}2{% endif%}">
<textarea name="note" class="funder-year-edit" rows="7">{{ funder_year.notes or '' }}</textarea>
<textarea name="note" class="funder-year-edit" rows="7"></textarea>
</td>
</tr>
</tbody>
Expand Down
13 changes: 8 additions & 5 deletions jinja2/grantmakers/partials/notes.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
{{ note.note|markdownify|safe }}
</li>
{% endfor %}
{% for funder_financial_year in object.funder_financial_years.filter(notes__isnull=false).exclude(notes__exact='') %}
{% for funder_financial_year in object.funder_financial_years.all() %}
{% for funder_year in funder_financial_year.funder_years.all() %}
{% for note in funder_year.notes.all() %}
<li class="note">
<header>
<strong>FY{{ funder_financial_year.financial_year_id }}</strong>
<time
value="{{ funder_financial_year.checked_on }}">{{ funder_financial_year.checked_on|naturalday }}</time>
by <strong>{{ funder_financial_year.checked_by|user_name }}</strong>
<time value="{{ note.date_added }}">{{ note.date_added|naturalday }}</time>
by <strong>{{ note.added_by }}</strong>
</header>
{{ funder_financial_year.notes|markdownify|safe }}
{{ note.note|markdownify|safe }}
</li>
{% endfor %}
{% endfor %}
{% endfor %}
<li class="note">
<header>Add note</header>
<form action="{{ url_for('grantmakers:add_note', org_id=object.org_id) }}" method="post"
Expand Down
37 changes: 21 additions & 16 deletions jinja2/grantmakers/task/detail.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<li>Showing all records</li>
{% endif %}
</ul>
{% if object._sql_query %}
<details>
<summary>SQL Query</summary>
<pre style="white-space: pre-wrap;">{{ object._sql_query }}</pre>
</details>
{% endif %}
</details>
{% if object.description %}
<p>{{ object.description }}</p>
Expand Down Expand Up @@ -61,26 +67,25 @@
{% if page_obj.object_list %}
{% call wrap_table(class_="sticky") %}
{% for object in page_obj.object_list %}
<tr class="{% if object.funder_financial_year.checked == 'Checked' %}positive{% endif %}">
<tr class="{% if object.checked == 'Checked' %}positive{% endif %}">
<td><a class="b"
href="{{ url_for('grantmakers:detail', org_id=object.funder_financial_year.funder.org_id) }}">{{ object.funder_financial_year.funder.name }}</a>
<td><a
href="{{ url_for('grantmakers:detail', org_id=object.funder_financial_year.funder.org_id) }}">{{ object.funder_financial_year.funder.org_id }}</a>
href="{{ url_for('grantmakers:detail', org_id=object.funder.org_id) }}">{{ object.funder.name }}</a>
<td><a href="{{ url_for('grantmakers:detail', org_id=object.funder.org_id) }}">{{ object.funder.org_id }}</a>
</td>
</td>
<td>{{ display_text(object.funder_financial_year.segment) }}</td>
<td class="tc">{{ display_boolean(object.funder_financial_year.included) }}</td>
<td class="tc">{{ display_boolean(object.funder_financial_year.makes_grants_to_individuals) }}</td>
<td>{{ display_text(object.segment) }}</td>
<td class="tc">{{ display_boolean(object.included) }}</td>
<td class="tc">{{ display_boolean(object.makes_grants_to_individuals) }}</td>
<td>
<ul class="tags">{% for tag in object.funder_financial_year.tags.values_list("tag", flat=true) %}<li>{{ tag }}
<ul class="tags">{% for tag in object.tags.values_list("tag", flat=true) %}<li>{{ tag }}
</li>
{% endfor %}</ul>
</td>
<td class="tc">
<div class="flex-row">
{{ display_boolean(object.funder_financial_year.checked == "Checked") }}
{% if object.funder_financial_year.checked_by %}
{{ object.funder_financial_year.checked_by|user_name }}
{{ display_boolean(object.checked == "Checked") }}
{% if object.checked_by %}
{{ object.checked_by|user_name }}
{% endif %}
</div>
</td>
Expand Down Expand Up @@ -113,13 +118,13 @@
<td class="tr">{{ display_number(object.funds_unrestricted, format_str="£{:,.0f}") }}</td>
<td class="tr">{{ display_number(object.employees, format_str="{:,.0f}") }}</td>
<td class="tr">
This: {{ display_number(object.funder_financial_year.scaling, format_str="{:,.0f}") }}<br>
{% if object.funder_financial_year.funder.current_year %}
This: {{ display_number(object.scaling, format_str="{:,.0f}") }}<br>
{% if object.funder.current_year %}
Current:
{{ display_number(object.funder_financial_year.funder.current_year.scaling, format_str="{:,.0f}") }}<br>
{{ display_number(object.funder.current_year.scaling, format_str="{:,.0f}") }}<br>
{% endif %}
{% if object.funder_financial_year.funder.latest_year %}
Latest: {{ display_number(object.funder_financial_year.funder.latest_year.scaling, format_str="{:,.0f}") }}
{% if object.funder.latest_year %}
Latest: {{ display_number(object.funder.latest_year.scaling, format_str="{:,.0f}") }}
{% endif %}
</td>
</tr>
Expand Down
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ without fetching any new data.

#### `python manage.py update financial-year`

This runs a series of SQL commands to keep the financial data up to date. The commands are:

1. Ensure every funder has a funder financial year for the current financial year
2. Set the current year to the correct year
3. Set the latest year to the correct year
4. Recalculate aggregate values for funder financial years
5. Update current funder financial years with the latest funder data
6. Ensure that the current funder financial year has the correct tags
7. Remove existing tags from the current funder financial year

#### `python manage.py update grants`

#### `python manage.py update grant-recipient-type`
Expand All @@ -203,3 +213,9 @@ Should instead use the endpoint at `/grantmakers/upload`.
#### `python manage.py fetch fgt`

Used to import data from the back catalogue of Foundation Giving Trends.

## Export data as backup

```sh
dokku postgres:export uk-grantmaking-data-db > ~/uk-grantmaking-data-db-20251701.export
```
3 changes: 2 additions & 1 deletion ukgrantmaking/admin/funder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from django.utils.html import format_html

from ukgrantmaking.admin.csv_upload import CSVUploadModelAdmin
Expand All @@ -16,7 +17,7 @@ def funder_count(self, obj):
return obj.funders.count()


class FunderNoteInline(admin.TabularInline):
class FunderNoteInline(GenericTabularInline):
model = FunderNote
extra = 0
fields = (
Expand Down
13 changes: 0 additions & 13 deletions ukgrantmaking/admin/funder_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ class FunderYearInline(admin.StackedInline):
"spending_grant_making_institutions_unknown_manual",
),
("spending_grant_making_institutions",),
(
"checked_by",
"notes",
),
],
},
),
Expand Down Expand Up @@ -126,7 +122,6 @@ class FunderYearAdmin(CSVUploadModelAdmin):
"income",
"spending",
"spending_charitable",
"checked",
)
show_facets = admin.ShowFacets.ALWAYS
list_display_links = ("financial_year_end",)
Expand All @@ -136,8 +131,6 @@ class FunderYearAdmin(CSVUploadModelAdmin):
"funder_financial_year__financial_year__fy",
"funder_financial_year__segment",
"funder_financial_year__category",
"checked",
("checked_by", admin.EmptyFieldListFilter),
)
readonly_fields = (
"income_registered",
Expand All @@ -162,8 +155,6 @@ class FunderYearAdmin(CSVUploadModelAdmin):
"funds_restricted_registered",
"funds_unrestricted_registered",
"employees_registered",
"checked_on",
"checked",
"date_added",
"date_updated",
# "funder_financial_year",
Expand Down Expand Up @@ -254,10 +245,6 @@ class FunderYearAdmin(CSVUploadModelAdmin):
"Checked",
{
"fields": [
"checked",
"checked_on",
"checked_by",
"notes",
"date_added",
"date_updated",
]
Expand Down
Loading

0 comments on commit 7e13ea4

Please sign in to comment.