From c8ec7d9581e5c55a8799c9603aa832f4f20c8db6 Mon Sep 17 00:00:00 2001 From: Joseph Muller Date: Wed, 13 Nov 2024 16:41:14 +0000 Subject: [PATCH 1/2] Use rich text for supporter notes #83 --- .../0057_alter_supporter_internal_notes.py | 36 +++++++++++++++++++ models.py | 3 +- .../supporter_list_item.html | 4 ++- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 migrations/0057_alter_supporter_internal_notes.py diff --git a/migrations/0057_alter_supporter_internal_notes.py b/migrations/0057_alter_supporter_internal_notes.py new file mode 100644 index 0000000..c88b054 --- /dev/null +++ b/migrations/0057_alter_supporter_internal_notes.py @@ -0,0 +1,36 @@ +# 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', + max_length=500 + ), + ), + migrations.RunPython( + linebreaks_to_brs_in_internal_notes, + reverse_code=migrations.RunPython.noop, + ) + ] diff --git a/models.py b/models.py index 33353ca..afd5a5a 100755 --- a/models.py +++ b/models.py @@ -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__) @@ -508,7 +509,7 @@ class Supporter(models.Model): help_text="Whether the supporter is active", ) - internal_notes = models.TextField( + internal_notes = JanewayBleachField( max_length=500, blank=True, help_text="Internal notes on this supporter", diff --git a/templates/consortial_billing/supporter_list_item.html b/templates/consortial_billing/supporter_list_item.html index 9791743..a70fb42 100644 --- a/templates/consortial_billing/supporter_list_item.html +++ b/templates/consortial_billing/supporter_list_item.html @@ -47,7 +47,9 @@

{% endif %}
Internal notes -

{{ supporter.internal_notes|linebreaks }}

+
+ {{ supporter.internal_notes|safe }} +
From be675fbde6165fde188a83c91b656b2ac6b12f5f Mon Sep 17 00:00:00 2001 From: Joseph Muller Date: Fri, 15 Nov 2024 09:55:10 +0000 Subject: [PATCH 2/2] Remove max length on text field #83 --- migrations/0057_alter_supporter_internal_notes.py | 1 - models.py | 1 - 2 files changed, 2 deletions(-) diff --git a/migrations/0057_alter_supporter_internal_notes.py b/migrations/0057_alter_supporter_internal_notes.py index c88b054..5e7a96e 100644 --- a/migrations/0057_alter_supporter_internal_notes.py +++ b/migrations/0057_alter_supporter_internal_notes.py @@ -26,7 +26,6 @@ class Migration(migrations.Migration): field=core.model_utils.JanewayBleachField( blank=True, help_text='Internal notes on this supporter', - max_length=500 ), ), migrations.RunPython( diff --git a/models.py b/models.py index afd5a5a..cfe3562 100755 --- a/models.py +++ b/models.py @@ -510,7 +510,6 @@ class Supporter(models.Model): ) internal_notes = JanewayBleachField( - max_length=500, blank=True, help_text="Internal notes on this supporter", )