├── .coveragerc ├── .editorconfig ├── .gitignore ├── .travis.yml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── docs ├── Makefile ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── requirements-test.txt ├── requirements.txt ├── runtests.py ├── setup.cfg ├── setup.py ├── spam ├── __init__.py ├── admin.py ├── behaviors.py ├── exceptions.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20150728_2050.py │ └── __init__.py ├── models.py ├── static │ ├── css │ │ └── spam.css │ ├── img │ │ └── .gitignore │ └── js │ │ └── spam.js ├── templates │ └── spam │ │ ├── base.html │ │ ├── spammyposting_form.html │ │ └── thanks.html ├── urls.py ├── utils.py └── views.py ├── test_app ├── __init__.py ├── migrations │ ├── 0001_initial.py │ └── __init__.py ├── models.py ├── urls.py └── views.py ├── tests ├── __init__.py ├── test_models.py ├── test_utils.py └── test_views.py └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | include = spam/* 3 | omit = *migrations*, *urls* 4 | -------------------------------------------------------------------------------- /.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 | [*.py] 16 | # https://github.com/timothycrosley/isort/wiki/isort-Settings 17 | line_length=120 18 | multi_line_output=3 19 | default_section=THIRDPARTY 20 | 21 | [*.yml] 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*.md] 26 | trim_trailing_whitespace = false 27 | 28 | [Makefile] 29 | indent_style = tab -------------------------------------------------------------------------------- /.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 | eggs 14 | parts 15 | bin 16 | var 17 | sdist 18 | develop-eggs 19 | .installed.cfg 20 | lib 21 | lib64 22 | 23 | # Installer logs 24 | pip-log.txt 25 | 26 | # Unit test / coverage reports 27 | .coverage 28 | .tox 29 | nosetests.xml 30 | 31 | # Translations 32 | *.mo 33 | 34 | # Mr Developer 35 | .mr.developer.cfg 36 | .project 37 | .pydevproject 38 | 39 | # Complexity 40 | output/*.html 41 | output/*/index.html 42 | 43 | # Sphinx 44 | docs/_build 45 | 46 | htmlcov 47 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.org 2 | 3 | language: python 4 | 5 | python: 6 | - "3.4" 7 | - "3.4" 8 | - "3.3" 9 | - "2.7" 10 | 11 | before_install: 12 | - pip install codecov 13 | 14 | # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors 15 | install: pip install -r requirements-test.txt 16 | 17 | # command to run tests using coverage, e.g. python setup.py test 18 | script: coverage run --source spam runtests.py 19 | 20 | after_success: 21 | - codecov 22 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Daniel Roy Greenfeld 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/pydanny/dj-spam/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 | dj-spam could always use more documentation, whether as part of the 40 | official dj-spam 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/pydanny/dj-spam/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 `dj-spam` for local development. 59 | 60 | 1. Fork the `dj-spam` repo on GitHub. 61 | 2. Clone your fork locally:: 62 | 63 | $ git clone git@github.com:your_name_here/dj-spam.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 dj-spam 68 | $ cd dj-spam/ 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 spam 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/pydanny/dj-spam/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_spam 113 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 3 | History 4 | ------- 5 | 6 | 0.3.0 ??? 7 | ++++++++++ 8 | 9 | * Added codecov.io badge 10 | * Officially supporting Python 3.5 11 | 12 | 13 | 0.2.0 (2-15-07-29) 14 | ++++++++++++++++++ 15 | 16 | * Added admin functionality. 17 | * Fixed broken spam report form. 18 | * Email of managers when content is flagged as spam. 19 | 20 | 0.1.0 (2-15-07-28) 21 | ++++++++++++++++++ 22 | 23 | * First release on PyPI. 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Daniel Roy Greenfeld 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 dj-spam 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 spam *.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 spam tests 28 | 29 | test: 30 | python runtests.py tests 31 | 32 | test-all: 33 | tox 34 | 35 | coverage: 36 | coverage run --source spam runtests.py tests 37 | coverage report -m 38 | coverage html 39 | open htmlcov/index.html 40 | 41 | docs: 42 | rm -f docs/dj-spam.rst 43 | rm -f docs/modules.rst 44 | sphinx-apidoc -o docs/ spam 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 | Work in Progress: dj-spam 3 | ============================= 4 | 5 | .. image:: https://badge.fury.io/py/dj-spam.png 6 | :target: https://badge.fury.io/py/dj-spam 7 | 8 | .. image:: https://travis-ci.org/pydanny/dj-spam.png?branch=master 9 | :target: https://travis-ci.org/pydanny/dj-spam 10 | 11 | .. image:: https://codecov.io/github/pydanny/dj-spam/coverage.svg?branch=master 12 | :target: https://codecov.io/github/pydanny/dj-spam?branch=master 13 | 14 | Django + Flagging Spam Made Easy 15 | 16 | Documentation 17 | ------------- 18 | 19 | The full documentation is at https://dj-spam.readthedocs.io. 20 | 21 | Features 22 | -------- 23 | 24 | * For Django 1.8+ 25 | * For Python 2.7/3.3+ 26 | * Direct foreign key from the model to the spam report. Avoiding content types and using explicit foreign keys makes for less kludgy databases. 27 | * Powered by conventions used all over Django: 28 | 29 | * Have the appropriate ``__str__()`` or ``__unicode__()`` method on your models. 30 | * Flaggable models should have ``get_absolute_url()`` methods. 31 | 32 | 33 | Quickstart 34 | ---------- 35 | 36 | Install dj-spam:: 37 | 38 | pip install dj-spam 39 | 40 | Configure it into your project:: 41 | 42 | # settings.py 43 | INSTALLED_APPS += ['spam', ] 44 | 45 | :: 46 | 47 | # urls.py 48 | url(r'^spam/', include('spam.urls', namespace='spam')), 49 | 50 | For any model you want to flag:: 51 | 52 | from spam import Spammable 53 | 54 | class MyModel(Spammable, models.Model): 55 | # Define your model here. Spammable attaches 56 | # the spam_flag field to your model as a ManyToManyField. 57 | 58 | @models.permalink 59 | def get_absolute_url(self): 60 | # Not required, but it allows dj-spam to link back to the offending 61 | # content in the report spam view. 62 | return 'absolute link to model detail view' 63 | 64 | Run Migrations 65 | 66 | :: 67 | 68 | ./manage migrate 69 | 70 | Then, in the model's related view:: 71 | 72 | from spam import SpammableMixin 73 | 74 | class MyModelDetailView(SpammableMixin, DetailView): 75 | class = MyModel 76 | 77 | This empowers you with the view method ``spam_report_url`` which you can use to 78 | define the URL to the reporting form:: 79 | 80 | Report Spam 81 | 82 | admin 83 | ------ 84 | 85 | dj-spam comes with a simple admin view. 86 | 87 | emailing managers 88 | ------------------- 89 | 90 | dj-spam emails `settings.MANAGERS` every time something is flagged. If you don't 91 | set `settings.MANAGERS`, it will email `settings.ADMINS`. 92 | 93 | 94 | Running tests locally 95 | --------------------- 96 | 97 | :: 98 | 99 | coverage run ./manage.py test 100 | -------------------------------------------------------------------------------- /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 | __version__ = '0.2.0' 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'dj-spam' 50 | copyright = u'2015, Daniel Roy Greenfeld' 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 = __version__ 58 | # The full version, including alpha/beta/rc tags. 59 | release = __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 = 'dj-spamdoc' 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', 'dj-spam.tex', u'dj-spam Documentation', 196 | u'Daniel Roy Greenfeld', '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', 'dj-spam', u'dj-spam Documentation', 226 | [u'Daniel Roy Greenfeld'], 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', 'dj-spam', u'dj-spam Documentation', 240 | u'Daniel Roy Greenfeld', 'dj-spam', '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 dj-spam'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 dj-spam 8 | 9 | Or, if you have virtualenvwrapper installed:: 10 | 11 | $ mkvirtualenv dj-spam 12 | $ pip install dj-spam 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 dj-spam in a project:: 6 | 7 | import spam 8 | -------------------------------------------------------------------------------- /requirements-test.txt: -------------------------------------------------------------------------------- 1 | django>=1.8.0 2 | coverage 3 | mock>=1.0.1 4 | flake8>=2.1.0 5 | tox>=1.7.0 6 | django-test-plus>=1.0.7 7 | 8 | # Additional test requirements go here 9 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | django>=1.8.0 2 | wheel==0.24.0 3 | # Additional requirements go here 4 | -------------------------------------------------------------------------------- /runtests.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | try: 4 | from django.conf import settings 5 | from django.test.utils import get_runner 6 | 7 | settings.configure( 8 | DEBUG=True, 9 | USE_TZ=True, 10 | DATABASES={ 11 | "default": { 12 | "ENGINE": "django.db.backends.sqlite3", 13 | } 14 | }, 15 | ROOT_URLCONF="test_app.urls", 16 | INSTALLED_APPS=[ 17 | "django.contrib.auth", 18 | "django.contrib.contenttypes", 19 | "django.contrib.sites", 20 | "test_app", 21 | "spam", 22 | ], 23 | SITE_ID=1, 24 | MIDDLEWARE_CLASSES=(), 25 | ) 26 | 27 | try: 28 | import django 29 | setup = django.setup 30 | except AttributeError: 31 | pass 32 | else: 33 | setup() 34 | 35 | except ImportError: 36 | import traceback 37 | traceback.print_exc() 38 | raise ImportError("To fix this error, run: pip install -r requirements-test.txt") 39 | 40 | 41 | def run_tests(*test_args): 42 | if not test_args: 43 | test_args = ['tests'] 44 | 45 | # Run tests 46 | TestRunner = get_runner(settings) 47 | test_runner = TestRunner() 48 | 49 | failures = test_runner.run_tests(test_args) 50 | 51 | if failures: 52 | sys.exit(bool(failures)) 53 | 54 | 55 | if __name__ == '__main__': 56 | run_tests(*sys.argv[1:]) 57 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | try: 8 | from setuptools import setup 9 | except ImportError: 10 | from distutils.core import setup 11 | 12 | version = "0.2.0" 13 | 14 | if sys.argv[-1] == 'publish': 15 | os.system('python setup.py sdist upload') 16 | os.system('python setup.py bdist_wheel upload') 17 | sys.exit() 18 | 19 | if sys.argv[-1] == 'tag': 20 | print("Tagging the version on github:") 21 | os.system("git tag -a %s -m 'version %s'" % (version, version)) 22 | os.system("git push --tags") 23 | sys.exit() 24 | 25 | readme = open('README.rst').read() 26 | history = open('HISTORY.rst').read().replace('.. :changelog:', '') 27 | 28 | setup( 29 | name='dj-spam', 30 | version=version, 31 | description="""Django + Fighting Spam Made Easy""", 32 | long_description=readme + '\n\n' + history, 33 | author='Daniel Roy Greenfeld', 34 | author_email='pydanny@gmail.com', 35 | url='https://github.com/pydanny/dj-spam', 36 | packages=[ 37 | 'spam', 38 | ], 39 | include_package_data=True, 40 | install_requires=[ 41 | 'django>=1.8.0', 42 | 'wheel>=0.24.0' 43 | ], 44 | license="BSD", 45 | zip_safe=False, 46 | keywords='dj-spam', 47 | classifiers=[ 48 | 'Development Status :: 2 - Pre-Alpha', 49 | 'Framework :: Django', 50 | 'Framework :: Django :: 1.8', 51 | 'Intended Audience :: Developers', 52 | 'License :: OSI Approved :: BSD License', 53 | 'Natural Language :: English', 54 | 'Programming Language :: Python :: 2', 55 | 'Programming Language :: Python :: 2.7', 56 | 'Programming Language :: Python :: 3', 57 | 'Programming Language :: Python :: 3.3', 58 | 'Programming Language :: Python :: 3.4', 59 | ], 60 | test_suite='tests', 61 | tests_require=[ 62 | "django>=1.8.0", 63 | "coverage", 64 | "mock>=1.0.1", 65 | "flake8>=2.1.0", 66 | "tox>=1.7.0", 67 | "django-test-plus>=1.0.7" 68 | ] 69 | ) 70 | -------------------------------------------------------------------------------- /spam/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.2.0' 2 | 3 | 4 | from .behaviors import Spammable 5 | from .views import SpammableMixin 6 | -------------------------------------------------------------------------------- /spam/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.utils.safestring import mark_safe 3 | 4 | from .behaviors import Spammable 5 | from .exceptions import SpamNotFound 6 | from .models import SpammyPosting 7 | from .utils import spammables 8 | 9 | 10 | class SpammyPostingAdmin(admin.ModelAdmin): 11 | model = SpammyPosting 12 | readonly_fields = ('source', 'created', 'modified',) 13 | 14 | def source(self, instance): 15 | """This links directly to the location of the offending content.""" 16 | 17 | for spammable in spammables(): 18 | try: 19 | content = spammable.objects.get(spam_flag=instance.pk) 20 | except SpammyPosting.DoesNotExist: 21 | continue 22 | break 23 | else: 24 | raise SpamNotFound(spammable) 25 | 26 | response = """{1}""".format( 27 | content.get_absolute_url(), 28 | content 29 | ) 30 | 31 | return mark_safe(response) 32 | 33 | source.short_description = "Source URL" 34 | source.allow_tags = True 35 | 36 | admin.site.register(SpammyPosting, SpammyPostingAdmin) 37 | -------------------------------------------------------------------------------- /spam/behaviors.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Spammable(models.Model): 5 | 6 | spam_flag = models.ManyToManyField("SpammyPosting") 7 | 8 | class Meta: 9 | abstract = True 10 | -------------------------------------------------------------------------------- /spam/exceptions.py: -------------------------------------------------------------------------------- 1 | class SpamNotFound(Exception): 2 | """When the system can't find spam the user defined""" 3 | 4 | 5 | class B16DecodingFail(Exception): 6 | """When decoding from B16 fails""" 7 | -------------------------------------------------------------------------------- /spam/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | from django.conf import settings 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='SpammyPosting', 17 | fields=[ 18 | ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), 19 | ('created', models.DateTimeField(auto_now_add=True)), 20 | ('modified', models.DateTimeField(auto_now=True)), 21 | ('reporter', models.ForeignKey(blank=True, null=True, to=settings.AUTH_USER_MODEL)), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /spam/migrations/0002_auto_20150728_2050.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | from django.conf import settings 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 12 | ('spam', '0001_initial'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AddField( 17 | model_name='spammyposting', 18 | name='comment', 19 | field=models.TextField(blank=True, null=True), 20 | ), 21 | migrations.AddField( 22 | model_name='spammyposting', 23 | name='reviewer', 24 | field=models.ForeignKey(related_name='reviewer', blank=True, null=True, to=settings.AUTH_USER_MODEL), 25 | ), 26 | migrations.AddField( 27 | model_name='spammyposting', 28 | name='status', 29 | field=models.IntegerField(default=10, choices=[(10, 'Flagged'), (20, 'Under review'), (30, 'Rejected'), (40, 'Approved')]), 30 | ), 31 | migrations.AlterField( 32 | model_name='spammyposting', 33 | name='reporter', 34 | field=models.ForeignKey(related_name='reporter', blank=True, null=True, to=settings.AUTH_USER_MODEL), 35 | ), 36 | ] 37 | -------------------------------------------------------------------------------- /spam/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/spam/migrations/__init__.py -------------------------------------------------------------------------------- /spam/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from django.conf import settings 3 | from django.db import models 4 | from django.utils.translation import ugettext_lazy as _ 5 | 6 | 7 | class SpammyPosting(models.Model): 8 | 9 | FLAGGED = 10 10 | REVIEW = 20 11 | CONTENT_REJECTED = 30 12 | CONTENT_APPROVED = 40 13 | STATUS = ( 14 | (FLAGGED, _('Flagged')), 15 | (REVIEW, _('Under review')), 16 | (CONTENT_REJECTED, _('Rejected')), 17 | (CONTENT_APPROVED, _('Approved')), 18 | ) 19 | 20 | # Reporter, left null/blank in case anonymous users are allowed to submit 21 | reporter = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, related_name='reporter') 22 | status = models.IntegerField(choices=STATUS, default=FLAGGED) 23 | reviewer = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='reviewer') 24 | comment = models.TextField(blank=True, null=True) 25 | created = models.DateTimeField(auto_now_add=True) 26 | modified = models.DateTimeField(auto_now=True) 27 | 28 | class Meta: 29 | app_label = 'spam' 30 | 31 | def __str__(self): 32 | return self.get_status_display() 33 | -------------------------------------------------------------------------------- /spam/static/css/spam.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/spam/static/css/spam.css -------------------------------------------------------------------------------- /spam/static/img/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/spam/static/img/.gitignore -------------------------------------------------------------------------------- /spam/static/js/spam.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/spam/static/js/spam.js -------------------------------------------------------------------------------- /spam/templates/spam/base.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | -------------------------------------------------------------------------------- /spam/templates/spam/spammyposting_form.html: -------------------------------------------------------------------------------- 1 | {% extends "spam/base.html" %} 2 | 3 | {% block content %} 4 |

