def email_member(notice, membership, global_context): user = membership.user body = notice.email_content context = membership.get_field_items() context['membership'] = membership context.update(global_context) # corporate member corp_replace_str if membership.corporate_membership_id: context['corporate_membership_notice'] = corp_replace_str if membership.expire_dt: context.update({ 'expire_dt': time.strftime( "%d-%b-%y %I:%M %p", membership.expire_dt.timetuple()), }) if membership.payment_method: payment_method_name = membership.payment_method.human_name else: payment_method_name = '' context.update({ 'member_number': membership.member_number, 'payment_method': payment_method_name, 'referer_url': '%s%s?next=%s' % (site_url, reverse('auth_login'), membership.referer_url), 'membership_link': '%s%s' % (site_url, membership.get_absolute_url()), 'renew_link': '%s%s' % (site_url, membership.get_absolute_url()) }) body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email_recipient = user.email subject = notice.subject.replace('(name)', user.get_full_name()) template = Template(subject) subject = template.render(context) email_context.update({ 'subject':subject, 'content':body}) if notice.sender: email_context.update({ 'sender':notice.sender, 'reply_to':notice.sender}) if notice.sender_display: email_context.update({'sender_display':notice.sender_display}) notification.send_emails([email_recipient], 'membership_notice_email', email_context) if verbosity > 1: print 'To ', email_recipient, subject
def email_member(notice, membership, global_context): corp_profile = membership.corp_profile representatives = corp_profile.reps.filter(Q(is_dues_rep=True)|(Q(is_member_rep=True))) sent = 0 for recipient in representatives: body = notice.email_content context = membership.get_field_items() context['membership'] = membership context.update(global_context) context.update({ 'rep_first_name': recipient.user.first_name, }) if membership.expiration_dt: body = body.replace("[expirationdatetime]", time.strftime( "%d-%b-%y %I:%M %p", membership.expiration_dt.timetuple())) else: body = body.replace("[expirationdatetime]", '') context.update({ 'corporatemembershiptypeid': str(membership.corporate_membership_type.id), 'corporatemembershiptype': membership.corporate_membership_type.name, 'view_link': "%s%s" % (site_url, membership.get_absolute_url()), 'renew_link': "%s%s" % (site_url, membership.get_renewal_url()), 'renewed_individuals_list': render_to_string(('notification/corp_memb_notice_email/renew_list.html'), {'corp_membership': membership, }), }) body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email.recipient = recipient.user.email subject = notice.subject.replace('(name)', corp_profile.name) template = Template(subject) subject = template.render(context) email.subject = subject email.body = body if notice.sender: email.sender = notice.sender email.reply_to = notice.sender if notice.sender_display: email.sender_display = notice.sender_display email.send() sent += 1 if verbosity > 1: print 'To ', email.recipient, email.subject return sent
def email_member(notice, membership, global_context): user = membership.user body = notice.email_content context = membership.get_field_items() context['membership'] = membership context.update(global_context) # corporate member corp_replace_str if membership.corporate_membership_id: context['corporate_membership_notice'] = corp_replace_str if membership.expire_dt: context.update({ 'expire_dt': time.strftime("%d-%b-%y %I:%M %p", membership.expire_dt.timetuple()), }) if membership.payment_method: payment_method_name = membership.payment_method.human_name else: payment_method_name = '' context.update({ 'member_number': membership.member_number, 'payment_method': payment_method_name, 'referer_url': '%s%s?next=%s' % (site_url, reverse('auth_login'), membership.referer_url), 'membership_link': '%s%s' % (site_url, membership.get_absolute_url()), 'renew_link': '%s%s' % (site_url, membership.get_absolute_url()) }) body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email_recipient = user.email subject = notice.subject.replace('(name)', user.get_full_name()) template = Template(subject) subject = template.render(context) email_context.update({'subject': subject, 'content': body}) if notice.sender: email_context.update({ 'sender': notice.sender, 'reply_to': notice.sender }) if notice.sender_display: email_context.update({'sender_display': notice.sender_display}) notification.send_emails([email_recipient], 'membership_notice_email', email_context) if verbosity > 1: print 'To ', email_recipient, subject
def email_member(notice, membership, global_context): user = membership.user body = notice.email_content context = membership.get_field_items() context['membership'] = membership context.update(global_context) # memberships page ------------ memberships_page = "%s%s" % \ (site_url, reverse('profile', args=[membership.user])) body = body.replace("[membershiptypeid]", str(membership.membership_type.id)) body = body.replace("[membershiplink]", '%s' % memberships_page) body = body.replace("[renewlink]", memberships_page) if membership.expire_dt: body = body.replace("[expirationdatetime]", time.strftime( "%d-%b-%y %I:%M %p", membership.expire_dt.timetuple())) else: body = body.replace("[expirationdatetime]", '') # corporate member corp_replace_str if membership.corporate_membership_id: body = body.replace("<!--[corporatemembernotice]-->", corp_replace_str) else: body = body.replace("<!--[corporatemembernotice]-->", "") context.update({'membershiptypeid': str(membership.membership_type.id), 'membershiplink': memberships_page, 'renewlink': memberships_page, 'membernumber': membership.member_number, 'membershiptype': membership.membership_type.name, }) if membership.expire_dt: context['expirationdatetime'] = time.strftime( "%d-%b-%y %I:%M %p", membership.expire_dt.timetuple()) # corporate member corp_replace_str if membership.corporate_membership_id: context['corporatemembernotice'] = corp_replace_str body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email.recipient = user.email subject = notice.subject.replace('(name)', user.get_full_name()) template = Template(subject) subject = template.render(context) email.subject = subject email.body = body if notice.sender: email.sender = notice.sender email.reply_to = notice.sender if notice.sender_display: email.sender_display = notice.sender_display email.send() if verbosity > 1: print 'To ', email.recipient, email.subject
def email_member(notice, membership, global_context): corp_profile = membership.corp_profile representatives = corp_profile.reps.filter( Q(is_dues_rep=True) | (Q(is_member_rep=True))) sent = 0 corp_app = CorpMembershipApp.objects.current_app() authentication_info = render_to_string( 'notification/corp_memb_notice_email/auth_info.html', { 'corp_membership': membership, 'corp_app': corp_app }) individuals_join_url = '%s%s' % ( site_url, reverse('membership_default.corp_pre_add', args=[membership.id])) if membership.expiration_dt: expire_dt = time.strftime("%d-%b-%y %I:%M %p", membership.expiration_dt.timetuple()) else: expire_dt = '' if membership.payment_method: payment_method = membership.payment_method.human_name else: payment_method = '' if membership.renewal: renewed_individuals_list = render_to_string( 'notification/corp_memb_notice_email/renew_list.html', {'corp_membership': membership}) total_individuals_renewed = membership.indivmembershiprenewentry_set.count( ) else: renewed_individuals_list = '' total_individuals_renewed = '' if membership.invoice: invoice_link = '%s%s' % (site_url, membership.invoice.get_absolute_url()) else: invoice_link = '' global_context.update({ 'name': corp_profile.name, 'email': corp_profile.email, 'expire_dt': expire_dt, 'payment_method': payment_method, 'renewed_individuals_list': renewed_individuals_list, 'total_individuals_renewed': total_individuals_renewed, 'view_link': "%s%s" % (site_url, membership.get_absolute_url()), 'renew_link': "%s%s" % (site_url, membership.get_renewal_url()), 'invoice_link': invoice_link, 'authentication_info': authentication_info, 'individuals_join_url': individuals_join_url, }) for recipient in representatives: body = notice.email_content context = membership.get_field_items() context['membership'] = membership context.update(global_context) context.update({ 'rep_first_name': recipient.user.first_name, }) body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email_recipient = recipient.user.email subject = notice.subject.replace('(name)', corp_profile.name) template = Template(subject) subject = template.render(context) email_context.update({'subject': subject, 'content': body}) if notice.sender: email_context.update({ 'sender': notice.sender, 'reply_to': notice.sender }) if notice.sender_display: email_context.update( {'sender_display': notice.sender_display}) notification.send_emails([email_recipient], 'corp_memb_notice_email', email_context) sent += 1 if verbosity > 1: print 'To ', email_recipient, subject return sent
def email_member(notice, membership, global_context): user = membership.user body = notice.email_content context = membership.entry_items context.update(global_context) body = body.replace("[membershiptypeid]", str(membership.membership_type.id)) body = body.replace("[membershiplink]", '%s%s' % (site_url, membership.get_absolute_url())) # memberships page ------------ memberships_page = "%s%s%s" % \ (site_url, reverse('profile', args=[membership.user]), "#userview-memberships") body = body.replace("[renewlink]", memberships_page) if membership.expire_dt: body = body.replace("[expirationdatetime]", time.strftime("%d-%b-%y %I:%M %p", membership.expire_dt.timetuple())) else: body = body.replace("[expirationdatetime]", '') # corporate member corp_replace_str if membership.corporate_membership_id: body = body.replace("<!--[corporatemembernotice]-->", corp_replace_str) else: body = body.replace("<!--[corporatemembernotice]-->", "") context.update({'membershiptypeid': str(membership.membership_type.id), 'membershiplink': '%s%s' % (site_url, membership.get_absolute_url()), 'renewlink': memberships_page, 'membernumber': membership.member_number, 'membershiptype': membership.membership_type.name, }) if membership.expire_dt: context['expirationdatetime'] = time.strftime("%d-%b-%y %I:%M %p", membership.expire_dt.timetuple()) # corporate member corp_replace_str if membership.corporate_membership_id: context['corporatemembernotice'] = corp_replace_str body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email.recipient = user.email email.subject = notice.subject.replace('(name)', user.get_full_name()) email.body = body if notice.sender: email.sender = notice.sender email.reply_to = notice.sender if notice.sender_display: email.sender_display = notice.sender_display email.send() if verbosity > 1: print 'To ', email.recipient, email.subject
def email_member(notice, membership, global_context): corp_profile = membership.corp_profile representatives = corp_profile.reps.filter(Q(is_dues_rep=True)|(Q(is_member_rep=True))) sent = 0 corp_app = CorpMembershipApp.objects.current_app() authentication_info = render_to_string( 'notification/corp_memb_notice_email/auth_info.html', {'corp_membership': membership, 'corp_app': corp_app}) individuals_join_url = '%s%s' % (site_url, reverse('membership_default.corp_pre_add', args=[membership.id])) if membership.expiration_dt: expire_dt = time.strftime("%d-%b-%y %I:%M %p", membership.expiration_dt.timetuple()) else: expire_dt = '' if membership.payment_method: payment_method = membership.payment_method.human_name else: payment_method = '' if membership.renewal: renewed_individuals_list = render_to_string( 'notification/corp_memb_notice_email/renew_list.html', {'corp_membership': membership}) total_individuals_renewed = membership.indivmembershiprenewentry_set.count() else: renewed_individuals_list = '' total_individuals_renewed = '' if membership.invoice: invoice_link = '%s%s' % (site_url, membership.invoice.get_absolute_url()) else: invoice_link = '' global_context.update({ 'name': corp_profile.name, 'email': corp_profile.email, 'expire_dt': expire_dt, 'payment_method': payment_method, 'renewed_individuals_list': renewed_individuals_list, 'total_individuals_renewed': total_individuals_renewed, 'view_link': "%s%s" % (site_url, membership.get_absolute_url()), 'renew_link': "%s%s" % (site_url, membership.get_renewal_url()), 'invoice_link': invoice_link, 'authentication_info': authentication_info, 'individuals_join_url': individuals_join_url, }) for recipient in representatives: body = notice.email_content context = membership.get_field_items() context['membership'] = membership context.update(global_context) context.update({ 'rep_first_name': recipient.user.first_name, }) body = fieldify(body) body = '%s <br /><br />%s' % (body, get_footer()) context = Context(context) template = Template(body) body = template.render(context) email_recipient = recipient.user.email subject = notice.subject.replace('(name)', corp_profile.name) template = Template(subject) subject = template.render(context) email_context.update({ 'subject':subject, 'content':body}) if notice.sender: email_context.update({ 'sender':notice.sender, 'reply_to':notice.sender}) if notice.sender_display: email_context.update({'sender_display':notice.sender_display}) notification.send_emails([email_recipient], 'corp_memb_notice_email', email_context) sent += 1 if verbosity > 1: print 'To ', email_recipient, subject return sent