├── .editorconfig ├── .gitignore ├── .travis.yml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── dbes ├── __init__.py ├── admin.py ├── backends.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_email_ordering.py │ └── __init__.py ├── models.py ├── static │ ├── css │ │ └── dbes.css │ ├── img │ │ └── .gitignore │ └── js │ │ └── dbes.js ├── templates │ └── dbes │ │ └── detail.html ├── urls.py ├── utils.py └── views.py ├── docs ├── Makefile ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── manage.py ├── requirements-test.txt ├── requirements.txt ├── requirements_dev.txt ├── runtests.py ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── settings.py ├── test_backend.py ├── test_models.py ├── test_views.py └── urls.py └── tox.ini /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.{py,rst,ini}] 12 | indent_style = space 13 | indent_size = 4 14 | 15 | [*.{html,css,scss,json,yml}] 16 | indent_style = space 17 | indent_size = 2 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [Makefile] 23 | indent_style = tab 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | __pycache__ 3 | 4 | # C extensions 5 | *.so 6 | 7 | # Packages 8 | *.egg 9 | *.egg-info 10 | dist 11 | build 12 | eggs 13 | parts 14 | bin 15 | var 16 | sdist 17 | develop-eggs 18 | .installed.cfg 19 | lib 20 | lib64 21 | 22 | # Installer logs 23 | pip-log.txt 24 | 25 | # Unit test / coverage reports 26 | .coverage 27 | .tox 28 | nosetests.xml 29 | htmlcov 30 | 31 | # Translations 32 | *.mo 33 | 34 | # Mr Developer 35 | .mr.developer.cfg 36 | .project 37 | .pydevproject 38 | 39 | # Pycharm/Intellij 40 | .idea 41 | 42 | # Complexity 43 | output/*.html 44 | output/*/index.html 45 | 46 | # Sphinx 47 | docs/_build 48 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | env: 4 | - TOX_ENV=py27-django17 5 | - TOX_ENV=py27-django18 6 | - TOX_ENV=py27-django19 7 | - TOX_ENV=py34-django17 8 | - TOX_ENV=py34-django18 9 | - TOX_ENV=py34-django19 10 | 11 | cache: pip 12 | sudo: false 13 | 14 | install: 15 | - pip install tox 16 | 17 | script: 18 | - tox -e $TOX_ENV 19 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Eliot Berriot 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | 5 | Contributions are welcome, and they are greatly appreciated! Every 6 | little bit helps, and credit will always be given. 7 | 8 | You can contribute in many ways: 9 | 10 | Types of Contributions 11 | ---------------------- 12 | 13 | Report Bugs 14 | ~~~~~~~~~~~ 15 | 16 | Report bugs at https://github.com/EliotBerriot/django-dbes/issues. 17 | 18 | If you are reporting a bug, please include: 19 | 20 | * Your operating system name and version. 21 | * Any details about your local setup that might be helpful in troubleshooting. 22 | * Detailed steps to reproduce the bug. 23 | 24 | Fix Bugs 25 | ~~~~~~~~ 26 | 27 | Look through the GitHub issues for bugs. Anything tagged with "bug" 28 | is open to whoever wants to implement it. 29 | 30 | Implement Features 31 | ~~~~~~~~~~~~~~~~~~ 32 | 33 | Look through the GitHub issues for features. Anything tagged with "feature" 34 | is open to whoever wants to implement it. 35 | 36 | Write Documentation 37 | ~~~~~~~~~~~~~~~~~~~ 38 | 39 | django-dbes could always use more documentation, whether as part of the 40 | official django-dbes docs, in docstrings, or even on the web in blog posts, 41 | articles, and such. 42 | 43 | Submit Feedback 44 | ~~~~~~~~~~~~~~~ 45 | 46 | The best way to send feedback is to file an issue at https://github.com/EliotBerriot/django-dbes/issues. 47 | 48 | If you are proposing a feature: 49 | 50 | * Explain in detail how it would work. 51 | * Keep the scope as narrow as possible, to make it easier to implement. 52 | * Remember that this is a volunteer-driven project, and that contributions 53 | are welcome :) 54 | 55 | Get Started! 56 | ------------ 57 | 58 | Ready to contribute? Here's how to set up `django-dbes` for local development. 59 | 60 | 1. Fork the `django-dbes` repo on GitHub. 61 | 2. Clone your fork locally:: 62 | 63 | $ git clone git@github.com:your_name_here/django-dbes.git 64 | 65 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 66 | 67 | $ mkvirtualenv django-dbes 68 | $ cd django-dbes/ 69 | $ python setup.py develop 70 | 71 | 4. Create a branch for local development:: 72 | 73 | $ git checkout -b name-of-your-bugfix-or-feature 74 | 75 | Now you can make your changes locally. 76 | 77 | 5. When you're done making changes, check that your changes pass flake8 and the 78 | tests, including testing other Python versions with tox:: 79 | 80 | $ flake8 dbes tests 81 | $ python setup.py test 82 | $ tox 83 | 84 | To get flake8 and tox, just pip install them into your virtualenv. 85 | 86 | 6. Commit your changes and push your branch to GitHub:: 87 | 88 | $ git add . 89 | $ git commit -m "Your detailed description of your changes." 90 | $ git push origin name-of-your-bugfix-or-feature 91 | 92 | 7. Submit a pull request through the GitHub website. 93 | 94 | Pull Request Guidelines 95 | ----------------------- 96 | 97 | Before you submit a pull request, check that it meets these guidelines: 98 | 99 | 1. The pull request should include tests. 100 | 2. If the pull request adds functionality, the docs should be updated. Put 101 | your new functionality into a function with a docstring, and add the 102 | feature to the list in README.rst. 103 | 3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check 104 | https://travis-ci.org/EliotBerriot/django-dbes/pull_requests 105 | and make sure that the tests pass for all supported Python versions. 106 | 107 | Tips 108 | ---- 109 | 110 | To run a subset of tests:: 111 | 112 | $ python -m unittest tests.test_dbes 113 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 3 | History 4 | ------- 5 | 6 | 0.1.0 (2016-04-20) 7 | ++++++++++++++++++ 8 | 9 | * First release on PyPI. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Eliot Berriot 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of django-dbes nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | recursive-include dbes *.html *.png *.gif *js *.css *jpg *jpeg *svg *py 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean-pyc clean-build docs 2 | 3 | help: 4 | @echo "clean-build - remove build artifacts" 5 | @echo "clean-pyc - remove Python file artifacts" 6 | @echo "lint - check style with flake8" 7 | @echo "test - run tests quickly with the default Python" 8 | @echo "test-all - run tests on every Python version with tox" 9 | @echo "coverage - check code coverage quickly with the default Python" 10 | @echo "docs - generate Sphinx HTML documentation, including API docs" 11 | @echo "release - package and upload a release" 12 | @echo "sdist - package" 13 | 14 | clean: clean-build clean-pyc 15 | 16 | clean-build: 17 | rm -fr build/ 18 | rm -fr dist/ 19 | rm -fr *.egg-info 20 | 21 | clean-pyc: 22 | find . -name '*.pyc' -exec rm -f {} + 23 | find . -name '*.pyo' -exec rm -f {} + 24 | find . -name '*~' -exec rm -f {} + 25 | 26 | lint: 27 | flake8 dbes tests 28 | 29 | test: 30 | python runtests.py tests 31 | 32 | test-all: 33 | tox 34 | 35 | coverage: 36 | coverage run --source dbes runtests.py tests 37 | coverage report -m 38 | coverage html 39 | open htmlcov/index.html 40 | 41 | docs: 42 | rm -f docs/django-dbes.rst 43 | rm -f docs/modules.rst 44 | sphinx-apidoc -o docs/ dbes 45 | $(MAKE) -C docs clean 46 | $(MAKE) -C docs html 47 | open docs/_build/html/index.html 48 | 49 | release: clean 50 | python setup.py sdist upload 51 | python setup.py bdist_wheel upload 52 | 53 | sdist: clean 54 | python setup.py sdist 55 | ls -l dist 56 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | =========================================== 2 | django-dbes (Django Database Email Storage) 3 | =========================================== 4 | 5 | .. image:: https://badge.fury.io/py/django-dbes.png 6 | :target: https://badge.fury.io/py/django-dbes 7 | 8 | .. image:: https://travis-ci.org/EliotBerriot/django-dbes.png?branch=master 9 | :target: https://travis-ci.org/EliotBerriot/django-dbes 10 | 11 | A django package to speed-up your HTML email development workflow in django. 12 | 13 | **Warning**: this package is intended for development only. 14 | 15 | Use case 16 | -------- 17 | 18 | Working on email templates/styling in django can be really painful and slow: 19 | 20 | * Dumping the email content to console via django's `ConsoleBackend` is just not enough when you work with HTML emails 21 | * Sending the emails to a real adress is slow, requires a working SMTP server, and may be dangerous. It will also quickly spam your inbox. 22 | 23 | A possible answer 24 | ----------------- 25 | 26 | What if we could display sent emails directly in browser during development ? It's actually quite simple, and it's exactly 27 | what ``django-dbes`` does: 28 | 29 | 1. Instead of sending mails or logging them to console, they're stored as model instances in the database 30 | 2. The email URL is logged on the console so it can be accessed it in a web browser 31 | 3. The view behind this URL retrieves the model instance and renders its content in a template 32 | 33 | The project is also bundled with an admin module so you can quickly see what the last sent emails were and display them. 34 | 35 | Quickstart 36 | ---------- 37 | 38 | Install ``django-dbes``:: 39 | 40 | pip install django-dbes 41 | 42 | Then add the app to your settings.py:: 43 | 44 | INSTALLED_APPS = [ 45 | # other apps 46 | 'dbes', 47 | ] 48 | 49 | EMAIL_BACKEND = 'dbes.backends.EmailBackend' 50 | 51 | Add this to your URLs conf:: 52 | 53 | urlpatterns = [ 54 | # your urls 55 | url(r'^emails/', include('dbes.urls', namespace='dbes')), 56 | ] 57 | 58 | Run the migrations:: 59 | 60 | python manage.py migrate dbes 61 | 62 | From now on, each time you send an email, it will be saved as a model instead of being sent. You'll also see 63 | a log output in your console, such as: 64 | 65 | Sending email to contact@test.com with subject "Test". You can access this email at URL http://127.0.0.1:8000/emails/8b2b0bf2-bfb3-4771-a14c-f6d4dc9a635b 66 | 67 | Just click the email link to display it. 68 | 69 | 70 | Running Tests 71 | -------------- 72 | 73 | Does the code actually work? 74 | 75 | :: 76 | 77 | source /bin/activate 78 | (myenv) $ pip install -r requirements-test.txt 79 | (myenv) $ python runtests.py 80 | 81 | Credits 82 | --------- 83 | 84 | Tools used in rendering this package: 85 | 86 | * Cookiecutter_ 87 | * `cookiecutter-pypackage`_ 88 | 89 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 90 | .. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage 91 | -------------------------------------------------------------------------------- /dbes/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1.0' 2 | -------------------------------------------------------------------------------- /dbes/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from . import models 4 | 5 | 6 | @admin.register(models.Email) 7 | class EmailAdmin(admin.ModelAdmin): 8 | list_display = ('recipient', 'subject', 'from_email', 'creation_date', 'uuid') 9 | search_fields = ('recipient', 'subject', 'from_email', 'uuid') 10 | -------------------------------------------------------------------------------- /dbes/backends.py: -------------------------------------------------------------------------------- 1 | from django.core.mail.backends.base import BaseEmailBackend 2 | 3 | from .models import Email 4 | from . import utils 5 | 6 | class EmailBackend(BaseEmailBackend): 7 | def send_messages(self, email_messages): 8 | return len(self.create_email_model_instances(email_messages)) 9 | 10 | def create_email_model_instances(self, email_messages): 11 | instances = [Email.from_message(recipient, message) for message in email_messages for recipient in message.recipients()] 12 | Email.objects.bulk_create(instances) 13 | for email in instances: 14 | utils.log_email(email) 15 | 16 | return instances 17 | -------------------------------------------------------------------------------- /dbes/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9.5 on 2016-04-20 05:32 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.utils.timezone 7 | import uuid 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | initial = True 13 | 14 | dependencies = [ 15 | ] 16 | 17 | operations = [ 18 | migrations.CreateModel( 19 | name='Email', 20 | fields=[ 21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 22 | ('recipient', models.EmailField(db_index=True, max_length=254)), 23 | ('from_email', models.EmailField(max_length=254)), 24 | ('creation_date', models.DateTimeField(default=django.utils.timezone.now)), 25 | ('html_body', models.TextField(blank=True, null=True)), 26 | ('plain_body', models.TextField(blank=True, null=True)), 27 | ('subject', models.TextField()), 28 | ('uuid', models.CharField(default=uuid.uuid4, max_length=36, unique=True)), 29 | ], 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /dbes/migrations/0002_email_ordering.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.13 on 2018-09-11 17:50 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('dbes', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterModelOptions( 16 | name='email', 17 | options={'ordering': ('-creation_date',)}, 18 | ), 19 | ] 20 | 21 | -------------------------------------------------------------------------------- /dbes/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agateblue/django-dbes/45bc9b673257ac261a2daf8adac28625fae315fc/dbes/migrations/__init__.py -------------------------------------------------------------------------------- /dbes/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from uuid import uuid4 3 | 4 | from django.dispatch import receiver 5 | from django.db import models 6 | from django.utils import timezone 7 | from django.core.urlresolvers import reverse 8 | 9 | from . import utils 10 | 11 | class Email(models.Model): 12 | recipient = models.EmailField(db_index=True) 13 | from_email = models.EmailField() 14 | creation_date = models.DateTimeField(default=timezone.now) 15 | html_body = models.TextField(null=True, blank=True) 16 | plain_body = models.TextField(null=True, blank=True) 17 | subject = models.TextField() 18 | uuid = models.CharField(max_length=36, default=uuid4, unique=True) 19 | 20 | class Meta: 21 | ordering = ('-creation_date',) 22 | 23 | @classmethod 24 | def from_message(cls, recipient, message): 25 | """create a model instance from a django.core.mail.message.EmailMultiAlternatives instance""" 26 | instance = cls(recipient=recipient, subject=message.subject, from_email=message.from_email) 27 | 28 | if message.content_subtype == 'html': 29 | missing_alternative = 'plain' 30 | instance.html_body = message.body 31 | elif message.content_subtype == 'plain': 32 | missing_alternative = 'html' 33 | instance.plain_body = message.body 34 | else: 35 | raise ValueError('You must provide either a HTML or a plain body to DBES backend') 36 | 37 | for body, mimetype in getattr(message, 'alternatives', []): 38 | if mimetype == 'text/{0}'.format(missing_alternative): 39 | setattr(instance, '{0}_body'.format(missing_alternative), body) 40 | break 41 | return instance 42 | 43 | def get_absolute_url(self): 44 | return reverse('dbes:email-detail', kwargs={'uuid': self.uuid}) 45 | 46 | @receiver(models.signals.post_save, sender=Email) 47 | def log_email(sender, instance, created, **kwargs): 48 | if not created: 49 | return 50 | utils.log_email(instance) 51 | -------------------------------------------------------------------------------- /dbes/static/css/dbes.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agateblue/django-dbes/45bc9b673257ac261a2daf8adac28625fae315fc/dbes/static/css/dbes.css -------------------------------------------------------------------------------- /dbes/static/img/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agateblue/django-dbes/45bc9b673257ac261a2daf8adac28625fae315fc/dbes/static/img/.gitignore -------------------------------------------------------------------------------- /dbes/static/js/dbes.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agateblue/django-dbes/45bc9b673257ac261a2daf8adac28625fae315fc/dbes/static/js/dbes.js -------------------------------------------------------------------------------- /dbes/templates/dbes/detail.html: -------------------------------------------------------------------------------- 1 | {% if email.html_body %}{{ email.html_body|safe }}{% else %}{{ email.plain_body }}{% endif %} 2 | -------------------------------------------------------------------------------- /dbes/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import include, url 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | url(r'^(?P[-\w]+)$', views.EmailDetail.as_view(), name="email-detail"), 7 | ] 8 | -------------------------------------------------------------------------------- /dbes/utils.py: -------------------------------------------------------------------------------- 1 | import logging 2 | logger = logging.getLogger('django') 3 | 4 | from django.contrib.sites.shortcuts import get_current_site 5 | from django.conf import settings 6 | 7 | def log_email(email): 8 | request = None 9 | protocol = getattr(settings, 'HTTP_PROTOCOL', 'http') 10 | full_url = ''.join([protocol, '://', get_current_site(request).domain, email.get_absolute_url()]) 11 | logger.info('Sending email to {0} with subject "{1}". You can access this email at URL {2}'.format( 12 | email.recipient, 13 | email.subject, 14 | full_url 15 | )) 16 | -------------------------------------------------------------------------------- /dbes/views.py: -------------------------------------------------------------------------------- 1 | from django.views import generic 2 | from django.http import Http404 3 | 4 | from . import models 5 | 6 | 7 | class EmailDetail(generic.DetailView): 8 | template_name = 'dbes/detail.html' 9 | context_object_name = 'email' 10 | 11 | def get_object(self, queryset=None): 12 | try: 13 | return models.Email.objects.get(uuid=self.kwargs['uuid']) 14 | except models.Email.DoesNotExist: 15 | raise Http404 16 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/complexity" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # complexity documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jul 9 22:26:36 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | cwd = os.getcwd() 22 | parent = os.path.dirname(cwd) 23 | sys.path.append(parent) 24 | 25 | import dbes 26 | 27 | # -- General configuration ----------------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | #needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be extensions 33 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix of source filenames. 40 | source_suffix = '.rst' 41 | 42 | # The encoding of source files. 43 | #source_encoding = 'utf-8-sig' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = u'django-dbes' 50 | copyright = u'2016, Eliot Berriot' 51 | 52 | # The version info for the project you're documenting, acts as replacement for 53 | # |version| and |release|, also used in various other places throughout the 54 | # built documents. 55 | # 56 | # The short X.Y version. 57 | version = dbes.__version__ 58 | # The full version, including alpha/beta/rc tags. 59 | release = dbes.__version__ 60 | 61 | # The language for content autogenerated by Sphinx. Refer to documentation 62 | # for a list of supported languages. 63 | #language = None 64 | 65 | # There are two options for replacing |today|: either, you set today to some 66 | # non-false value, then it is used: 67 | #today = '' 68 | # Else, today_fmt is used as the format for a strftime call. 69 | #today_fmt = '%B %d, %Y' 70 | 71 | # List of patterns, relative to source directory, that match files and 72 | # directories to ignore when looking for source files. 73 | exclude_patterns = ['_build'] 74 | 75 | # The reST default role (used for this markup: `text`) to use for all documents. 76 | #default_role = None 77 | 78 | # If true, '()' will be appended to :func: etc. cross-reference text. 79 | #add_function_parentheses = True 80 | 81 | # If true, the current module name will be prepended to all description 82 | # unit titles (such as .. function::). 83 | #add_module_names = True 84 | 85 | # If true, sectionauthor and moduleauthor directives will be shown in the 86 | # output. They are ignored by default. 87 | #show_authors = False 88 | 89 | # The name of the Pygments (syntax highlighting) style to use. 90 | pygments_style = 'sphinx' 91 | 92 | # A list of ignored prefixes for module index sorting. 93 | #modindex_common_prefix = [] 94 | 95 | # If true, keep warnings as "system message" paragraphs in the built documents. 96 | #keep_warnings = False 97 | 98 | 99 | # -- Options for HTML output --------------------------------------------------- 100 | 101 | # The theme to use for HTML and HTML Help pages. See the documentation for 102 | # a list of builtin themes. 103 | html_theme = 'default' 104 | 105 | # Theme options are theme-specific and customize the look and feel of a theme 106 | # further. For a list of options available for each theme, see the 107 | # documentation. 108 | #html_theme_options = {} 109 | 110 | # Add any paths that contain custom themes here, relative to this directory. 111 | #html_theme_path = [] 112 | 113 | # The name for this set of Sphinx documents. If None, it defaults to 114 | # " v documentation". 115 | #html_title = None 116 | 117 | # A shorter title for the navigation bar. Default is the same as html_title. 118 | #html_short_title = None 119 | 120 | # The name of an image file (relative to this directory) to place at the top 121 | # of the sidebar. 122 | #html_logo = None 123 | 124 | # The name of an image file (within the static path) to use as favicon of the 125 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 126 | # pixels large. 127 | #html_favicon = None 128 | 129 | # Add any paths that contain custom static files (such as style sheets) here, 130 | # relative to this directory. They are copied after the builtin static files, 131 | # so a file named "default.css" will overwrite the builtin "default.css". 132 | html_static_path = ['_static'] 133 | 134 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 135 | # using the given strftime format. 136 | #html_last_updated_fmt = '%b %d, %Y' 137 | 138 | # If true, SmartyPants will be used to convert quotes and dashes to 139 | # typographically correct entities. 140 | #html_use_smartypants = True 141 | 142 | # Custom sidebar templates, maps document names to template names. 143 | #html_sidebars = {} 144 | 145 | # Additional templates that should be rendered to pages, maps page names to 146 | # template names. 147 | #html_additional_pages = {} 148 | 149 | # If false, no module index is generated. 150 | #html_domain_indices = True 151 | 152 | # If false, no index is generated. 153 | #html_use_index = True 154 | 155 | # If true, the index is split into individual pages for each letter. 156 | #html_split_index = False 157 | 158 | # If true, links to the reST sources are added to the pages. 159 | #html_show_sourcelink = True 160 | 161 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 162 | #html_show_sphinx = True 163 | 164 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 165 | #html_show_copyright = True 166 | 167 | # If true, an OpenSearch description file will be output, and all pages will 168 | # contain a tag referring to it. The value of this option must be the 169 | # base URL from which the finished HTML is served. 170 | #html_use_opensearch = '' 171 | 172 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 173 | #html_file_suffix = None 174 | 175 | # Output file base name for HTML help builder. 176 | htmlhelp_basename = 'django-dbesdoc' 177 | 178 | 179 | # -- Options for LaTeX output -------------------------------------------------- 180 | 181 | latex_elements = { 182 | # The paper size ('letterpaper' or 'a4paper'). 183 | #'papersize': 'letterpaper', 184 | 185 | # The font size ('10pt', '11pt' or '12pt'). 186 | #'pointsize': '10pt', 187 | 188 | # Additional stuff for the LaTeX preamble. 189 | #'preamble': '', 190 | } 191 | 192 | # Grouping the document tree into LaTeX files. List of tuples 193 | # (source start file, target name, title, author, documentclass [howto/manual]). 194 | latex_documents = [ 195 | ('index', 'django-dbes.tex', u'django-dbes Documentation', 196 | u'Eliot Berriot', 'manual'), 197 | ] 198 | 199 | # The name of an image file (relative to this directory) to place at the top of 200 | # the title page. 201 | #latex_logo = None 202 | 203 | # For "manual" documents, if this is true, then toplevel headings are parts, 204 | # not chapters. 205 | #latex_use_parts = False 206 | 207 | # If true, show page references after internal links. 208 | #latex_show_pagerefs = False 209 | 210 | # If true, show URL addresses after external links. 211 | #latex_show_urls = False 212 | 213 | # Documents to append as an appendix to all manuals. 214 | #latex_appendices = [] 215 | 216 | # If false, no module index is generated. 217 | #latex_domain_indices = True 218 | 219 | 220 | # -- Options for manual page output -------------------------------------------- 221 | 222 | # One entry per manual page. List of tuples 223 | # (source start file, name, description, authors, manual section). 224 | man_pages = [ 225 | ('index', 'django-dbes', u'django-dbes Documentation', 226 | [u'Eliot Berriot'], 1) 227 | ] 228 | 229 | # If true, show URL addresses after external links. 230 | #man_show_urls = False 231 | 232 | 233 | # -- Options for Texinfo output ------------------------------------------------ 234 | 235 | # Grouping the document tree into Texinfo files. List of tuples 236 | # (source start file, target name, title, author, 237 | # dir menu entry, description, category) 238 | texinfo_documents = [ 239 | ('index', 'django-dbes', u'django-dbes Documentation', 240 | u'Eliot Berriot', 'django-dbes', 'One line description of project.', 241 | 'Miscellaneous'), 242 | ] 243 | 244 | # Documents to append as an appendix to all manuals. 245 | #texinfo_appendices = [] 246 | 247 | # If false, no module index is generated. 248 | #texinfo_domain_indices = True 249 | 250 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 251 | #texinfo_show_urls = 'footnote' 252 | 253 | # If true, do not generate a @detailmenu in the "Top" node's menu. 254 | #texinfo_no_detailmenu = False 255 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. complexity documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to django-dbes's documentation! 7 | ================================================================= 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | readme 15 | installation 16 | usage 17 | contributing 18 | authors 19 | history 20 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Installation 3 | ============ 4 | 5 | At the command line:: 6 | 7 | $ easy_install django-dbes 8 | 9 | Or, if you have virtualenvwrapper installed:: 10 | 11 | $ mkvirtualenv django-dbes 12 | $ pip install django-dbes 13 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Usage 3 | ======== 4 | 5 | To use django-dbes in a project:: 6 | 7 | import dbes 8 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | import signal 5 | 6 | BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 7 | def sigterm_handler(signum, frame): 8 | sys.exit(1) 9 | 10 | if __name__ == "__main__": 11 | sys.path.append(os.path.join(BASE_DIR, 'tests')) 12 | sys.path.append(os.path.join(BASE_DIR, 'dbes')) 13 | 14 | signal.signal(signal.SIGTERM, sigterm_handler) 15 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "phonealchemist.settings") 16 | 17 | from django.core.management import execute_from_command_line 18 | 19 | execute_from_command_line(sys.argv) 20 | -------------------------------------------------------------------------------- /requirements-test.txt: -------------------------------------------------------------------------------- 1 | coverage 2 | mock>=1.0.1 3 | flake8>=2.1.0 4 | tox>=1.7.0 5 | 6 | # Additional test requirements go here 7 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | django>=1.9.1 2 | # Additional requirements go here 3 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | bumpversion==0.5.3 2 | wheel==0.24.0 3 | -------------------------------------------------------------------------------- /runtests.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | TEST_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tests') 3 | 4 | try: 5 | from django.conf import settings 6 | from django.test.utils import get_runner 7 | 8 | settings.configure( 9 | DEBUG=True, 10 | USE_TZ=True, 11 | DATABASES={ 12 | "default": { 13 | "ENGINE": "django.db.backends.sqlite3", 14 | } 15 | }, 16 | ROOT_URLCONF="tests.urls", 17 | INSTALLED_APPS=[ 18 | "django.contrib.auth", 19 | "django.contrib.admin", 20 | "django.contrib.contenttypes", 21 | "django.contrib.sites", 22 | "dbes", 23 | ], 24 | SITE_ID=1, 25 | MIDDLEWARE_CLASSES=(), 26 | ) 27 | 28 | try: 29 | import django 30 | setup = django.setup 31 | except AttributeError: 32 | pass 33 | else: 34 | setup() 35 | 36 | except ImportError: 37 | import traceback 38 | traceback.print_exc() 39 | raise ImportError("To fix this error, run: pip install -r requirements-test.txt") 40 | 41 | 42 | def run_tests(*test_args): 43 | if not test_args: 44 | test_args = ['tests'] 45 | 46 | # Run tests 47 | TestRunner = get_runner(settings) 48 | test_runner = TestRunner() 49 | 50 | failures = test_runner.run_tests(test_args) 51 | 52 | if failures: 53 | sys.exit(bool(failures)) 54 | 55 | 56 | if __name__ == '__main__': 57 | run_tests(*sys.argv[1:]) 58 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.1.0 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | 8 | [bumpversion:file:dbes/__init__.py] 9 | 10 | [wheel] 11 | universal = 1 12 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import os 4 | import re 5 | import sys 6 | 7 | try: 8 | from setuptools import setup 9 | except ImportError: 10 | from distutils.core import setup 11 | 12 | 13 | def get_version(*file_paths): 14 | filename = os.path.join(os.path.dirname(__file__), *file_paths) 15 | version_file = open(filename).read() 16 | version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", 17 | version_file, re.M) 18 | if version_match: 19 | return version_match.group(1) 20 | raise RuntimeError('Unable to find version string.') 21 | 22 | version = get_version('dbes', '__init__.py') 23 | 24 | if sys.argv[-1] == 'publish': 25 | try: 26 | import wheel 27 | except ImportError: 28 | print('Wheel library missing. Please run "pip install wheel"') 29 | sys.exit() 30 | os.system('python setup.py sdist upload') 31 | os.system('python setup.py bdist_wheel upload') 32 | sys.exit() 33 | 34 | if sys.argv[-1] == 'tag': 35 | print("Tagging the version on github:") 36 | os.system("git tag -a %s -m 'version %s'" % (version, version)) 37 | os.system("git push --tags") 38 | sys.exit() 39 | 40 | readme = open('README.rst').read() 41 | history = open('HISTORY.rst').read().replace('.. :changelog:', '') 42 | 43 | setup( 44 | name='django-dbes', 45 | version=version, 46 | description="""A django package to speed-up your HTML email developpement workflow in django""", 47 | long_description=readme + '\n\n' + history, 48 | author='Eliot Berriot', 49 | author_email='contact@eliotberriot.com', 50 | url='https://github.com/EliotBerriot/django-dbes', 51 | packages=[ 52 | 'dbes', 53 | ], 54 | include_package_data=True, 55 | install_requires=[ 56 | ], 57 | license="BSD", 58 | zip_safe=False, 59 | keywords='django-dbes', 60 | classifiers=[ 61 | 'Development Status :: 3 - Alpha', 62 | 'Framework :: Django', 63 | 'Framework :: Django :: 1.8', 64 | 'Framework :: Django :: 1.9', 65 | 'Intended Audience :: Developers', 66 | 'License :: OSI Approved :: BSD License', 67 | 'Natural Language :: English', 68 | 'Programming Language :: Python :: 2', 69 | 'Programming Language :: Python :: 2.7', 70 | 'Programming Language :: Python :: 3', 71 | 'Programming Language :: Python :: 3.4', 72 | ], 73 | ) 74 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agateblue/django-dbes/45bc9b673257ac261a2daf8adac28625fae315fc/tests/__init__.py -------------------------------------------------------------------------------- /tests/settings.py: -------------------------------------------------------------------------------- 1 | from django.conf.global_settings import * 2 | 3 | SECRET_KEY = "test" 4 | INSTALLED_APPS = [ 5 | "django.contrib.auth", 6 | "django.contrib.contenttypes", 7 | "django.contrib.sites", 8 | "dbes", 9 | ] 10 | -------------------------------------------------------------------------------- /tests/test_backend.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from django.test import TestCase, override_settings 6 | from django.utils import timezone 7 | from django.core import mail 8 | 9 | from dbes import models 10 | 11 | @override_settings(EMAIL_BACKEND='dbes.backends.EmailBackend') 12 | class TestDbes(TestCase): 13 | 14 | def setUp(self): 15 | pass 16 | 17 | def test_email_plain_creation(self): 18 | recipients = [ 19 | 'to1@to.com', 20 | 'to2@to.com', 21 | ] 22 | mail.send_mail('subject', 'message', 'from@from.com', recipients) 23 | for r in recipients: 24 | e = models.Email.objects.get(recipient=r) 25 | self.assertEqual(e.subject, 'subject') 26 | self.assertEqual(e.from_email, 'from@from.com') 27 | self.assertEqual(e.plain_body, 'message') 28 | self.assertEqual(e.html_body, None) 29 | 30 | def test_email_html_creation(self): 31 | recipients = [ 32 | 'to1@to.com', 33 | 'to2@to.com', 34 | ] 35 | mail.send_mail('subject', 'message', 'from@from.com', recipients, html_message='message') 36 | for r in recipients: 37 | e = models.Email.objects.get(recipient=r) 38 | self.assertEqual(e.subject, 'subject') 39 | self.assertEqual(e.from_email, 'from@from.com') 40 | self.assertEqual(e.html_body, 'message') 41 | self.assertEqual(e.plain_body, 'message') 42 | 43 | 44 | def tearDown(self): 45 | pass 46 | -------------------------------------------------------------------------------- /tests/test_models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | test_django-dbes 6 | ------------ 7 | 8 | Tests for `django-dbes` models module. 9 | """ 10 | 11 | from django.test import TestCase 12 | from django.utils import timezone 13 | 14 | from dbes import models 15 | 16 | 17 | class TestDbes(TestCase): 18 | 19 | def setUp(self): 20 | pass 21 | 22 | def test_email_creation(self): 23 | now = timezone.now() 24 | email = models.Email(recipient='test@test.com', subject='test', html_body='test') 25 | email.save() 26 | self.assertGreater(email.creation_date, now) 27 | 28 | def tearDown(self): 29 | pass 30 | -------------------------------------------------------------------------------- /tests/test_views.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from django.test import TestCase, override_settings 6 | from django.utils import timezone 7 | from django.core import mail 8 | 9 | from dbes import models 10 | 11 | @override_settings(EMAIL_BACKEND='dbes.backends.EmailBackend') 12 | class TestDbes(TestCase): 13 | 14 | def test_can_display_txt_email_in_view(self): 15 | mail.send_mail('subject', 'message', 'from@from.com', ['to1@to.com']) 16 | 17 | e = models.Email.objects.get(recipient='to1@to.com') 18 | url = e.get_absolute_url() 19 | response = self.client.get(url) 20 | self.assertEqual(response.status_code, 200) 21 | self.assertHTMLEqual(response.content.decode('utf-8'), 'message') 22 | 23 | def test_can_display_html_email_in_view(self): 24 | mail.send_mail('subject', 'message', 'from@from.com', ['to1@to.com'], html_message='message') 25 | 26 | e = models.Email.objects.get(recipient='to1@to.com') 27 | url = e.get_absolute_url() 28 | response = self.client.get(url) 29 | self.assertEqual(response.status_code, 200) 30 | self.assertHTMLEqual(response.content.decode('utf-8'), 'message') 31 | -------------------------------------------------------------------------------- /tests/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import include, url 2 | 3 | 4 | urlpatterns = [ 5 | url(r'^emails/', include('dbes.urls', namespace='dbes')), 6 | ] 7 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | #[tox] 2 | #envlist = py27, py33, py34, py35 3 | # 4 | #[testenv] 5 | #setenv = 6 | # PYTHONPATH = {toxinidir}:{toxinidir}/dbes 7 | #commands = python runtests.py 8 | #deps = 9 | # -r{toxinidir}/requirements-test.txt 10 | 11 | # Tox (http://tox.testrun.org/) is a tool for running tests 12 | # in multiple virtualenvs. This configuration file will run the 13 | # test suite on all supported python versions. To use it, "pip install tox" 14 | # and then run "tox" from this directory. 15 | 16 | [tox] 17 | skipsdist = True 18 | envlist = 19 | py{27,34,35}-django{17,18,19} 20 | 21 | [testenv] 22 | basepython = 23 | py26: python2.6 24 | py27: python2.7 25 | py32: python3.2 26 | py33: python3.3 27 | py34: python3.4 28 | py35: python3.5 29 | 30 | setenv = 31 | PYTHONPATH = {toxinidir}:{toxinidir}/dbes 32 | commands = python runtests.py {posargs} 33 | deps = 34 | -r{toxinidir}/requirements-test.txt 35 | django17: Django>=1.7,<1.8 36 | django18: Django>=1.8,<1.9 37 | django19: Django>=1.9,<1.10 38 | --------------------------------------------------------------------------------