Example #1
0
def send_events_list(user, event_list, location):
    profile_url = urlresolvers.reverse('user_detail', args=(user.username, ))
    footer = 'You are receiving this email because your preferences for event reminders are on. To turn them off, visit %s' % profile_url
    sender = location.from_email()
    subject = '[' + location.email_subject_prefix + ']' + ' Reminder of your events today'
    current_tz = timezone.get_current_timezone()
    today_local = timezone.now().astimezone(current_tz).date()
    day_of_week = weekday_number_to_name[today_local.weekday()]
    plaintext = get_template('emails/events_today.txt')
    domain = Site.objects.get_current().domain
    c = {
        'user': user,
        'events': event_list,
        'location_name': location.name,
        'location': location,
        'domain': domain,
        "footer": footer,
        "day_of_week": day_of_week
    }
    text_content = plaintext.render(c)
    mailgun_data = {
        "from": sender,
        "to": user.email,
        "subject": subject,
        "text": text_content,
    }
    return emails.mailgun_send(mailgun_data)
Example #2
0
def send_events_list(user, event_list, location):
	profile_url = urlresolvers.reverse('user_detail', args=(user.username))
	footer = 'You are receiving this email because your preferences for event reminders are on. To turn them off, visit %s' % profile_url
	sender = location.from_email()
	subject = '[' + location.email_subject_prefix + ']' + 'Reminder of your events today'
	current_tz = timezone.get_current_timezone()
	today_local = timezone.now().astimezone(current_tz).date()
	day_of_week = weekday_number_to_name[today_local.weekday()]
	plaintext = get_template('emails/events_today.txt')
	c = Context({
			'user': user,
			'events': event_list,
			'location_name': location.name,
			'location': location,
			'domain': domain,
			"footer": footer,
			"day_of_week": day_of_week
			})
	text_content = plaintext.render(c)
	mailgun_data={
			"from": sender,
			"to": user.email,
			"subject": subject,
			"text": text_content,
		}
	return emails.mailgun_send(mailgun_data)
Example #3
0
def event_send_mail(request, event_id, event_slug, location_slug=None):
	if not request.method == 'POST':
		return HttpResponseRedirect('/404')

	location = get_object_or_404(Location, slug=location_slug)
	subject = request.POST.get("subject")
	recipients = [request.POST.get("recipient"),]
	body = request.POST.get("body") + "\n\n" + request.POST.get("footer")

	# the from address is set to the organizer's email so people can respond
	# directly with questions if needed.
	mailgun_data={"from": request.user.email,
		"to": request.user.email,
		"bcc": recipients,
		"subject": subject,
		"text": body,
	}

	resp = mailgun_send(mailgun_data)

	logger.debug(resp)
	if resp.status_code == 200:
		messages.add_message(request, messages.INFO, "Your message was sent.")
	else:
		messages.add_message(request, messages.INFO, "There was a connection problem and your message was not sent.")
	return HttpResponseRedirect(reverse('gather_view_event', args=(location_slug, event_id, event_slug)))
Example #4
0
def event_send_mail(request, event_id, event_slug, location_slug=None):
    if not request.method == 'POST':
        return HttpResponseRedirect('/404')

    location = get_object_or_404(Location, slug=location_slug)
    subject = request.POST.get("subject")
    recipients = [request.POST.get("recipient"),]
    body = request.POST.get("body") + "\n\n" + request.POST.get("footer")

    # the from address is set to the organizer's email so people can respond
    # directly with questions if needed.
    mailgun_data={"from": request.user.email,
        "to": request.user.email,
        "bcc": recipients,
        "subject": subject,
        "text": body,
    }

    resp = mailgun_send(mailgun_data)

    logger.debug(resp)
    if resp.status_code == 200:
        messages.add_message(request, messages.INFO, "Your message was sent.")
    else:
        messages.add_message(request, messages.INFO, "There was a connection problem and your message was not sent.")
    return HttpResponseRedirect(reverse('gather_view_event', args=(location_slug, event_id, event_slug)))
Example #5
0
def weekly_reminder_email(user, event_list, location):
    profile_url = urlresolvers.reverse('user_detail', args=(user.username, ))
    location_name = location.name
    current_tz = timezone.get_current_timezone()
    today_local = timezone.now().astimezone(current_tz).date()
    tomorrow_local = today_local + datetime.timedelta(days=1)
    week_name = tomorrow_local.strftime("%B %d, %Y")
    footer = 'You are receiving this email because you requested weekly updates of upcoming events from %s. To turn them off, visit %s' % (
        location_name, profile_url)
    sender = location.from_email()
    subject = '[' + location.email_subject_prefix + ']' + ' Upcoming events for the week of %s' % week_name
    current_tz = timezone.get_current_timezone()
    today_local = timezone.now().astimezone(current_tz).date()
    plaintext = get_template('emails/events_this_week.txt')
    htmltext = get_template('emails/events_this_week.html')
    domain = Site.objects.get_current().domain

    c_text = {
        'user': user,
        'events': event_list,
        'location_name': location_name,
        'location': location,
        'domain': domain,
        "footer": footer,
        "week_name": week_name
    }
    text_content = plaintext.render(c_text)

    c_html = {
        'user': user,
        'events': event_list,
        'location_name': location_name,
        'location': location,
        'domain': domain,
        "footer": footer,
        "week_name": week_name
    }
    html_content = htmltext.render(c_html)

    mailgun_data = {
        "from": sender,
        "to": user.email,
        "subject": subject,
        "text": text_content,
        "html": html_content,
    }
    return emails.mailgun_send(mailgun_data)
Example #6
0
def weekly_reminder_email(user, event_list, location):
	profile_url = urlresolvers.reverse('user_detail', args=(user.username, ))
	location_name = location.name
	current_tz = timezone.get_current_timezone()
	today_local = timezone.now().astimezone(current_tz).date()
	tomorrow_local = today_local + datetime.timedelta(days=1)
	week_name = tomorrow_local.strftime("%B %d, %Y")
	footer = 'You are receiving this email because you requested weekly updates of upcoming events from %s. To turn them off, visit %s' % (location_name, profile_url)
	sender = location.from_email()
	subject = '[' + location.email_subject_prefix + ']' + ' Upcoming events for the week of %s' % week_name
	current_tz = timezone.get_current_timezone()
	today_local = timezone.now().astimezone(current_tz).date()
	plaintext = get_template('emails/events_this_week.txt')
	htmltext = get_template('emails/events_this_week.html')
	domain = Site.objects.get_current().domain

	c_text = Context({
			'user': user,
			'events': event_list,
			'location_name': location_name,
			'location': location,
			'domain': domain,
			"footer": footer,
			"week_name": week_name
			})
	text_content = plaintext.render(c_text)

	c_html = Context({
			'user': user,
			'events': event_list,
			'location_name': location_name,
			'location': location,
			'domain': domain,
			"footer": footer,
			"week_name": week_name
			})
	html_content = htmltext.render(c_html)

	mailgun_data={
			"from": sender,
			"to": user.email,
			"subject": subject,
			"text": text_content,
			"html": html_content,
		}
	return emails.mailgun_send(mailgun_data)