fix: better archive search links for group documents (#6835)
This commit is contained in:
parent
e24fb601db
commit
3312913c6f
24
ietf/group/migrations/0004_modern_list_archive.py
Normal file
24
ietf/group/migrations/0004_modern_list_archive.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Copyright The IETF Trust 2023, All Rights Reserved
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db.models import Value
|
||||||
|
from django.db.models.functions import Replace
|
||||||
|
|
||||||
|
|
||||||
|
def forward(apps, schema_editor):
|
||||||
|
Group = apps.get_model("group", "Group")
|
||||||
|
old_pattern = f"{settings.MAILING_LIST_ARCHIVE_URL}/arch/search/?email_list="
|
||||||
|
new_pattern = f"{settings.MAILING_LIST_ARCHIVE_URL}/arch/browse/"
|
||||||
|
|
||||||
|
Group.objects.filter(list_archive__startswith=old_pattern).update(
|
||||||
|
list_archive=Replace("list_archive", Value(old_pattern), Value(new_pattern))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("group", "0003_iabworkshops"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [migrations.RunPython(forward)]
|
|
@ -431,7 +431,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if doc.group and doc.group.list_archive %}
|
{% if doc.group and doc.group.list_archive %}
|
||||||
{% if doc.group.list_archive|startswith:settings.MAILING_LIST_ARCHIVE_URL %}
|
{% if doc.group.list_archive|startswith:settings.MAILING_LIST_ARCHIVE_URL %}
|
||||||
<a href="{{ doc.group.list_archive }}?q={{ doc.name }}">
|
<a href="{{ doc.group.list_archive }}?q={{ doc.name }}{% if doc.came_from_draft %} OR %22{{ doc.came_from_draft.name }}%22{% endif%}">
|
||||||
Mailing list discussion
|
Mailing list discussion
|
||||||
</a>
|
</a>
|
||||||
{% elif doc.group.list_archive|is_valid_url %}
|
{% elif doc.group.list_archive|is_valid_url %}
|
||||||
|
|
Loading…
Reference in a new issue