~barry/mailman/work1

« back to all changes in this revision

Viewing changes to src/mailman/app/notifications.py

  • Committer: Barry Warsaw
  • Date: 2014-01-05 21:21:10 UTC
  • Revision ID: barry@list.org-20140105212110-y39xuab7cnu2kr83
checkpointing

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
 
67
67
 
68
 
def send_welcome_message(mlist, address, language, delivery_mode, text=''):
 
68
def send_welcome_message(mlist, member, language, text=''):
69
69
    """Send a welcome message to a subscriber.
70
70
 
71
71
    Prepending to the standard welcome message template is the mailing list's
72
72
    welcome message, if there is one.
73
73
 
74
 
    :param mlist: the mailing list
 
74
    :param mlist: The mailing list.
75
75
    :type mlist: IMailingList
76
 
    :param address: The address to respond to
77
 
    :type address: string
78
 
    :param language: the language of the response
 
76
    :param member: The member to send the welcome message to.
 
77
    :param address: IMember
 
78
    :param language: The language of the response.
79
79
    :type language: ILanguage
80
 
    :param delivery_mode: the type of delivery the subscriber is getting
81
 
    :type delivery_mode: DeliveryMode
82
80
    """
83
 
    welcome_message = _get_message(mlist.welcome_message_uri,
84
 
                                   mlist, language)
85
 
    # Find the IMember object which is subscribed to the mailing list, because
86
 
    # from there, we can get the member's options url.
87
 
    member = mlist.members.get_member(address)
88
 
    user_name = member.user.display_name
 
81
    welcome_message = _get_message(mlist.welcome_message_uri, mlist, language)
89
82
    options_url = member.options_url
90
83
    # Get the text from the template.
91
84
    text = expand(welcome_message, dict(
92
85
        fqdn_listname=mlist.fqdn_listname,
93
86
        list_name=mlist.display_name,
94
 
        #listinfo_uri=mlist.script_url('listinfo'),
95
87
        list_requests=mlist.request_address,
96
 
        user_name=user_name,
97
 
        user_address=address,
 
88
        user_name=member.user.display_name,
 
89
        user_address=member.address.email,
98
90
        user_options_uri=options_url,
99
91
        ))
100
 
    if delivery_mode is not DeliveryMode.regular:
 
92
    if member.delivery_mode is not DeliveryMode.regular:
101
93
        digmode = _(' (Digest mode)')
102
94
    else:
103
95
        digmode = ''
104
96
    msg = UserNotification(
105
 
        formataddr((user_name, address)),
 
97
        formataddr((member.user.display_name, member.address.email)),
106
98
        mlist.request_address,
107
99
        _('Welcome to the "$mlist.display_name" mailing list${digmode}'),
108
100
        text, language)