fix: mailman3 links for nonwg lists (#7507)

This commit is contained in:
Robert Sparks 2024-06-06 13:11:54 -05:00 committed by GitHub
parent da0a217a8c
commit c5aaab74b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 69 additions and 5 deletions

View file

@ -313,7 +313,7 @@ def active_wgs(request):
if group.list_subscribe.startswith('http'):
group.list_subscribe_url = group.list_subscribe
elif group.list_email.endswith('@ietf.org'):
group.list_subscribe_url = MAILING_LIST_INFO_URL % {'list_addr':group.list_email.split('@')[0]}
group.list_subscribe_url = MAILING_LIST_INFO_URL % {'list_addr':group.list_email.split('@')[0].lower(),'domain':'ietf.org'}
else:
group.list_subscribe_url = "mailto:"+group.list_subscribe

View file

@ -8,8 +8,8 @@ from ietf.mailinglists.models import NonWgMailingList, Allowlisted
class NonWgMailingListAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'description')
search_fields = ('name',)
list_display = ('id', 'name', 'domain', 'description')
search_fields = ('name', 'domain')
admin.site.register(NonWgMailingList, NonWgMailingListAdmin)

View file

@ -11,6 +11,7 @@ class NonWgMailingListFactory(factory.django.DjangoModelFactory):
model = NonWgMailingList
name = factory.Sequence(lambda n: "list-name-%s" % n)
domain = factory.Sequence(lambda n: "domain-%s.org" % n)
description = factory.Faker('sentence', nb_words=10)

View file

@ -0,0 +1,59 @@
# Generated by Django 4.2.13 on 2024-06-05 17:51
from django.db import migrations, models
from django.db.models.functions import Lower
IAB_NAMES = ["iab", "iab-stream"]
RFCED_NAMES = [
"auth48archive",
"rfc-dist",
"rfc-editor-rfi",
"rfc-interest",
"rpat",
"rsab",
]
IRTF_NAMES = [
"anrp-select",
"anrw-sc",
"anrw-tpc",
"crypto-panel",
"dtn-interest",
"irsg",
"irtf-announce",
"smart",
"teaching",
"travel-grants-commitee",
]
def forward(apps, schema_editor):
NonWgMailingList = apps.get_model("mailinglists", "NonWgMailingList")
NonWgMailingList.objects.annotate(lowername=Lower("name")).filter(
lowername__in=IAB_NAMES
).update(domain="iab.org")
NonWgMailingList.objects.annotate(lowername=Lower("name")).filter(
lowername__in=IRTF_NAMES
).update(domain="irtf.org")
NonWgMailingList.objects.annotate(lowername=Lower("name")).filter(
lowername__in=RFCED_NAMES
).update(domain="rfc-editor.org")
def reverse(apps, schema_editor):
pass
class Migration(migrations.Migration):
dependencies = [
("mailinglists", "0003_remove_subscribed_lists_delete_list_and_more"),
]
operations = [
migrations.AddField(
model_name="nonwgmailinglist",
name="domain",
field=models.CharField(default="ietf.org", max_length=32),
),
migrations.RunPython(forward, reverse),
]

View file

@ -14,12 +14,13 @@ from ietf.utils.models import ForeignKey
# while decoupling from mailman2 until we integrate with mailman3
class NonWgMailingList(models.Model):
name = models.CharField(max_length=32)
domain = models.CharField(max_length=32, default="ietf.org")
description = models.CharField(max_length=256)
def __str__(self):
return "<NonWgMailingList: %s>" % self.name
def info_url(self):
return settings.MAILING_LIST_INFO_URL % {'list_addr': self.name }
return settings.MAILING_LIST_INFO_URL % {'list_addr': self.name.lower(), 'domain': self.domain.lower() }
# Allowlisted is unused, but is not being dropped until its human-curated content
# is archived outside this database.

View file

@ -41,6 +41,7 @@ class NonWgMailingListResource(ModelResource):
filtering = {
"id": ALL,
"name": ALL,
"domain": ALL,
"description": ALL,
}
api.mailinglists.register(NonWgMailingListResource())

View file

@ -38,7 +38,9 @@ class MailingListTests(TestCase):
url = urlreverse("ietf.mailinglists.views.nonwg")
r = self.client.get(url)
q = PyQuery(r.content)
for l in lists:
self.assertContains(r, l.name)
self.assertContains(r, l.description)
self.assertNotEqual(q(f"a[href=\"{l.info_url()}\"]"), [])

View file

@ -690,7 +690,7 @@ ALL_ID_DOWNLOAD_DIR = '/a/www/www6s/download'
DOCUMENT_FORMAT_ALLOWLIST = ["txt", "ps", "pdf", "xml", "html", ]
# Mailing list info URL for lists hosted on the IETF servers
MAILING_LIST_INFO_URL = "https://www.ietf.org/mailman/listinfo/%(list_addr)s"
MAILING_LIST_INFO_URL = "https://mailman3.%(domain)s/mailman3/lists/%(list_addr)s.%(domain)s"
MAILING_LIST_ARCHIVE_URL = "https://mailarchive.ietf.org"
# Liaison Statement Tool settings (one is used in DOC_HREFS below)