Esempio n. 1
0
 def remind(self, message=None):
     email = EmailMessageWithEnvelopeTo(
         "Reminder: Your invitation to join %s" % self.project,
         "Don't forget that you've been invited to join %s" % self.project +
         ('\n%s' % message if message else ''), settings.DEFAULT_FROM_EMAIL,
         [self.user.email])
     email.send()
Esempio n. 2
0
def register(request):
    form = RegistrationForm()

    if request.method == "GET":
        return locals()

    form = RegistrationForm(request.POST)
    if not form.is_valid():
        return locals()

    new_user = form.save()
    registration_profile = form.profile

    subject = "Please confirm your email address"
    body = registration_profile.render_to_string(
        "contact_manager/confirm_initial_email_contact.txt")
    email = EmailMessageWithEnvelopeTo(subject, body,
                                       settings.DEFAULT_FROM_EMAIL,
                                       [registration_profile.contact.email])
    email.send()

    new_user = authenticate(username=new_user.username,
                            password=form.cleaned_data['password1'])
    login(request, new_user)

    messages.success(request, "Now check your email to activate your account.")
    return redirect("member_account", new_user.username)
Esempio n. 3
0
 def send(self, message=None):
     email = EmailMessageWithEnvelopeTo(
         "Invitation to join %s" % self.project,
         "You've been invited to join %s" % self.project +
         ('\n%s' % message if message else ''), settings.DEFAULT_FROM_EMAIL,
         [self.user.email])
     email.send()
Esempio n. 4
0
 def send(self, message=None):
     email = EmailMessageWithEnvelopeTo(
         "Request to join %s" % self.project,
         "%s wants to join %s" % self.project +
         ('\n%s' % message if message else ''), settings.DEFAULT_FROM_EMAIL,
         [user.email for user in self.project.admins])
     email.send()
def register(request):
    form = RegistrationForm()

    if request.method == "GET":
        return locals()

    form = RegistrationForm(request.POST)    
    if not form.is_valid():
        return locals()

    new_user = form.save()
    registration_profile = form.profile

    subject = "Please confirm your email address"
    body = registration_profile.render_to_string(
        "contact_manager/confirm_initial_email_contact.txt")
    email = EmailMessageWithEnvelopeTo(subject, body,
                                       settings.DEFAULT_FROM_EMAIL,
                                       [registration_profile.contact.email])
    email.send()

    new_user = authenticate(username=new_user.username, password=form.cleaned_data['password1'])
    login(request, new_user)

    messages.success(request, "Now check your email to activate your account.")
    return redirect("member_account", new_user.username)
 def send(self, message=None):
     email = EmailMessageWithEnvelopeTo(
         "Invitation to join %s" % self.project,
         "You've been invited to join %s" % self.project + (
             '\n%s' % message if message else ''),
         settings.DEFAULT_FROM_EMAIL,
         [self.user.email])
     email.send()
 def remind(self, message=None):
     email = EmailMessageWithEnvelopeTo(
         "Reminder: Your invitation to join %s" % self.project,
         "Don't forget that you've been invited to join %s" % self.project + (
             '\n%s' % message if message else ''),
         settings.DEFAULT_FROM_EMAIL,
         [self.user.email])
     email.send()
 def send(self, message=None):
     email = EmailMessageWithEnvelopeTo(
         "Request to join %s" % self.project,
         "%s wants to join %s" % self.project + (
             '\n%s' % message if message else ''),
         settings.DEFAULT_FROM_EMAIL,
         [user.email for user in self.project.admins])
     email.send()
Esempio n. 9
0
    def send_to_subscribers(self, post):
        author = post.author.email
        subject = post.subject
        body = post.body

        domain = settings.SITE_DOMAIN
        subject = ''.join(subject.splitlines())

        subscribers = LocalRoles.objects.filter(
            list=self, roles__contains="ListSubscriber")
        subscribers = [i.username for i in subscribers]
        subscribers = User.objects.filter(is_active=True,
                                          username__in=subscribers)
        subscribers = [i.email for i in subscribers]

        if self.container_id:
            uid = "%s.%s" % (self.slug, self.container_id)
        else:
            uid = self.slug

        email = EmailMessageWithEnvelopeTo(
            subject,
            body,
            settings.DEFAULT_FROM_EMAIL,
            subscribers,
            headers={
                'From':
                author,
                'To':
                self.email_address(),
                'List-ID':
                "<%s.%s>" % (uid, self.fqdn),
                'List-Help':
                "<mailto:%s+help@%s>" % (self.slug, self.fqdn),
                'List-Subscribe':
                "<mailto:%s+subscribe@%s" % (self.slug, self.fqdn),
                'List-Unsubscribe':
                "<mailto:%s+unsubscribe@%s" % (self.slug, self.fqdn),
                'List-Post':
                "<mailto:%s@%s" % (self.slug, self.fqdn),  # XXX TODO "NO"
                'List-Owner':
                "<mailto:%s+manager@%s" % (self.slug, self.fqdn),
                'List-Archive':
                "<http://%s/%s>" % (self.fqdn, self.get_absolute_url()),
            })
        email.content_subtype = "text/html"
        email.send()
