-
Notifications
You must be signed in to change notification settings - Fork 1
[R1-297] SCHOLARSHIP SNIPPETS | Character Limit + Links #1142
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
Draft
katdom13
wants to merge
5
commits into
master
Choose a base branch
from
R1-297-scholarship-snippets-character-limits-links
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d54ede
Add new_summary richtext field
katdom13 fc94538
Create manual migration to convert URLs within text to richtext links
katdom13 6ddb7c1
Remove old summary field, rename new_summary to summary
katdom13 4603cc3
Update accordion to render richtext introduction
katdom13 7e26194
Make title character limits longer
katdom13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
rca/scholarships/migrations/0014_scholarship_new_summary.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
49
rca/scholarships/migrations/0015_migrate_summary_to_new_summary.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| ] |
22 changes: 22 additions & 0 deletions
22
...hips/migrations/0016_remove_scholarship_summary_rename_new_summary_scholarship_summary.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
21
rca/scholarships/migrations/0017_alter_scholarship_title.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
rca/utils/migrations/0028_alter_sluggedtaxonomy_slug_and_more.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ticket states:
But we can't really do that, so the simplest solution would just be to make the
max_lengthbigger.