mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
* Ensure links are prepended with base URL on receipt * Bug fix (cherry picked from commit 3253a4a93c61c405da6c5d62ddd80bf74579e4c2) Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
parent
2bccbffe56
commit
343f63c6ba
@ -33,7 +33,8 @@ from . import config, locales
|
|||||||
|
|
||||||
checkMinPythonVersion()
|
checkMinPythonVersion()
|
||||||
|
|
||||||
INVENTREE_NEWS_URL = 'https://inventree.org/news/feed.atom'
|
INVENTREE_BASE_URL = 'https://inventree.org'
|
||||||
|
INVENTREE_NEWS_URL = f'{INVENTREE_BASE_URL}/news/feed.atom'
|
||||||
|
|
||||||
# Determine if we are running in "test" mode e.g. "manage.py test"
|
# Determine if we are running in "test" mode e.g. "manage.py test"
|
||||||
TESTING = 'test' in sys.argv or 'TESTING' in os.environ
|
TESTING = 'test' in sys.argv or 'TESTING' in os.environ
|
||||||
|
@ -29,5 +29,5 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(set_default_currency),
|
migrations.RunPython(set_default_currency, reverse_code=migrations.RunPython.noop),
|
||||||
]
|
]
|
||||||
|
@ -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
|
||||||
|
)
|
||||||
|
]
|
@ -70,6 +70,10 @@ def update_news_feed():
|
|||||||
if entry.id in id_list:
|
if entry.id in id_list:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Enforce proper links for the entries
|
||||||
|
if entry.link and str(entry.link).startswith('/'):
|
||||||
|
entry.link = settings.INVENTREE_BASE_URL + str(entry.link)
|
||||||
|
|
||||||
# Create entry
|
# Create entry
|
||||||
try:
|
try:
|
||||||
NewsFeedEntry.objects.create(
|
NewsFeedEntry.objects.create(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user