Skip to content

Commit

Permalink
fix: mailman3 links for nonwg lists (#7507)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsparks authored Jun 6, 2024
1 parent da0a217 commit c5aaab7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ietf/group/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions ietf/mailinglists/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


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)


Expand Down
1 change: 1 addition & 0 deletions ietf/mailinglists/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Meta:
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)


59 changes: 59 additions & 0 deletions ietf/mailinglists/migrations/0004_nonwgmailinglist_domain.py
Original file line number Diff line number Diff line change
@@ -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),
]
3 changes: 2 additions & 1 deletion ietf/mailinglists/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
# 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.
Expand Down
1 change: 1 addition & 0 deletions ietf/mailinglists/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Meta:
filtering = {
"id": ALL,
"name": ALL,
"domain": ALL,
"description": ALL,
}
api.mailinglists.register(NonWgMailingListResource())
Expand Down
2 changes: 2 additions & 0 deletions ietf/mailinglists/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def test_nonwg(self):
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()}\"]"), [])

2 changes: 1 addition & 1 deletion ietf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def skip_unreadable_post(record):
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)
Expand Down

0 comments on commit c5aaab7

Please sign in to comment.