Reporting Potential Spam

5 | 6 |

7 | Content Type: 8 | {{ model_class.meta.model_name.title }} 9 |

10 |

11 | Content Location: 12 | {{ instance }} 13 |

14 | 15 |
16 | {% csrf_token %} 17 | {{ form.as_p }} 18 | 19 | 20 |
21 | 22 | {% endblock %} 23 | -------------------------------------------------------------------------------- /spam/templates/spam/thanks.html: -------------------------------------------------------------------------------- 1 | {% extends "spam/base.html" %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Thanks for the Report!' %}

6 | 7 |

{% trans "We'll look into this spam report right away." %}

8 | 9 | {% if messages %} 10 |
11 | {% for message in messages %} 12 |

{{ message }}

13 | {% endfor %} 14 |
15 | {% endif %} 16 | 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /spam/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from . import views 3 | 4 | urlpatterns = ( 5 | url( 6 | regex=r'^$', 7 | view=views.ThankYouView.as_view(), 8 | name='thanks' 9 | ), 10 | url( 11 | r'^report/(?P\w+)/$', 12 | view=views.ReportSpamCreateView.as_view(), 13 | name='report' 14 | ), 15 | ) 16 | -------------------------------------------------------------------------------- /spam/utils.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from binascii import Error as BinaryError 4 | from base64 import b16encode, b16decode 5 | 6 | from django.apps import apps 7 | from django.core.exceptions import FieldDoesNotExist 8 | from django.http import Http404 9 | from django.shortcuts import get_object_or_404 10 | 11 | from .exceptions import B16DecodingFail 12 | 13 | 14 | def spammables(): 15 | # Lists all models that are marked flaggable 16 | flaggables = [] 17 | for model in apps.get_models(): 18 | try: 19 | model._meta.get_field_by_name('spam_flag') 20 | except FieldDoesNotExist: 21 | continue 22 | flaggables.append(model) 23 | return flaggables 24 | 25 | 26 | def is_spammable(app, model): 27 | model_class = apps.get_model("{}.{}".format(app, model)) 28 | return model_class in spammables() 29 | 30 | 31 | def get_app_name(model_class_or_instance): 32 | return model_class_or_instance._meta.app_config.name.split('.')[-1] 33 | 34 | 35 | def b16_slug_to_arguments(b16_slug): 36 | """ 37 | 38 | Raises B16DecodingFail exception on 39 | """ 40 | try: 41 | url = b16decode(b16_slug.decode('utf-8')) 42 | except BinaryError: 43 | raise B16DecodingFail 44 | except TypeError: 45 | raise B16DecodingFail('Non-base16 digit found') 46 | except AttributeError: 47 | raise B16DecodingFail("b16_slug must have a 'decode' method.") 48 | 49 | try: 50 | app, model, pk = url.decode('utf-8').split('/')[0:3] 51 | except UnicodeDecodeError: 52 | raise B16DecodingFail("Invalid b16_slug passed") 53 | return app, model, pk 54 | 55 | 56 | def get_spammable_or_404(app, model, pk): 57 | # Does this view have the is_spammable mixin? 58 | if is_spammable(app, model): 59 | # convert app/model into the actual model class 60 | model_class = apps.get_model(app, model) 61 | # So we can call meta for details in the template 62 | model_class.meta = model_class._meta 63 | instance = get_object_or_404(model_class, pk=pk) 64 | return model_class, instance 65 | raise Http404 66 | -------------------------------------------------------------------------------- /spam/views.py: -------------------------------------------------------------------------------- 1 | from binascii import Error as BinaryError 2 | from base64 import b16encode 3 | 4 | from django.apps import apps 5 | from django.conf import settings 6 | from django.core.mail import mail_managers 7 | from django.core.urlresolvers import reverse_lazy 8 | from django.http import Http404 9 | from django.shortcuts import get_object_or_404 10 | from django.db import transaction 11 | from django.views.generic import ( 12 | CreateView, 13 | TemplateView, 14 | ) 15 | 16 | from .exceptions import B16DecodingFail 17 | from .models import SpammyPosting 18 | from .utils import ( 19 | spammables, 20 | is_spammable, 21 | get_app_name, 22 | b16_slug_to_arguments, 23 | get_spammable_or_404 24 | ) 25 | 26 | # MANAGERS is a list of tuples following the same pattern as settings.ADMINS 27 | MANAGERS = getattr(settings, "MANAGERS", settings.ADMINS) 28 | 29 | 30 | class ReportSpamCreateView(CreateView): 31 | """ 32 | Requires 'model' as an argument 33 | """ 34 | model = SpammyPosting 35 | fields = ['comment',] 36 | success_url = reverse_lazy('spam:thanks') 37 | 38 | def b16_slug_to_arguments(self): 39 | """Returns app, model, pk""" 40 | try: 41 | return b16_slug_to_arguments(self.kwargs['slug']) 42 | except B16DecodingFail: 43 | raise Http404 44 | 45 | def get_context_data(self, **kwargs): 46 | context = super(ReportSpamCreateView, self).get_context_data(**kwargs) 47 | app, model, pk = self.b16_slug_to_arguments() 48 | model_class, instance = get_spammable_or_404(app, model, pk) 49 | context['model_class'] = model_class 50 | context['instance'] = instance 51 | return context 52 | 53 | def form_valid(self, form): 54 | app, model, pk = self.b16_slug_to_arguments() 55 | model_class, instance = get_spammable_or_404(app, model, pk) 56 | with transaction.atomic(): 57 | spam = form.save(commit=False) 58 | spam.reporter = self.request.user 59 | spam.save() 60 | # Add the spam to the flagged instance of content 61 | instance.spam_flag.add(spam) 62 | mail_managers( 63 | # TODO: Ability to specify site name 64 | "Spam flagged on your site", 65 | # TODO: Put this in a template so it can be easily customized 66 | "Content was flagged as being spammy. You should go and check it out." 67 | ) 68 | return super(ReportSpamCreateView, self).form_valid(form) 69 | 70 | 71 | class ThankYouView(TemplateView): 72 | template_name = "spam/thanks.html" 73 | 74 | 75 | class SpammableMixin(object): 76 | def spam_report_url(self): 77 | slug = "{app}/{model}/{pk}/".format( 78 | app = get_app_name(self.object), 79 | model = self.object._meta.object_name, 80 | pk = self.object.title 81 | ) 82 | # We're just hashing so users won't readily get a sense of how we 83 | # architected our project 84 | b16_slug = b16encode(slug.encode('utf-8')) 85 | return reverse_lazy('spam:report', kwargs={'b16_slug': b16_slug}) 86 | -------------------------------------------------------------------------------- /test_app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/test_app/__init__.py -------------------------------------------------------------------------------- /test_app/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | from django.conf import settings 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | operations = [ 11 | migrations.CreateModel( 12 | name='Data', 13 | fields=[ 14 | ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), 15 | ('title', models.CharField(max_length=50)), 16 | ('SpammyPosting', models.ManyToManyField(to="spam.SpammyPosting")), 17 | ], 18 | options={}, 19 | bases=(models.Model,), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /test_app/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/test_app/migrations/__init__.py -------------------------------------------------------------------------------- /test_app/models.py: -------------------------------------------------------------------------------- 1 | from django.core.urlresolvers import reverse_lazy 2 | from django.db import models 3 | 4 | from spam import Spammable 5 | 6 | 7 | class Data(Spammable, models.Model): 8 | 9 | title = models.CharField(max_length=50) 10 | 11 | def get_absolute_url(self): 12 | # Not required, but it allows dj-spam to link back to the offending 13 | # content in the report spam view. 14 | return reverse_lazy('data', kwargs={'pk': self.pk}) 15 | -------------------------------------------------------------------------------- /test_app/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url, include 2 | 3 | from test_app.views import DataDetailView 4 | 5 | urlpatterns = [ 6 | url(r'^spam/', include('spam.urls', namespace='spam')), 7 | url( 8 | regex="^(?P\d+)/$", 9 | view=DataDetailView.as_view(), 10 | name="data", 11 | ), 12 | 13 | ] 14 | -------------------------------------------------------------------------------- /test_app/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponse 2 | from django.shortcuts import get_object_or_404 3 | from django.views.generic import View 4 | 5 | from spam import SpammableMixin 6 | 7 | from .models import Data 8 | 9 | 10 | class DataDetailView(SpammableMixin, View): 11 | 12 | @property 13 | def object(self): 14 | return get_object_or_404(Data, pk=self.kwargs['pk']) 15 | 16 | def get(self, request, *args, **kwargs): 17 | return HttpResponse() 18 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pydanny/dj-spam/924dbe794f7b421015445964c38b65d3e48990db/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | test_dj-spam 6 | ------------ 7 | 8 | Tests for `dj-spam` models module. 9 | """ 10 | 11 | import os 12 | import shutil 13 | from test_plus.test import TestCase 14 | 15 | from django.conf import settings 16 | 17 | from spam.models import SpammyPosting 18 | 19 | 20 | class TestSpammyPosting(TestCase): 21 | """ Tests for SpammyPosting model. """ 22 | 23 | def setUp(self): 24 | self.user = self.make_user() 25 | self.spammy_posting = SpammyPosting.objects.create( 26 | reporter=self.user, 27 | status=SpammyPosting.FLAGGED, 28 | reviewer=self.user, 29 | comment="Includes too many links" 30 | ) 31 | 32 | def test_str(self): 33 | """ Test the `__str__()` method of SpammyPosting """ 34 | self.assertEqual(self.spammy_posting.__str__(), "Flagged") 35 | -------------------------------------------------------------------------------- /tests/test_utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | test_dj-spam 6 | ------------ 7 | 8 | Tests for `dj-spam` utils module. 9 | """ 10 | from base64 import b16encode 11 | 12 | from django.contrib.auth import get_user_model 13 | from django.test import TestCase 14 | 15 | from spam.exceptions import B16DecodingFail 16 | from spam.utils import ( 17 | get_app_name, 18 | b16_slug_to_arguments, 19 | get_spammable_or_404 20 | ) 21 | 22 | from test_app.models import Data 23 | 24 | User = get_user_model() 25 | 26 | 27 | class TestGetAppName(TestCase): 28 | """ Tests the `get_app_name()` utility. """ 29 | 30 | def test_model_class(self): 31 | """ Tests `get_app_name()` with a model class as the argument. """ 32 | app_name = get_app_name(User) 33 | self.assertEqual( 34 | app_name, 35 | 'auth' # django.contrib.auth 36 | ) 37 | 38 | def test_instance(self): 39 | """ Tests `get_app_name()` with a model instance as the argument. """ 40 | user = User.objects.create( 41 | username='test', 42 | email='test@example.com', 43 | password='!' 44 | ) 45 | app_name = get_app_name(user) 46 | self.assertEqual( 47 | app_name, 48 | 'auth' # django.contrib.auth 49 | ) 50 | 51 | 52 | class TestB16SlugToArguments(TestCase): 53 | 54 | def setUp(self): 55 | self.slug = b16encode('myapp/myproject/35'.encode('utf-8')) 56 | self.bad_slug = 'ABCDEF'.encode('utf-8') 57 | self.bad_slug_type = 'IAMSPAM' 58 | 59 | def test_b16_slug_to_arguments(self): 60 | self.assertEqual( 61 | ('myapp', 'myproject', '35'), 62 | b16_slug_to_arguments(self.slug) 63 | ) 64 | 65 | def test_bad_slug(self): 66 | with self.assertRaises(B16DecodingFail): 67 | b16_slug_to_arguments(self.bad_slug) 68 | 69 | def test_bad_slug_type(self): 70 | with self.assertRaises(B16DecodingFail): 71 | b16_slug_to_arguments(self.bad_slug_type) 72 | 73 | 74 | class TestGetSpammableOr404(TestCase): 75 | 76 | def setUp(self): 77 | self.data = Data.objects.create(title='test') 78 | 79 | def test_get_spammable(self): 80 | model_class, instance = get_spammable_or_404( 81 | 'test_app', 82 | 'Data', 83 | self.data.pk 84 | ) 85 | self.assertEqual(model_class, Data) 86 | self.assertIsInstance(instance, Data) 87 | -------------------------------------------------------------------------------- /tests/test_views.py: -------------------------------------------------------------------------------- 1 | from base64 import b16encode, b16decode 2 | 3 | from django.core.urlresolvers import reverse 4 | from django.http import HttpResponseNotAllowed 5 | from django.test import RequestFactory 6 | 7 | from spam.views import ReportSpamCreateView 8 | from test_plus.test import TestCase 9 | 10 | from test_app.models import Data 11 | from test_app.views import DataDetailView 12 | 13 | 14 | class TestReportSpamCreateView(TestCase): 15 | 16 | def setUp(self): 17 | self.data = Data.objects.create(title='test') 18 | self.factory = RequestFactory() 19 | 20 | def test_data_detail_view(self): 21 | """ Just to make certain we have the tests wired up right""" 22 | # Get the URL 23 | # Create a request 24 | request = self.factory.get('/fake-url') 25 | # Generate a response 26 | response = DataDetailView.as_view()(request, pk=self.data.pk) 27 | 28 | # Check to see if we had a 404 or not 29 | self.response_200(response) 30 | 31 | def test_slug_to_arguments(self): 32 | base_url = "test_app/data/{0}/".format(self.data.pk) 33 | b16_slug = b16encode(base_url.encode('utf-8')) 34 | 35 | request = self.factory.get('/fake-url') 36 | 37 | view = ReportSpamCreateView.as_view() 38 | response = view(request, slug=b16_slug) 39 | self.response_200(response) 40 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py27, py33, py34, py35 3 | 4 | [testenv] 5 | setenv = 6 | PYTHONPATH = {toxinidir}:{toxinidir}/spam 7 | commands = python runtests.py 8 | deps = 9 | -r{toxinidir}/requirements-test.txt 10 | --------------------------------------------------------------------------------