diff --git a/ietf/group/views.py b/ietf/group/views.py index 7ad6e5bf0..0c37cca3a 100644 --- a/ietf/group/views.py +++ b/ietf/group/views.py @@ -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 diff --git a/ietf/mailinglists/admin.py b/ietf/mailinglists/admin.py index 51b906053..081ee6477 100644 --- a/ietf/mailinglists/admin.py +++ b/ietf/mailinglists/admin.py @@ -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) diff --git a/ietf/mailinglists/factories.py b/ietf/mailinglists/factories.py index 1a3b0ffa1..3be5770d7 100644 --- a/ietf/mailinglists/factories.py +++ b/ietf/mailinglists/factories.py @@ -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) diff --git a/ietf/mailinglists/migrations/0004_nonwgmailinglist_domain.py b/ietf/mailinglists/migrations/0004_nonwgmailinglist_domain.py new file mode 100644 index 000000000..b977313a8 --- /dev/null +++ b/ietf/mailinglists/migrations/0004_nonwgmailinglist_domain.py @@ -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), + ] diff --git a/ietf/mailinglists/models.py b/ietf/mailinglists/models.py index f575ffe5a..828d3823a 100644 --- a/ietf/mailinglists/models.py +++ b/ietf/mailinglists/models.py @@ -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 "" % 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. diff --git a/ietf/mailinglists/resources.py b/ietf/mailinglists/resources.py index b075d1807..4d1713b7b 100644 --- a/ietf/mailinglists/resources.py +++ b/ietf/mailinglists/resources.py @@ -41,6 +41,7 @@ class NonWgMailingListResource(ModelResource): filtering = { "id": ALL, "name": ALL, + "domain": ALL, "description": ALL, } api.mailinglists.register(NonWgMailingListResource()) diff --git a/ietf/mailinglists/tests.py b/ietf/mailinglists/tests.py index 0b44d28c7..8c5a550df 100644 --- a/ietf/mailinglists/tests.py +++ b/ietf/mailinglists/tests.py @@ -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()}\"]"), []) diff --git a/ietf/settings.py b/ietf/settings.py index 95a8ad4e4..4f0bba20a 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -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)