Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.

Commit 55dad01

Browse files
authored
Merge pull request #18 from dipcode-software/feat/name-refactor
refactor on app name
2 parents 0387483 + c881a76 commit 55dad01

17 files changed

+60
-57
lines changed

.coveragerc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[run]
2-
source=mailings/
2+
source=cbmail/
33
branch=True
44
omit=
55
*tests*
@@ -20,4 +20,4 @@ exclude_lines =
2020

2121
# Don't complain if tests don't hit defensive assertion code:
2222
raise AssertionError
23-
raise NotImplementedError
23+
raise NotImplementedError

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include LICENSE
22
include MANIFEST.in
33
include README.md
4-
recursive-include mailings/templates *
4+
recursive-include cbmail/templates *

README.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Django maillings
1+
Django CBMail
22
================
33

44
|Build Status| |Codacy Badge| |Coverage Status| |BCH compliance|
@@ -19,20 +19,20 @@ To install the app run :
1919

2020
.. code:: shell
2121
22-
pip install django-mailings
22+
pip install django-cbmail
2323
2424
or add it to the list of requirements of your project.
2525

2626
Example usage
2727
-------------
2828

29-
Use the BaseMailing class to define your email like:
29+
Create a mails.py and use the BaseMail class to define your email like:
3030

3131
.. code:: python
3232
33-
from mailings.mailings import BaseMailing
33+
from cbmail.base import BaseMail
3434
35-
class ExampleEmail(BaseMailing):
35+
class ExampleEmail(BaseMail):
3636
""" """
3737
template_name = "myapp/mails/myemail.html"
3838
subject = "Example subject of email"
@@ -56,7 +56,7 @@ settings:
5656
5757
DEFAULT_FROM_EMAIL = "[email protected]"
5858
59-
MAILINGS = {
59+
CBMAIL = {
6060
'DEFAULT_REPLY_TO': "[email protected]",
6161
'DEFAULT_SUJECT': "Example subject",
6262
'BASE_URL': "https://domain.com",
@@ -84,11 +84,11 @@ projects and commercial products.
8484
.. _Settings reference: #settings-reference
8585
.. _License: #license
8686

87-
.. |Build Status| image:: https://travis-ci.org/dipcode-software/django-mailings.svg?branch=master
88-
:target: https://travis-ci.org/dipcode-software/django-mailings
87+
.. |Build Status| image:: https://travis-ci.org/dipcode-software/django-cbmail.svg?branch=master
88+
:target: https://travis-ci.org/dipcode-software/django-cbmail
8989
.. |Codacy Badge| image:: https://api.codacy.com/project/badge/Grade/d01ebbe43c684d478cacc530e44633ad
90-
:target: https://www.codacy.com/app/srtabs/django-mailings?utm_source=github.com&utm_medium=referral&utm_content=dipcode-software/django-mailings&utm_campaign=Badge_Grade
91-
.. |Coverage Status| image:: https://coveralls.io/repos/github/dipcode-software/django-mailings/badge.svg?branch=master
92-
:target: https://coveralls.io/github/dipcode-software/django-mailings?branch=master
93-
.. |BCH compliance| image:: https://bettercodehub.com/edge/badge/dipcode-software/django-mailings?branch=master
90+
:target: https://www.codacy.com/app/srtabs/django-cbmail?utm_source=github.com&utm_medium=referral&utm_content=dipcode-software/django-cbmail&utm_campaign=Badge_Grade
91+
.. |Coverage Status| image:: https://coveralls.io/repos/github/dipcode-software/django-cbmail/badge.svg?branch=master
92+
:target: https://coveralls.io/github/dipcode-software/django-cbmail?branch=master
93+
.. |BCH compliance| image:: https://bettercodehub.com/edge/badge/dipcode-software/django-cbmail?branch=master
9494
:target: https://bettercodehub.com/

cbmail/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
default_app_config = 'cbmail.apps.CBMAilConfig'
2+
3+
__version__ = '0.1.0'

mailings/apps.py cbmail/apps.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from django.apps import AppConfig
44

55

6-
class MailingsConfig(AppConfig):
7-
name = 'mailings'
6+
class CBMAilConfig(AppConfig):
7+
name = 'cbmail'

mailings/base.py cbmail/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import unicode_literals
22

3+
from cbmail.conf import settings
34
from django.conf import settings as dj_settings
45
from django.core.mail import get_connection
56
from django.core.mail.message import EmailMultiAlternatives
67
from django.template import loader
78
from django.utils.html import strip_tags
8-
from mailings.conf import settings
99

1010

11-
class BaseMailing(object):
11+
class BaseMail(object):
1212
"""
1313
This class represents the base of a templated email
1414
TODO: add prefix support to subject
@@ -49,7 +49,7 @@ def get_mail_to(self, object_or_list):
4949
raise ValueError(
5050
'object_or_list must be object with get_mailing_list method '
5151
'defined or list instance.')
52-
return BaseMailing._filter_whitelist(object_or_list)
52+
return BaseMail._filter_whitelist(object_or_list)
5353

5454
def get_mail_cc(self):
5555
""" Returns the list of emails to be used on cc email field """

mailings/conf.py cbmail/conf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from django.core.exceptions import ImproperlyConfigured
66

77

8+
APP_NAME = 'CBMAIL'
9+
810
DEFAULTS = {
911
'DEFAULT_REPLY_TO': '[email protected]',
1012
'DEFAULT_SUJECT': 'Example subject',
@@ -30,7 +32,7 @@ def check_settings(self):
3032

3133
@property
3234
def user_settings(self):
33-
return getattr(dj_settings, 'MAILINGS', {})
35+
return getattr(dj_settings, APP_NAME, {})
3436

3537
def __getattr__(self, attr):
3638
""" """
File renamed without changes.
File renamed without changes.
File renamed without changes.

mailings/tests/test_base.py cbmail/tests/test_base.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from tempfile import NamedTemporaryFile
22

3+
from cbmail.base import Attachment, BaseMail
4+
from cbmail.mixins import MailingListMixin
35
from django.test import SimpleTestCase
4-
from mailings.base import Attachment, BaseMailing
5-
from mailings.mixins import MailingListMixin
66
from mock import patch
77

88

9-
class TestBaseObject(BaseMailing):
10-
template_name = 'mailings/base.html'
9+
class TestBaseObject(BaseMail):
10+
template_name = 'cbmail/base.html'
1111
mail_to = [('dev', '[email protected]')]
1212
mail_cc = ['[email protected]']
1313
mail_bcc = ['[email protected]']
@@ -27,8 +27,8 @@ def get_attachments(self):
2727
return [att]
2828

2929

30-
class TestBaseNoInfoObject(BaseMailing):
31-
template_name = 'mailings/base.html'
30+
class TestBaseNoInfoObject(BaseMail):
31+
template_name = 'cbmail/base.html'
3232
mail_to = [('dev', '[email protected]')]
3333
mail_cc = ['[email protected]']
3434
mail_bcc = ['[email protected]']
@@ -72,18 +72,18 @@ def test_get_mail_to_error(self):
7272
ValueError, self.object.get_mail_to, '"invalid type"')
7373

7474
def test_filter_whitelist(self):
75-
with self.settings(MAILINGS={'WHITELIST': ['[email protected]', '[email protected]']}):
76-
result = BaseMailing._filter_whitelist(['[email protected]', '[email protected]'])
75+
with self.settings(CBMAIL={'WHITELIST': ['[email protected]', '[email protected]']}):
76+
result = BaseMail._filter_whitelist(['[email protected]', '[email protected]'])
7777
self.assertEqual(result, ['[email protected]'])
7878

7979
def test_filter_whitelist_not_defined(self):
80-
with self.settings(MAILINGS={}):
81-
result = BaseMailing._filter_whitelist(['[email protected]', '[email protected]'])
80+
with self.settings(CBMAIL={}):
81+
result = BaseMail._filter_whitelist(['[email protected]', '[email protected]'])
8282
self.assertEqual(result, ['[email protected]', '[email protected]'])
8383

8484
def test_filter_whitelist_empty(self):
85-
with self.settings(MAILINGS={'WHITELIST': ['[email protected]', '[email protected]']}):
86-
result = BaseMailing._filter_whitelist(['[email protected]', '[email protected]'])
85+
with self.settings(CBMAIL={'WHITELIST': ['[email protected]', '[email protected]']}):
86+
result = BaseMail._filter_whitelist(['[email protected]', '[email protected]'])
8787
self.assertEqual(result, [])
8888

8989
def test_get_mail_cc(self):
@@ -120,13 +120,13 @@ def test_get_no_info_subject(self):
120120

121121
def test_get_template_name(self):
122122
result = self.object.get_template_name()
123-
self.assertEqual(result, 'mailings/base.html')
123+
self.assertEqual(result, 'cbmail/base.html')
124124

125125
def test_get_base_url(self):
126126
result = self.object.get_base_url()
127127
self.assertEqual(result, 'https://domain.com')
128128

129-
@patch('mailings.base.loader.render_to_string')
129+
@patch('cbmail.base.loader.render_to_string')
130130
def test_render(self, render_to_string):
131131
render_to_string.return_value = "dummy"
132132
result = self.object.render()
@@ -138,9 +138,9 @@ def test_render(self, render_to_string):
138138
'subject': self.object.get_subject()
139139
})
140140

141-
@patch('mailings.base.loader.render_to_string')
141+
@patch('cbmail.base.loader.render_to_string')
142142
def test_render_extra_data(self, render_to_string):
143-
with self.settings(MAILINGS={
143+
with self.settings(CBMAIL={
144144
'EXTRA_DATA': {'dummy_key': 'dummy_value'}}):
145145
render_to_string.return_value = "dummy"
146146
result = self.object.render()
@@ -153,11 +153,11 @@ def test_render_extra_data(self, render_to_string):
153153
'dummy_key': 'dummy_value'
154154
})
155155

156-
@patch('mailings.base.get_connection')
156+
@patch('cbmail.base.get_connection')
157157
def test_get_send_empty(self, get_connection):
158158
self.assertEqual(self.object.send([]), 0)
159159

160-
@patch('mailings.base.get_connection')
160+
@patch('cbmail.base.get_connection')
161161
def test_get_send(self, get_connection):
162162
self.object.send(['[email protected]'])
163163
get_connection().send_messages.assert_called_once()

mailings/tests/test_conf.py cbmail/tests/test_conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
from cbmail.conf import settings
45
from django.core.exceptions import ImproperlyConfigured
56
from django.test import SimpleTestCase
6-
from mailings.conf import settings
77

88

99
class MailingsSettingsTest(SimpleTestCase):
@@ -16,10 +16,10 @@ def test_getattr_default(self):
1616
self.assertEqual(settings.WHITELIST, [])
1717

1818
def test_getattr_user(self):
19-
with self.settings(MAILINGS={'BASE_URL': 'https://domain.com'}):
19+
with self.settings(CBMAIL={'BASE_URL': 'https://domain.com'}):
2020
self.assertEqual(settings.BASE_URL, 'https://domain.com')
2121

2222
def test_check_settings(self):
23-
with self.settings(MAILINGS={}):
23+
with self.settings(CBMAIL={}):
2424
with self.assertRaises(ImproperlyConfigured):
2525
settings.check_settings()

mailings/tests/test_mixins.py cbmail/tests/test_mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.test import SimpleTestCase
22

3-
from mailings.mixins import MailingListMixin
3+
from cbmail.mixins import MailingListMixin
44

55

66
class MixinsTest(SimpleTestCase):

mailings/__init__.py

-3
This file was deleted.

runtests.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import django
21
import sys
32

4-
from django.test.runner import DiscoverRunner
3+
import django
4+
55
from django.conf import settings
6+
from django.test.runner import DiscoverRunner
7+
68

79
settings.configure(
810
INSTALLED_APPS=(
9-
'mailings',
11+
'cbmail',
1012
),
11-
MAILINGS={
13+
CBMAIL={
1214
'DEFAULT_REPLY_TO': "[email protected]",
1315
'DEFAULT_SUJECT': "Unit test default",
1416
'BASE_URL': "https://domain.com",
@@ -24,6 +26,6 @@
2426
if __name__ == "__main__":
2527
django.setup()
2628
runner = DiscoverRunner()
27-
failures = runner.run_tests(['mailings'])
29+
failures = runner.run_tests(['cbmail'])
2830
if failures:
2931
sys.exit(failures)

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111

1212
# Package meta-data.
13-
VERSION = __import__("mailings").__version__
14-
NAME = 'django-mailings'
13+
VERSION = __import__("cbmail").__version__
14+
NAME = 'django-cbmail'
1515
DESCRIPTION = 'Django module to easily send templated emails. '
16-
URL = 'https://github.com/dipcode-software/django-mailings/'
16+
URL = 'https://github.com/dipcode-software/django-cbmail/'
1717
1818
AUTHOR = 'Dipcode'
1919

tox.ini

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands = {envpython} runtests.py
88

99
[testenv:flake8]
1010
deps = flake8
11-
commands = flake8 {toxinidir}/mailings --exclude=*/migrations/*,*settings*
11+
commands = flake8 {toxinidir}/cbmail --exclude=*/migrations/*,*settings*
1212

1313
[testenv:coverage]
1414
basepython=python2.7
@@ -23,7 +23,7 @@ commands=
2323
coverage erase
2424

2525
[testenv:travis]
26-
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH CODACY_PROJECT_TOKEN
26+
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
2727
deps =
2828
-r{toxinidir}/requirements/tests.txt
2929
coverage
@@ -36,4 +36,3 @@ commands =
3636
coverage report
3737
coverage xml
3838
coveralls
39-
python-codacy-coverage -r coverage.xml

0 commit comments

Comments
 (0)