membershipworks: Use django functions to sanitize Member mailbox
This commit is contained in:
parent
aa87026e99
commit
39f97dd6f9
@ -1,3 +1,5 @@
|
|||||||
|
import django.core.mail.message
|
||||||
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q, Count, BooleanField
|
from django.db.models import Q, Count, BooleanField
|
||||||
|
|
||||||
@ -160,6 +162,12 @@ class Member(models.Model):
|
|||||||
db_table = "members"
|
db_table = "members"
|
||||||
ordering = ("first_name", "last_name")
|
ordering = ("first_name", "last_name")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sanitized_mailbox(self):
|
||||||
|
return django.core.mail.message.sanitize_address(
|
||||||
|
(self.account_name, self.email), settings.DEFAULT_CHARSET
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MemberFlag(models.Model):
|
class MemberFlag(models.Model):
|
||||||
member = models.ForeignKey(Member, on_delete=models.PROTECT, db_column="uid")
|
member = models.ForeignKey(Member, on_delete=models.PROTECT, db_column="uid")
|
||||||
|
@ -38,7 +38,7 @@ class CertificationDefinitionViewSet(viewsets.ModelViewSet):
|
|||||||
for cert in version.certification_set.all():
|
for cert in version.certification_set.all():
|
||||||
if cert.member and cert.member.is_active:
|
if cert.member and cert.member.is_active:
|
||||||
lists[definition.mailing_list].add(
|
lists[definition.mailing_list].add(
|
||||||
f"{cert.member.account_name} <{cert.member.email}>"
|
cert.member.sanitized_mailbox
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response(lists)
|
return Response(lists)
|
||||||
|
Loading…
Reference in New Issue
Block a user