Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rich text for supporter notes #88

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions migrations/0057_alter_supporter_internal_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 4.2.16 on 2024-11-13 16:21

import core.model_utils
from django.db import migrations
from django.template.defaultfilters import linebreaksbr


def linebreaks_to_brs_in_internal_notes(apps, schema_editor):
Supporter = apps.get_model('consortial_billing', 'Supporter')
for supporter in Supporter.objects.all():
new_notes = linebreaksbr(supporter.internal_notes)
supporter.internal_notes = new_notes
supporter.save()


class Migration(migrations.Migration):

dependencies = [
('consortial_billing', '0056_remove_supporter_country'),
]

operations = [
migrations.AlterField(
model_name='supporter',
name='internal_notes',
field=core.model_utils.JanewayBleachField(
blank=True,
help_text='Internal notes on this supporter',
),
),
migrations.RunPython(
linebreaks_to_brs_in_internal_notes,
reverse_code=migrations.RunPython.noop,
)
]
4 changes: 2 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from plugins.consortial_billing import utils, logic, plugin_settings

from core.model_utils import JanewayBleachField
from utils.logger import get_logger
logger = get_logger(__name__)

Expand Down Expand Up @@ -508,8 +509,7 @@ class Supporter(models.Model):
help_text="Whether the supporter is active",
)

internal_notes = models.TextField(
max_length=500,
internal_notes = JanewayBleachField(
blank=True,
help_text="Internal notes on this supporter",
)
Expand Down
4 changes: 3 additions & 1 deletion templates/consortial_billing/supporter_list_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ <h3>
{% endif %}
<details>
<summary>Internal notes</summary>
<p>{{ supporter.internal_notes|linebreaks }}</p>
<div>
{{ supporter.internal_notes|safe }}
</div>
</details>
</div>
<div class="actions">
Expand Down