fix: mailman3 links for nonwg lists (#7507)
This commit is contained in:
parent
da0a217a8c
commit
c5aaab74b8
|
@ -313,7 +313,7 @@ def active_wgs(request):
|
||||||
if group.list_subscribe.startswith('http'):
|
if group.list_subscribe.startswith('http'):
|
||||||
group.list_subscribe_url = group.list_subscribe
|
group.list_subscribe_url = group.list_subscribe
|
||||||
elif group.list_email.endswith('@ietf.org'):
|
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:
|
else:
|
||||||
group.list_subscribe_url = "mailto:"+group.list_subscribe
|
group.list_subscribe_url = "mailto:"+group.list_subscribe
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ from ietf.mailinglists.models import NonWgMailingList, Allowlisted
|
||||||
|
|
||||||
|
|
||||||
class NonWgMailingListAdmin(admin.ModelAdmin):
|
class NonWgMailingListAdmin(admin.ModelAdmin):
|
||||||
list_display = ('id', 'name', 'description')
|
list_display = ('id', 'name', 'domain', 'description')
|
||||||
search_fields = ('name',)
|
search_fields = ('name', 'domain')
|
||||||
admin.site.register(NonWgMailingList, NonWgMailingListAdmin)
|
admin.site.register(NonWgMailingList, NonWgMailingListAdmin)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ class NonWgMailingListFactory(factory.django.DjangoModelFactory):
|
||||||
model = NonWgMailingList
|
model = NonWgMailingList
|
||||||
|
|
||||||
name = factory.Sequence(lambda n: "list-name-%s" % n)
|
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)
|
description = factory.Faker('sentence', nb_words=10)
|
||||||
|
|
||||||
|
|
||||||
|
|
59
ietf/mailinglists/migrations/0004_nonwgmailinglist_domain.py
Normal file
59
ietf/mailinglists/migrations/0004_nonwgmailinglist_domain.py
Normal 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),
|
||||||
|
]
|
|
@ -14,12 +14,13 @@ from ietf.utils.models import ForeignKey
|
||||||
# while decoupling from mailman2 until we integrate with mailman3
|
# while decoupling from mailman2 until we integrate with mailman3
|
||||||
class NonWgMailingList(models.Model):
|
class NonWgMailingList(models.Model):
|
||||||
name = models.CharField(max_length=32)
|
name = models.CharField(max_length=32)
|
||||||
|
domain = models.CharField(max_length=32, default="ietf.org")
|
||||||
description = models.CharField(max_length=256)
|
description = models.CharField(max_length=256)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "<NonWgMailingList: %s>" % self.name
|
return "<NonWgMailingList: %s>" % self.name
|
||||||
def info_url(self):
|
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
|
# Allowlisted is unused, but is not being dropped until its human-curated content
|
||||||
# is archived outside this database.
|
# is archived outside this database.
|
||||||
|
|
|
@ -41,6 +41,7 @@ class NonWgMailingListResource(ModelResource):
|
||||||
filtering = {
|
filtering = {
|
||||||
"id": ALL,
|
"id": ALL,
|
||||||
"name": ALL,
|
"name": ALL,
|
||||||
|
"domain": ALL,
|
||||||
"description": ALL,
|
"description": ALL,
|
||||||
}
|
}
|
||||||
api.mailinglists.register(NonWgMailingListResource())
|
api.mailinglists.register(NonWgMailingListResource())
|
||||||
|
|
|
@ -38,7 +38,9 @@ class MailingListTests(TestCase):
|
||||||
url = urlreverse("ietf.mailinglists.views.nonwg")
|
url = urlreverse("ietf.mailinglists.views.nonwg")
|
||||||
|
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
|
q = PyQuery(r.content)
|
||||||
for l in lists:
|
for l in lists:
|
||||||
self.assertContains(r, l.name)
|
self.assertContains(r, l.name)
|
||||||
self.assertContains(r, l.description)
|
self.assertContains(r, l.description)
|
||||||
|
self.assertNotEqual(q(f"a[href=\"{l.info_url()}\"]"), [])
|
||||||
|
|
||||||
|
|
|
@ -690,7 +690,7 @@ ALL_ID_DOWNLOAD_DIR = '/a/www/www6s/download'
|
||||||
DOCUMENT_FORMAT_ALLOWLIST = ["txt", "ps", "pdf", "xml", "html", ]
|
DOCUMENT_FORMAT_ALLOWLIST = ["txt", "ps", "pdf", "xml", "html", ]
|
||||||
|
|
||||||
# Mailing list info URL for lists hosted on the IETF servers
|
# 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"
|
MAILING_LIST_ARCHIVE_URL = "https://mailarchive.ietf.org"
|
||||||
|
|
||||||
# Liaison Statement Tool settings (one is used in DOC_HREFS below)
|
# Liaison Statement Tool settings (one is used in DOC_HREFS below)
|
||||||
|
|
Loading…
Reference in a new issue