# Path: brasilcomvc/common/email.py
# def send_template_email(subject, to, template_name, context=None):
#     '''
#     Render a template into an email body and send it through Django's send_mail
# 
#     - The `to` parameter must be a single email address.
#     - This function omits `from_email` because it expects it to exist from an
#     environment variable.
#     - Other parameters are omitted as well because there are no
#     use for them in the current use case.
#     '''
#     body = render_to_string(template_name, context or {}, Context({
#         'mailing_address': settings.MAILING_ADDRESS,
#         'site_url': settings.BASE_URL,
#         'sns_facebook': settings.SNS_FACEBOOK,
#         'sns_googleplus': settings.SNS_GOOGLEPLUS,
#         'sns_twitter': settings.SNS_TWITTER,
#         'subject': subject,
#     }))
#     plain_body = strip_tags(body)
# 
#     email = EmailMultiAlternatives(
#         subject=subject,
#         body=plain_body,
#         to=(to,))
#     email.attach_alternative(body, 'text/html')
#     email.send()


from django.conf import settings
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.utils.encoding import smart_text, python_2_unicode_compatible
from django.utils.text import slugify
from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFill
from pygeocoder import Geocoder, GeocoderError
from brasilcomvc.common.email import send_template_email
    message = models.TextField()
    created = models.DateTimeField(auto_now_add=True)

    volunteer.verbose_name = 'voluntário'
    project.verbose_name = 'projeto'
    message.verbose_name = 'mensagem ao organizador'
    message.help_text = 'Conte-nos brevemente como você pode ajudar.'
    created.verbose_name = 'hora do registro'

    class Meta:
        unique_together = ('project', 'volunteer',)
        verbose_name = 'inscrição em projeto'
        verbose_name_plural = 'inscrições em projetos'

    def __str__(self):
        return '{}: {}'.format(self.project.name, self.volunteer.full_name)

    def _get_email_context(self):
        return {
            attr: getattr(self, attr)
            for attr in ('message', 'project', 'volunteer',)}

    def send_owner_email(self):
        send_template_email(
            subject='Alguém se inscreveu no seu projeto!',
            to=self.project.owner.email,
            template_name='emails/project_apply_owner.html',
            context=self._get_email_context())

    def send_volunteer_email(self):

# Path: brasilcomvc/common/email.py
# def send_template_email(subject, to, template_name, context=None):
#     '''
#     Render a template into an email body and send it through Django's send_mail
# 
#     - The `to` parameter must be a single email address.
#     - This function omits `from_email` because it expects it to exist from an
#     environment variable.
#     - Other parameters are omitted as well because there are no
#     use for them in the current use case.
#     '''
#     body = render_to_string(template_name, context or {}, Context({
#         'mailing_address': settings.MAILING_ADDRESS,
#         'site_url': settings.BASE_URL,
#         'sns_facebook': settings.SNS_FACEBOOK,
#         'sns_googleplus': settings.SNS_GOOGLEPLUS,
#         'sns_twitter': settings.SNS_TWITTER,
#         'subject': subject,
#     }))
#     plain_body = strip_tags(body)
# 
#     email = EmailMultiAlternatives(
#         subject=subject,
#         body=plain_body,
#         to=(to,))
#     email.attach_alternative(body, 'text/html')
#     email.send()


# Path: brasilcomvc/projects/models.py
from django.conf import settings
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.utils.encoding import smart_text, python_2_unicode_compatible
from django.utils.text import slugify
from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFill
from pygeocoder import Geocoder, GeocoderError
from brasilcomvc.common.email import send_template_email

    message = models.TextField()
    created = models.DateTimeField(auto_now_add=True)

    volunteer.verbose_name = 'voluntário'
    project.verbose_name = 'projeto'
    message.verbose_name = 'mensagem ao organizador'
    message.help_text = 'Conte-nos brevemente como você pode ajudar.'
    created.verbose_name = 'hora do registro'

    class Meta:
        unique_together = ('project', 'volunteer',)
        verbose_name = 'inscrição em projeto'
        verbose_name_plural = 'inscrições em projetos'

    def __str__(self):
        return '{}: {}'.format(self.project.name, self.volunteer.full_name)

    def _get_email_context(self):
        return {
            attr: getattr(self, attr)
            for attr in ('message', 'project', 'volunteer',)}

    def send_owner_email(self):
        send_template_email(
            subject='Alguém se inscreveu no seu projeto!',
            to=self.project.owner.email,
            template_name='emails/project_apply_owner.html',
            context=self._get_email_context())

    def send_volunteer_email(self):

        send_template_email(