def send_invitation(invitation):
 if invitation.user:
  template = mail_builder.membership_notification
  email = template(invitation.user, {'membership': invitation})
 else:
  template = mail_builder.membership_invitation
  email = template(invitation.email, {'membership': invitation})
 email.send()

def send_invitation ( invitation ) : if invitation . user : template = mail_builder . membership_notification email = template ( invitation . user , { 'membership' : invitation } ) else : template = mail_builder . membership_invitation email = template ( invitation . email , { 'membership' : invitation } ) email . send ( )
send an invitation email .