def project_team_invite_email(request, project_slug):
    project = Project.objects.get(slug=project_slug)
    if not project.viewable(request):
        return HttpResponseForbidden()
    if not project.manageable(request):
        return HttpResponseForbidden()

    email = request.POST['email']
    try:
        user = User.objects.get(email=email)
    except User.DoesNotExist:
        pass
    else:
        messages.info(request, "This user already exists. Search better.")
        return redirect(project)

    factory = TemporaryAccountFactory(email)
    registration_form = factory.registration_form()
    new_user = factory.create_temporary_user(registration_form)

    registration_profile = registration_form.profile
    contact = registration_form.contact

    invite = ProjectInvite.objects.create(user=new_user, project=project,
                                          inviter=request.user)

    context = {}
    context['invite'] = invite
    custom_message = request.POST.get('custom_message') or ''
    if custom_message and custom_message.strip():
        context['custom_message'] = custom_message.strip()

    subject = "You're been invited"
    message = registration_profile.render_to_string(
        'gateway/project_invite_pending_activation_email.txt', context)
    email = EmailMessageWithEnvelopeTo(subject, message, 
                                       settings.DEFAULT_FROM_EMAIL,
                                       [contact.email])
    email.send()

    messages.success(request, "Your invitation has been sent.")
    return redirect(project)
def new_contact(msg):
    email = msg.get("From")
    addr = parseaddr(addr)[1]

    factory = TemporaryAccountFactory(email)
    registration_form = factory.registration_form()
    new_user = factory.create_temporary_user(registration_form)

    registration_profile = registration_form.profile
    contact = registration_form.contact

    subject = "Please confirm your account"
    message = registration_profile.render_to_string(
        'gateway/listen_mail_pending_activation_email.txt')
    email = EmailMessageWithEnvelopeTo(subject, message, 
                                       settings.DEFAULT_FROM_EMAIL,
                                       [contact.email])
    email.send()

    return defer(msg, contact)
Esempio n. 12
0
def new_contact(msg):
    email = msg.get("From")
    addr = parseaddr(addr)[1]

    factory = TemporaryAccountFactory(email)
    registration_form = factory.registration_form()
    new_user = factory.create_temporary_user(registration_form)

    registration_profile = registration_form.profile
    contact = registration_form.contact

    subject = "Please confirm your account"
    message = registration_profile.render_to_string(
        'gateway/listen_mail_pending_activation_email.txt')
    email = EmailMessageWithEnvelopeTo(subject, message,
                                       settings.DEFAULT_FROM_EMAIL,
                                       [contact.email])
    email.send()

    return defer(msg, contact)
def member_email_contacts(request, username):
    user = User.objects.get(username=username)
    if user != request.user:
        return HttpResponseForbidden()

    contact_add_form = EmailContactForm(data=request.POST)
    if not contact_add_form.is_valid():
        return locals()
    
    new_contact = contact_add_form.save(user)
    registration_profile = contact_add_form.profile
    subject = "Please confirm your email address"
    body = registration_profile.render_to_string(
        "contact_manager/confirm_secondary_email_contact.txt")
    email = EmailMessageWithEnvelopeTo(subject, body, 
                                       settings.DEFAULT_FROM_EMAIL,
                                       [new_contact.email])
    email.send()

    messages.info(request, "Now check your email to confirm the contact.")
    return redirect("member_account", user.username)
def member_email_contacts(request, username):
    user = User.objects.get(username=username)
    if user != request.user:
        return HttpResponseForbidden()

    contact_add_form = EmailContactForm(data=request.POST)
    if not contact_add_form.is_valid():
        return locals()

    new_contact = contact_add_form.save(user)
    registration_profile = contact_add_form.profile
    subject = "Please confirm your email address"
    body = registration_profile.render_to_string(
        "contact_manager/confirm_secondary_email_contact.txt")
    email = EmailMessageWithEnvelopeTo(subject, body,
                                       settings.DEFAULT_FROM_EMAIL,
                                       [new_contact.email])
    email.send()

    messages.info(request, "Now check your email to confirm the contact.")
    return redirect("member_account", user.username)
    def send_to_subscribers(self, post):
        author = post.author.email
        subject = post.subject
        body = post.body

        domain = settings.SITE_DOMAIN
        subject = "".join(subject.splitlines())

        subscribers = LocalRoles.objects.filter(list=self, roles__contains="ListSubscriber")
        subscribers = [i.username for i in subscribers]
        subscribers = User.objects.filter(is_active=True, username__in=subscribers)
        subscribers = [i.email for i in subscribers]

        if self.container_id:
            uid = "%s.%s" % (self.slug, self.container_id)
        else:
            uid = self.slug

        email = EmailMessageWithEnvelopeTo(
            subject,
            body,
            settings.DEFAULT_FROM_EMAIL,
            subscribers,
            headers={
                "From": author,
                "To": self.email_address(),
                "List-ID": "<%s.%s>" % (uid, self.fqdn),
                "List-Help": "<mailto:%s+help@%s>" % (self.slug, self.fqdn),
                "List-Subscribe": "<mailto:%s+subscribe@%s" % (self.slug, self.fqdn),
                "List-Unsubscribe": "<mailto:%s+unsubscribe@%s" % (self.slug, self.fqdn),
                "List-Post": "<mailto:%s@%s" % (self.slug, self.fqdn),  # XXX TODO "NO"
                "List-Owner": "<mailto:%s+manager@%s" % (self.slug, self.fqdn),
                "List-Archive": "<http://%s/%s>" % (self.fqdn, self.get_absolute_url()),
            },
        )
        email.content_subtype = "text/html"
        email.send()