def setup_func(): mlist = MailingList(name = list_name, email = list_addr) mlist.save() sender_name, sender_addr = parseaddr(sender) user = mailinglist.create_user(sender_addr) mailinglist.add_if_not_subscriber(sender, list_name) user.save()
def test_add_if_not_subscribed(): """ Test add_if_not_subscribed. """ test_create_user() mailinglist.add_if_not_subscriber(member, list_name) subs = Subscription.objects.all() assert len(subs) == 1 mailinglist.add_if_not_subscriber(member, list_name) assert len(subs) == 1
def START(message, list_name=None, id_number=None, host=None): """ The start state looks for confirmation emails and move users with valid confirmation emails into a posting state. We also create the user's postosaurus account (if needed) and subscription here. This prevents users from being added to a list if they don't want to be. """ mlist = mailinglist.find_list(list_name) if mlist: if CONFIRM.verify(mlist, 'confirm', message['from'], id_number): # Let them know they've been added. name, address = parseaddr(message['from']) CONFIRM.notify(relay, mlist, 'confirm', address) user = mailinglist.find_user(address) if not user: user = mailinglist.create_user(address) mailinglist.add_if_not_subscriber(address, list_name) return POSTING return START