-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure links are prepended with base URL on receipt
- Loading branch information
1 parent
331692b
commit b5fa7be
Showing
4 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
39 changes: 39 additions & 0 deletions
39
src/backend/InvenTree/common/migrations/0031_auto_20241026_0024.py
This file contains 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,39 @@ | ||
# Generated by Django 4.2.16 on 2024-10-26 00:24 | ||
|
||
from django.conf import settings | ||
from django.db import migrations | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('inventree') | ||
|
||
|
||
def update_news_feed_urls(apps, schema_editor): | ||
"""Update and validate the news feed URLs.""" | ||
|
||
from common.models import NewsFeedEntry | ||
|
||
n = 0 | ||
|
||
for entry in NewsFeedEntry.objects.all(): | ||
if entry.link and entry.link.startswith('/'): | ||
entry.link = settings.INVENTREE_BASE_URL + entry.link | ||
entry.save() | ||
n += 1 | ||
|
||
if n > 0: | ||
logger.info("Updated link for %s NewsFeedEntry objects", n) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('common', '0030_barcodescanresult'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
update_news_feed_urls, | ||
reverse_code=migrations.RunPython.noop | ||
) | ||
] |
This file contains 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