Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div class="accordion__content-container">
{% if accordion.introduction %}
<div class="accordion__introduction">
{{ accordion.introduction }}
{{ accordion.introduction|richtext }}
</div>
{% endif %}
{{ accordion.body|richtext|linebreaks }}
Expand Down
19 changes: 19 additions & 0 deletions rca/scholarships/migrations/0014_scholarship_new_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.2.11 on 2026-04-01 08:45

import wagtail.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("scholarships", "0013_rename_funding_categories_scholarship_other_criteria"),
]

operations = [
migrations.AddField(
model_name="scholarship",
name="new_summary",
field=wagtail.fields.RichTextField(blank=True),
),
]
49 changes: 49 additions & 0 deletions rca/scholarships/migrations/0015_migrate_summary_to_new_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import re

from django.db import migrations

# Matches https?:// URLs or bare www. URLs
URL_RE = re.compile(r"((?:https?://|www\.)\S+)")


def text_to_richtext(text):
"""
Wrap plain text in a <p> tag, converting bare URLs to <a> links.
Display text for the link is the URL without the scheme prefix.
Bare www. URLs get https:// prepended in the href.
"""

def replace_url(match):
url = match.group(1)
# Strip trailing punctuation that isn't part of the URL
stripped = url.rstrip(".,;:)")
trailing = url[len(stripped):]
if stripped.startswith("www."):
href = f"https://{stripped}"
display = stripped
else:
href = stripped
display = re.sub(r"^https?://", "", stripped)
return f'<a href="{href}">{display}</a>{trailing}'

linked = URL_RE.sub(replace_url, text)
return f"<p>{linked}</p>"


def migrate_summary_forward(apps, schema_editor):
Scholarship = apps.get_model("scholarships", "Scholarship")
for obj in Scholarship.objects.exclude(summary=""):
if not obj.new_summary:
obj.new_summary = text_to_richtext(obj.summary)
obj.save(update_fields=["new_summary"])


class Migration(migrations.Migration):

dependencies = [
("scholarships", "0014_scholarship_new_summary"),
]

operations = [
migrations.RunPython(migrate_summary_forward, migrations.RunPython.noop),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.2.11 on 2026-04-01 10:40

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("scholarships", "0015_migrate_summary_to_new_summary"),
]

operations = [
migrations.RemoveField(
model_name="scholarship",
name="summary",
),
migrations.RenameField(
model_name="scholarship",
old_name="new_summary",
new_name="summary",
),
]
21 changes: 21 additions & 0 deletions rca/scholarships/migrations/0017_alter_scholarship_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.2.11 on 2026-04-01 11:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
(
"scholarships",
"0016_remove_scholarship_summary_rename_new_summary_scholarship_summary",
),
]

operations = [
migrations.AlterField(
model_name="scholarship",
name="title",
field=models.CharField(max_length=255),
),
]
7 changes: 5 additions & 2 deletions rca/scholarships/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ class Meta:

@register_snippet
class Scholarship(models.Model):
title = models.CharField(max_length=50)
title = models.CharField(max_length=255)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ticket states:

remove character limits from Scholarship title fields and other criteria taxonomy.

But we can't really do that, so the simplest solution would just be to make the max_length bigger.

active = models.BooleanField(default=True)
summary = models.CharField(max_length=255, blank=True)
summary = RichTextField(
features=["h3", "bold", "italic", "link"],
blank=True,
)
value = models.CharField(max_length=100)
location = models.ForeignKey(
ScholarshipLocation, null=True, on_delete=models.SET_NULL
Expand Down
23 changes: 23 additions & 0 deletions rca/utils/migrations/0028_alter_sluggedtaxonomy_slug_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.2.11 on 2026-04-01 11:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("utils", "0027_add_little_red_book"),
]

operations = [
migrations.AlterField(
model_name="sluggedtaxonomy",
name="slug",
field=models.SlugField(blank=True, max_length=255),
),
migrations.AlterField(
model_name="sluggedtaxonomy",
name="title",
field=models.CharField(max_length=255),
),
]
4 changes: 2 additions & 2 deletions rca/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,8 @@ class SluggedTaxonomy(models.Model):
as a few are identical
"""

title = models.CharField(max_length=128)
slug = models.SlugField(blank=True, max_length=128)
title = models.CharField(max_length=255)
slug = models.SlugField(blank=True, max_length=255)

def __str__(self):
return self.title
Expand Down
Loading