Esempio n. 1
0
def group_invite_user(user, group, email, inviter):
    """Invite email to join group. May raise smtplib.SMTPRecipientsRefused if server
    rejects email.
    """
    if not group.is_accepted() or not group.get_members().can_manage(user):
        raise AccessError

    group.add_invitation(email, inviter)

    transaction_commit(inviter, 'InviteToGroup')    # moved from group/form.ptl/InviteForm.commit()
    
    try:
        user = get_user_database().get_user_by_email(email)
    except KeyError:
        # e-mail address is not registered, send an e-mail (rather than internal message)
        subject=_(_email_invite_subject) % dict(group_name=group.name)
        body=_(_email_invite_body) % dict(email=email,
            home_url=messages.home_url,
            inviter=qon.ui.blocks.user.display_name_plain(inviter),
            group_name=qon.ui.blocks.group.display_name_plain(group))
            
        sendmail(subject, body, [email])
    else:
        message_send(inviter, user,
            subject=_(_message_invite_subject) % dict(group_name=group.name),
            body=_(_message_invite_body) % dict(
                email=email,
                inviter=qon.ui.blocks.user.display_name_plain(inviter),
                group_name=qon.ui.blocks.group.display_name_plain(group)
                )
            )
Esempio n. 2
0
def group_purge(group):
    """Purge an unsponsored group."""
    if not group.is_accepted():
        # send a message to group owner that his group is being purged
        
        email = group.owners[0].get_primary_email()
        
        d=dict(group_name=group.display_name(),
            primary=email,
            group_description=group.description,
            )
        
        message = _notify_group_purged % d
        
        import socket
        try:
            sendmail("ned.com Group Not Sponsored", message, [email])
        except socket.error:
            pass
        
        # delete the group
        group_delete(group)