def test_factory_registration(self):

        factory.register(TestMail)
        self.assertIn('test', factory.mail_map)

        factory.unregister(TestMail)
        self.assertNotIn('test', factory.mail_map)
 def setUp(self):
     factory.register(TestMail)
Beispiel #3
0
def activation_url():
    return '%s%s' % (
        settings.SITE_URL, reverse('registration_activate',
                                   args=[str(uuid.uuid4()).replace('-', '')]))


class EmailChangeRequestForm(BaseMailForm):
    """Here, there is no inputs, all data is provided by get_context_data()."""
    email_request = forms.ModelChoiceField(queryset=EmailChangeRequest.objects.all())
    activation_url = forms.URLField()

    def __init__(self, *args, **kwargs):
        if 'mail_class' in kwargs:
            self.mail_class = kwargs.pop('mail_class')
        forms.Form.__init__(self, *args, **kwargs)

    def get_preview_data(self):
        User = get_user_model()
        user = User(username=u'johndoe',
                    first_name=u'John',
                    last_name=u'Doe',
                    title=u'MR')
        email_request = EmailChangeRequest(user=user, email=user.email)
        url = activation_url()
        return {'email_request': email_request,
                'activation_url': url}


factory.register(EmailChangeRequestMail, EmailChangeRequestForm)
Beispiel #4
0
from mail_factory.mails import BaseMail
from mail_factory import factory


class CommentMail(BaseMail):
    template_name = 'comments'
    params = ['title', 'content']


factory.register(CommentMail)
Beispiel #5
0
from django.conf import settings

from mail_factory import factory, mails


class BaseMail(mails.BaseMail):
    def get_context_data(self, *args, **kwargs):
        return {
            "FORJ_CONTACT_EMAIL": settings.FORJ_CONTACT_EMAIL,
            "FORJ_PHONE_NUMBER": settings.FORJ_PHONE_NUMBER,
        }


class ConfirmationMail(BaseMail):
    template_name = "confirmation"
    params = ["order"]


factory.register(ConfirmationMail)
Beispiel #6
0
from mail_factory import factory, BaseMail, MailForm


class CustomFormMail(BaseMail):
    template_name = "custom_form"
    params = ["title", "content"]


class CustomFormMailForm(MailForm):
    class Meta:
        initial = {"title": "My initial subject", "content": "My initial content"}


factory.register(CustomFormMail, mail_form=CustomFormMailForm)


class NoCustomMail(BaseMail):
    template_name = "no_custom"
    params = ["title", "content"]


factory.register(NoCustomMail)  # default form
Beispiel #7
0
#-*- coding: utf-8 -*-
from mail_factory import factory
from mail_factory.mails import BaseMail


class AdModifiedMessageEmail(BaseMail):
    """
    Ad Modified Message mail
    Used when a user update a new ad
    """
    template_name = 'ad_modified_email'
    params = ['user', 'site_name', 'site_url']

factory.register(AdModifiedMessageEmail)


class AdModeratedMessageEmail(BaseMail):
    """
    Override the default mail sent from moderation
    """
    template_name = 'ad_moderated_email'
    params = ['user', 'site_name', 'site_url']


class UserSignIn(BaseMail):
    """
    User Sign In
    """
    template_name = 'user_sign_in'
    params = ['user', 'site_name', 'site_url']
Beispiel #8
0
from mail_factory import factory, BaseMail, MailForm


class CustomFormMail(BaseMail):
    template_name = 'custom_form'
    params = ['title', 'content']


class CustomFormMailForm(MailForm):
    class Meta:
        initial = {
            'title': 'My initial subject',
            'content': 'My initial content'
        }


factory.register(CustomFormMail, mail_form=CustomFormMailForm)


class NoCustomMail(BaseMail):
    template_name = 'no_custom'
    params = ['title', 'content']


factory.register(NoCustomMail)  # default form
Beispiel #9
0
#-*- coding: utf-8 -*-
from mail_factory import factory
from mail_factory.mails import BaseMail


class AdModifiedMessageEmail(BaseMail):
    """
    Ad Modified Message mail
    Used when a user update a new ad
    """
    template_name = 'ad_modified_email'
    params = ['user', 'site_name', 'site_url']


factory.register(AdModifiedMessageEmail)


class AdModeratedMessageEmail(BaseMail):
    """
    Override the default mail sent from moderation
    """
    template_name = 'ad_moderated_email'
    params = ['user', 'site_name', 'site_url']


class UserSignIn(BaseMail):
    """
    User Sign In
    """
    template_name = 'user_sign_in'
    params = ['user', 'site_name', 'site_url']
def register(*args, **kwargs):
    """Register notification

    Wraps factory.register from django-mail-factory
    """
    return factory.register(*args, **kwargs)