[
  {
    "path": ".coveragerc",
    "content": "[run]\nomit =\n    */migrations/*\n    */compat.py\n    */__init__.py\n    */test_*\n\n[report]\nexclude_lines =\n    def __repr__\n    def __str__\n    def parse_args\n    pragma: no cover\n    raise NotImplementedError\n    if __name__ == .__main__.:"
  },
  {
    "path": ".gitignore",
    "content": "*.py[cod]\n\n# C extensions\n*.so\n\n# Packages\n*.egg\n*.egg-info\ndist\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\nlib\nlib64\n\n# Installer logs\npip-log.txt\n\n# Unit test / coverage reports\n.coverage\n.tox\nnosetests.xml\n\n# Translations\n*.mo\n\n# Mr Developer\n.mr.developer.cfg\n.project\n.pydevproject\n\n# Complexity\noutput/*.html\noutput/*/index.html\n\n# Sphinx\ndocs/_build\n\n#pycharm\n.idea/\n\n#coverage\nhtmlcov\n"
  },
  {
    "path": ".travis.yml",
    "content": "# Config file for automatic testing at travis-ci.org\n\nlanguage: python\n\npython:\n  - \"3.5\"\n  - \"3.4\"\n  - \"2.7\"\nenv:\n    - DJANGO=\"Django==1.11.2\"\n\n# command to install dependencies, e.g. pip install -r requirements.txt\ninstall:\n - pip install $DJANGO\n - pip install -r requirements-test.txt\n\n# command to run tests using coverage, e.g. python setup.py test\nscript: coverage run --source users runtests.py\n\n# report coverage to coveralls.io\nafter_success: coveralls\n"
  },
  {
    "path": "AUTHORS.rst",
    "content": "=======\nCredits\n=======\n\nDevelopment Lead\n----------------\n\n* Mishbah Razzaque (mishbahr) <mishbahx@gmail.com>\n\nContributors\n------------\n\n* John Matthew (jfmatth) <john@compunique.com>\n* moemen <moemenology@gmail.com>\n* Alwerdani <alwerdani@gmail.com>\n* Weizhong Tu (twz915) <tuweizhong@163.com>\n* Ahmed Maher (mxahmed) <ahmedmaherelmitwally@gmail.com>"
  },
  {
    "path": "CONTRIBUTING.rst",
    "content": "============\nContributing\n============\n\nContributions are welcome, and they are greatly appreciated! Every\nlittle bit helps, and credit will always be given. \n\nYou can contribute in many ways:\n\nTypes of Contributions\n----------------------\n\nReport Bugs\n~~~~~~~~~~~\n\nReport bugs at https://github.com/mishbahr/django-users2/issues.\n\nIf you are reporting a bug, please include:\n\n* Your operating system name and version.\n* Any details about your local setup that might be helpful in troubleshooting.\n* Detailed steps to reproduce the bug.\n\nFix Bugs\n~~~~~~~~\n\nLook through the GitHub issues for bugs. Anything tagged with \"bug\"\nis open to whoever wants to implement it.\n\nImplement Features\n~~~~~~~~~~~~~~~~~~\n\nLook through the GitHub issues for features. Anything tagged with \"feature\"\nis open to whoever wants to implement it.\n\nWrite Documentation\n~~~~~~~~~~~~~~~~~~~\n\ndjango-users2 could always use more documentation, whether as part of the \nofficial django-users2 docs, in docstrings, or even on the web in blog posts,\narticles, and such.\n\nSubmit Feedback\n~~~~~~~~~~~~~~~\n\nThe best way to send feedback is to file an issue at https://github.com/mishbahr/django-users2/issues.\n\nIf you are proposing a feature:\n\n* Explain in detail how it would work.\n* Keep the scope as narrow as possible, to make it easier to implement.\n* Remember that this is a volunteer-driven project, and that contributions\n  are welcome :)\n\nGet Started!\n------------\n\nReady to contribute? Here's how to set up `django-users2` for local development.\n\n1. Fork the `django-users2` repo on GitHub.\n2. Clone your fork locally::\n\n    $ git clone git@github.com:your_name_here/django-users2.git\n\n3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::\n\n    $ mkvirtualenv django-users2\n    $ cd django-users2/\n    $ python setup.py develop\n\n4. Create a branch for local development::\n\n    $ git checkout -b name-of-your-bugfix-or-feature\n\nNow you can make your changes locally.\n\n5. When you're done making changes, check that your changes pass flake8 and the\ntests, including testing other Python versions with tox::\n\n    $ flake8 users tests\n    $ python setup.py test\n    $ tox\n\nTo get flake8 and tox, just pip install them into your virtualenv. \n\n6. Commit your changes and push your branch to GitHub::\n\n    $ git add .\n    $ git commit -m \"Your detailed description of your changes.\"\n    $ git push origin name-of-your-bugfix-or-feature\n\n7. Submit a pull request through the GitHub website.\n\nPull Request Guidelines\n-----------------------\n\nBefore you submit a pull request, check that it meets these guidelines:\n\n1. The pull request should include tests.\n2. If the pull request adds functionality, the docs should be updated. Put\n   your new functionality into a function with a docstring, and add the\n   feature to the list in README.rst.\n3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check \n   https://travis-ci.org/mishbahr/django-users2/pull_requests\n   and make sure that the tests pass for all supported Python versions.\n\nTips\n----\n\nTo run a subset of tests::\n\n    $ python -m unittest tests.test_users"
  },
  {
    "path": "HISTORY.rst",
    "content": ".. :changelog:\n\nHistory\n-------\n\n0.1.0 (2014-09-25)\n++++++++++++++++++\n\n* First release on PyPI.\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2014, Mishbah Razzaque\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* 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.\n\n* Neither the name of django-users2 nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS 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."
  },
  {
    "path": "MANIFEST.in",
    "content": "include AUTHORS.rst\ninclude CONTRIBUTING.rst\ninclude HISTORY.rst\ninclude LICENSE\ninclude README.rst\nrecursive-include users *.html *.png *.gif *js *.css *jpg *jpeg *svg *py"
  },
  {
    "path": "Makefile",
    "content": ".PHONY: clean-pyc clean-build docs\n\nhelp:\n\t@echo \"clean-build - remove build artifacts\"\n\t@echo \"clean-pyc - remove Python file artifacts\"\n\t@echo \"lint - check style with flake8\"\n\t@echo \"test - run tests quickly with the default Python\"\n\t@echo \"testall - run tests on every Python version with tox\"\n\t@echo \"coverage - check code coverage quickly with the default Python\"\n\t@echo \"docs - generate Sphinx HTML documentation, including API docs\"\n\t@echo \"release - package and upload a release\"\n\t@echo \"sdist - package\"\n\nclean: clean-build clean-pyc\n\nclean-build:\n\trm -fr build/\n\trm -fr dist/\n\trm -fr *.egg-info\n\nclean-pyc:\n\tfind . -name '*.pyc' -exec rm -f {} +\n\tfind . -name '*.pyo' -exec rm -f {} +\n\tfind . -name '*~' -exec rm -f {} +\n\nlint:\n\tflake8 django-users2 tests\n\ntest:\n\tpython runtests.py test\n\ntest-all:\n\ttox\n\ncoverage:\n\tcoverage run --source django-users2 setup.py test\n\tcoverage report -m\n\tcoverage html\n\topen htmlcov/index.html\n\ndocs:\n\trm -f docs/django-users2.rst\n\trm -f docs/modules.rst\n\tsphinx-apidoc -o docs/ django-users2\n\t$(MAKE) -C docs clean\n\t$(MAKE) -C docs html\n\topen docs/_build/html/index.html\n\nrelease: clean\n\tpython setup.py sdist upload\n\tpython setup.py bdist_wheel upload\n\nsdist: clean\n\tpython setup.py sdist\n\tls -l dist"
  },
  {
    "path": "README.rst",
    "content": "=============================\ndjango-users2\n=============================\n\n.. image:: http://img.shields.io/travis/mishbahr/django-users2.svg?style=flat-square\n    :target: https://travis-ci.org/mishbahr/django-users2/\n\n.. image:: http://img.shields.io/pypi/v/django-users2.svg?style=flat-square\n    :target: https://pypi.python.org/pypi/django-users2/\n    :alt: Latest Version\n\n.. image:: http://img.shields.io/pypi/dm/django-users2.svg?style=flat-square\n    :target: https://pypi.python.org/pypi/django-users2/\n    :alt: Downloads\n\n.. image:: http://img.shields.io/pypi/l/django-users2.svg?style=flat-square\n    :target: https://pypi.python.org/pypi/django-users2/\n    :alt: License\n\n.. image:: http://img.shields.io/coveralls/mishbahr/django-users2.svg?style=flat-square\n  :target: https://coveralls.io/r/mishbahr/django-users2?branch=master\n\n\nCustom user model for django >=1.5 with support for multiple user types and\nlots of other awesome utils (mostly borrowed from other projects). If you are\nusing django < 1.11, please install v0.2.1 or earlier (`pip install\ndjango-users2<=0.2.1`).\n\nFeatures\n--------\n\n* email as username for authentication (barebone extendable user models)\n* support for multiple user types (using the awesome django-model-utils)\n* automatically creates superuser after syncdb/migrations (really handy during the initial development phases)\n* built in emails/passwords validators (with lots of customisable options)\n* prepackaged with all the templates, including additional templates required by views in ``django.contrib.auth`` (for a painless signup process)\n\n\nDocumentation\n-------------\n\nThe full documentation is at https://django-users2.readthedocs.org.\n\nQuickstart\n----------\n\n1. Install `django-users2`::\n\n    pip install django-users2\n\n2. Add `django-users2` to `INSTALLED_APPS`::\n\n    INSTALLED_APPS = (\n        ...\n        'django.contrib.auth',\n    \t'django.contrib.sites',\n        'users',\n        ...\n    )\n\n3. Set your `AUTH_USER_MODEL` setting to use ``users.User``::\n\n    AUTH_USER_MODEL = 'users.User'\n\n4. Once you’ve done this, run the ``migrate`` command to install the model used by this package::\n\n    python manage.py migrate\n\n5. Add the `django-users2` URLs to your project’s URLconf as follows::\n\n    urlpatterns = patterns('',\n        ...\n        url(r'^accounts/', include('users.urls')),\n        ...\n    )\n\nwhich sets up URL patterns for the views in django-users2 as well as several useful views in django.contrib.auth (e.g. login, logout, password change/reset)\n\n\nConfiguration\n-----------------------\nSet ``USERS_VERIFY_EMAIL = True`` to enable email verification for registered users. \n\nWhen a new ``User`` object is created, with its ``is_active`` field set to ``False``, an activation key is generated, and an email is sent to the user containing a link to click to activate the account::\n\n    USERS_VERIFY_EMAIL = False\n\nUpon clicking the activation link, the new account is made active (i.e. ``is_active`` field is set to ``True``); after this, the user can log in. Optionally, you can automatically login the user after successful activation::\n    \n    USERS_AUTO_LOGIN_ON_ACTIVATION = True\n\nThis is the number of days the users will have, to activate their accounts after registering:: \n\n   USERS_EMAIL_CONFIRMATION_TIMEOUT_DAYS = 3\n\nAutomatically create django ``superuser`` after ``syncdb``, by default this option is enabled when ``settings.DEBUG = True``. \n\nYou can customise the email/password by overriding ``USERS_SUPERUSER_EMAIL`` and ``USERS_SUPERUSER_PASSWORD`` settings (highly recommended)::\n\n    USERS_CREATE_SUPERUSER = settings.DEBUG\n    USERS_SUPERUSER_EMAIL = 'superuser@djangoproject.com'\n    USERS_SUPERUSER_PASSWORD = 'django'  \n\nPrevent automated registration by spambots, by enabling a hidden (using css) honeypot field::\n\n    USERS_SPAM_PROTECTION = True\n\nPrevent user registrations by setting ``USERS_REGISTRATION_OPEN = False``::\n\n\tUSERS_REGISTRATION_OPEN = True\n\n\nSettings for validators, that check the strength of user specified passwords::\n    \n    # Specifies minimum length for passwords:\n    USERS_PASSWORD_MIN_LENGTH = 5\n\n    #Specifies maximum length for passwords:\n    USERS_PASSWORD_MAX_LENGTH = None\n\t\nOptionally, the complexity validator, checks the password strength::\n\n\tUSERS_CHECK_PASSWORD_COMPLEXITY = True\n\nSpecify number of characters within various sets that a password must contain::\n\n\tUSERS_PASSWORD_POLICY = {\n\t\t'UPPER': 0,       # Uppercase 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\t\t'LOWER': 0,       # Lowercase 'abcdefghijklmnopqrstuvwxyz'\n\t\t'DIGITS': 0,      # Digits '0123456789'\n\t\t'PUNCTUATION': 0  # Punctuation \"\"\"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\"\"\"\n\t}\n\nAllow/disallow registration using emails addresses from specific domains::\n \n    USERS_VALIDATE_EMAIL_DOMAIN = True\n\nList of disallowed domains::\n\n    USERS_EMAIL_DOMAINS_BLACKLIST = []\n\nFor example, ``USERS_EMAIL_DOMAINS_BLACKLIST = ['mailinator.com']`` will block all visitors from using mailinator.com email addresses to register.\n    \nList of allowed domains::\n\n    USERS_EMAIL_DOMAINS_WHITELIST = []\n\nFor example, ``USERS_EMAIL_DOMAINS_WHITELIST = ['ljworld.com']`` will only allow user registration with ljworld.com domains.\n"
  },
  {
    "path": "docs/Makefile",
    "content": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS    =\nSPHINXBUILD   = sphinx-build\nPAPER         =\nBUILDDIR      = _build\n\n# User-friendly check for sphinx-build\nifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)\n$(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/)\nendif\n\n# Internal variables.\nPAPEROPT_a4     = -D latex_paper_size=a4\nPAPEROPT_letter = -D latex_paper_size=letter\nALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .\n# the i18n builder cannot share the environment and doctrees with the others\nI18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .\n\n.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext\n\nhelp:\n\t@echo \"Please use \\`make <target>' where <target> is one of\"\n\t@echo \"  html       to make standalone HTML files\"\n\t@echo \"  dirhtml    to make HTML files named index.html in directories\"\n\t@echo \"  singlehtml to make a single large HTML file\"\n\t@echo \"  pickle     to make pickle files\"\n\t@echo \"  json       to make JSON files\"\n\t@echo \"  htmlhelp   to make HTML files and a HTML help project\"\n\t@echo \"  qthelp     to make HTML files and a qthelp project\"\n\t@echo \"  devhelp    to make HTML files and a Devhelp project\"\n\t@echo \"  epub       to make an epub\"\n\t@echo \"  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\"\n\t@echo \"  latexpdf   to make LaTeX files and run them through pdflatex\"\n\t@echo \"  latexpdfja to make LaTeX files and run them through platex/dvipdfmx\"\n\t@echo \"  text       to make text files\"\n\t@echo \"  man        to make manual pages\"\n\t@echo \"  texinfo    to make Texinfo files\"\n\t@echo \"  info       to make Texinfo files and run them through makeinfo\"\n\t@echo \"  gettext    to make PO message catalogs\"\n\t@echo \"  changes    to make an overview of all changed/added/deprecated items\"\n\t@echo \"  xml        to make Docutils-native XML files\"\n\t@echo \"  pseudoxml  to make pseudoxml-XML files for display purposes\"\n\t@echo \"  linkcheck  to check all external links for integrity\"\n\t@echo \"  doctest    to run all doctests embedded in the documentation (if enabled)\"\n\nclean:\n\trm -rf $(BUILDDIR)/*\n\nhtml:\n\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/html.\"\n\ndirhtml:\n\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/dirhtml.\"\n\nsinglehtml:\n\t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml\n\t@echo\n\t@echo \"Build finished. The HTML page is in $(BUILDDIR)/singlehtml.\"\n\npickle:\n\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle\n\t@echo\n\t@echo \"Build finished; now you can process the pickle files.\"\n\njson:\n\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json\n\t@echo\n\t@echo \"Build finished; now you can process the JSON files.\"\n\nhtmlhelp:\n\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp\n\t@echo\n\t@echo \"Build finished; now you can run HTML Help Workshop with the\" \\\n\t      \".hhp project file in $(BUILDDIR)/htmlhelp.\"\n\nqthelp:\n\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp\n\t@echo\n\t@echo \"Build finished; now you can run \"qcollectiongenerator\" with the\" \\\n\t      \".qhcp project file in $(BUILDDIR)/qthelp, like this:\"\n\t@echo \"# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp\"\n\t@echo \"To view the help file:\"\n\t@echo \"# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc\"\n\ndevhelp:\n\t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp\n\t@echo\n\t@echo \"Build finished.\"\n\t@echo \"To view the help file:\"\n\t@echo \"# mkdir -p $$HOME/.local/share/devhelp/complexity\"\n\t@echo \"# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity\"\n\t@echo \"# devhelp\"\n\nepub:\n\t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub\n\t@echo\n\t@echo \"Build finished. The epub file is in $(BUILDDIR)/epub.\"\n\nlatex:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo\n\t@echo \"Build finished; the LaTeX files are in $(BUILDDIR)/latex.\"\n\t@echo \"Run \\`make' in that directory to run these through (pdf)latex\" \\\n\t      \"(use \\`make latexpdf' here to do that automatically).\"\n\nlatexpdf:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo \"Running LaTeX files through pdflatex...\"\n\t$(MAKE) -C $(BUILDDIR)/latex all-pdf\n\t@echo \"pdflatex finished; the PDF files are in $(BUILDDIR)/latex.\"\n\nlatexpdfja:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo \"Running LaTeX files through platex and dvipdfmx...\"\n\t$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja\n\t@echo \"pdflatex finished; the PDF files are in $(BUILDDIR)/latex.\"\n\ntext:\n\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text\n\t@echo\n\t@echo \"Build finished. The text files are in $(BUILDDIR)/text.\"\n\nman:\n\t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man\n\t@echo\n\t@echo \"Build finished. The manual pages are in $(BUILDDIR)/man.\"\n\ntexinfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo\n\t@echo \"Build finished. The Texinfo files are in $(BUILDDIR)/texinfo.\"\n\t@echo \"Run \\`make' in that directory to run these through makeinfo\" \\\n\t      \"(use \\`make info' here to do that automatically).\"\n\ninfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo \"Running Texinfo files through makeinfo...\"\n\tmake -C $(BUILDDIR)/texinfo info\n\t@echo \"makeinfo finished; the Info files are in $(BUILDDIR)/texinfo.\"\n\ngettext:\n\t$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale\n\t@echo\n\t@echo \"Build finished. The message catalogs are in $(BUILDDIR)/locale.\"\n\nchanges:\n\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes\n\t@echo\n\t@echo \"The overview file is in $(BUILDDIR)/changes.\"\n\nlinkcheck:\n\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck\n\t@echo\n\t@echo \"Link check complete; look for any errors in the above output \" \\\n\t      \"or in $(BUILDDIR)/linkcheck/output.txt.\"\n\ndoctest:\n\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest\n\t@echo \"Testing of doctests in the sources finished, look at the \" \\\n\t      \"results in $(BUILDDIR)/doctest/output.txt.\"\n\nxml:\n\t$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml\n\t@echo\n\t@echo \"Build finished. The XML files are in $(BUILDDIR)/xml.\"\n\npseudoxml:\n\t$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml\n\t@echo\n\t@echo \"Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml.\""
  },
  {
    "path": "docs/authors.rst",
    "content": ".. include:: ../AUTHORS.rst"
  },
  {
    "path": "docs/conf.py",
    "content": "# -*- coding: utf-8 -*-\n#\n# complexity documentation build configuration file, created by\n# sphinx-quickstart on Tue Jul  9 22:26:36 2013.\n#\n# This file is execfile()d with the current directory set to its containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\nimport sys, os\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#sys.path.insert(0, os.path.abspath('.'))\n\ncwd = os.getcwd()\nparent = os.path.dirname(cwd)\nsys.path.append(parent)\n\nimport users\n\n# -- General configuration -----------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be extensions\n# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.\nextensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix of source filenames.\nsource_suffix = '.rst'\n\n# The encoding of source files.\n#source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = u'django-users2'\ncopyright = u'2014, Mishbah Razzaque'\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = users.__version__\n# The full version, including alpha/beta/rc tags.\nrelease = users.__version__\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#language = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n#today = ''\n# Else, today_fmt is used as the format for a strftime call.\n#today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\nexclude_patterns = ['_build']\n\n# The reST default role (used for this markup: `text`) to use for all documents.\n#default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n#add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n#add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n#show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# A list of ignored prefixes for module index sorting.\n#modindex_common_prefix = []\n\n# If true, keep warnings as \"system message\" paragraphs in the built documents.\n#keep_warnings = False\n\n\n# -- Options for HTML output ---------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\nhtml_theme = 'default'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further.  For a list of options available for each theme, see the\n# documentation.\n#html_theme_options = {}\n\n# Add any paths that contain custom themes here, relative to this directory.\n#html_theme_path = []\n\n# The name for this set of Sphinx documents.  If None, it defaults to\n# \"<project> v<release> documentation\".\n#html_title = None\n\n# A shorter title for the navigation bar.  Default is the same as html_title.\n#html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n#html_logo = None\n\n# The name of an image file (within the static path) to use as favicon of the\n# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n#html_favicon = None\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = ['_static']\n\n# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,\n# using the given strftime format.\n#html_last_updated_fmt = '%b %d, %Y'\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n#html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n#html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n#html_additional_pages = {}\n\n# If false, no module index is generated.\n#html_domain_indices = True\n\n# If false, no index is generated.\n#html_use_index = True\n\n# If true, the index is split into individual pages for each letter.\n#html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n#html_show_sourcelink = True\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n#html_show_sphinx = True\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n#html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it.  The value of this option must be the\n# base URL from which the finished HTML is served.\n#html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n#html_file_suffix = None\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'django-users2doc'\n\n\n# -- Options for LaTeX output --------------------------------------------------\n\nlatex_elements = {\n# The paper size ('letterpaper' or 'a4paper').\n#'papersize': 'letterpaper',\n\n# The font size ('10pt', '11pt' or '12pt').\n#'pointsize': '10pt',\n\n# Additional stuff for the LaTeX preamble.\n#'preamble': '',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title, author, documentclass [howto/manual]).\nlatex_documents = [\n  ('index', 'django-users2.tex', u'django-users2 Documentation',\n   u'Mishbah Razzaque', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n#latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n#latex_use_parts = False\n\n# If true, show page references after internal links.\n#latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n#latex_show_urls = False\n\n# Documents to append as an appendix to all manuals.\n#latex_appendices = []\n\n# If false, no module index is generated.\n#latex_domain_indices = True\n\n\n# -- Options for manual page output --------------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n    ('index', 'django-users2', u'django-users2 Documentation',\n     [u'Mishbah Razzaque'], 1)\n]\n\n# If true, show URL addresses after external links.\n#man_show_urls = False\n\n\n# -- Options for Texinfo output ------------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n  ('index', 'django-users2', u'django-users2 Documentation',\n   u'Mishbah Razzaque', 'django-users2', 'One line description of project.',\n   'Miscellaneous'),\n]\n\n# Documents to append as an appendix to all manuals.\n#texinfo_appendices = []\n\n# If false, no module index is generated.\n#texinfo_domain_indices = True\n\n# How to display URL addresses: 'footnote', 'no', or 'inline'.\n#texinfo_show_urls = 'footnote'\n\n# If true, do not generate a @detailmenu in the \"Top\" node's menu.\n#texinfo_no_detailmenu = False"
  },
  {
    "path": "docs/contributing.rst",
    "content": ".. include:: ../CONTRIBUTING.rst"
  },
  {
    "path": "docs/history.rst",
    "content": ".. include:: ../HISTORY.rst"
  },
  {
    "path": "docs/index.rst",
    "content": ".. complexity documentation master file, created by\n   sphinx-quickstart on Tue Jul  9 22:26:36 2013.\n   You can adapt this file completely to your liking, but it should at least\n   contain the root `toctree` directive.\n\nWelcome to django-users2's documentation!\n=================================================================\n\nContents:\n\n.. toctree::\n   :maxdepth: 2\n\n   readme\n   installation\n   usage\n   contributing\n   authors\n   history"
  },
  {
    "path": "docs/installation.rst",
    "content": "============\nInstallation\n============\n\nAt the command line::\n\n    $ easy_install django-users2\n\nOr, if you have virtualenvwrapper installed::\n\n    $ mkvirtualenv django-users2\n    $ pip install django-users2"
  },
  {
    "path": "docs/make.bat",
    "content": "@ECHO OFF\n\nREM Command file for Sphinx documentation\n\nif \"%SPHINXBUILD%\" == \"\" (\n\tset SPHINXBUILD=sphinx-build\n)\nset BUILDDIR=_build\nset ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .\nset I18NSPHINXOPTS=%SPHINXOPTS% .\nif NOT \"%PAPER%\" == \"\" (\n\tset ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%\n\tset I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%\n)\n\nif \"%1\" == \"\" goto help\n\nif \"%1\" == \"help\" (\n\t:help\n\techo.Please use `make ^<target^>` where ^<target^> is one of\n\techo.  html       to make standalone HTML files\n\techo.  dirhtml    to make HTML files named index.html in directories\n\techo.  singlehtml to make a single large HTML file\n\techo.  pickle     to make pickle files\n\techo.  json       to make JSON files\n\techo.  htmlhelp   to make HTML files and a HTML help project\n\techo.  qthelp     to make HTML files and a qthelp project\n\techo.  devhelp    to make HTML files and a Devhelp project\n\techo.  epub       to make an epub\n\techo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\n\techo.  text       to make text files\n\techo.  man        to make manual pages\n\techo.  texinfo    to make Texinfo files\n\techo.  gettext    to make PO message catalogs\n\techo.  changes    to make an overview over all changed/added/deprecated items\n\techo.  xml        to make Docutils-native XML files\n\techo.  pseudoxml  to make pseudoxml-XML files for display purposes\n\techo.  linkcheck  to check all external links for integrity\n\techo.  doctest    to run all doctests embedded in the documentation if enabled\n\tgoto end\n)\n\nif \"%1\" == \"clean\" (\n\tfor /d %%i in (%BUILDDIR%\\*) do rmdir /q /s %%i\n\tdel /q /s %BUILDDIR%\\*\n\tgoto end\n)\n\n\n%SPHINXBUILD% 2> nul\nif errorlevel 9009 (\n\techo.\n\techo.The 'sphinx-build' command was not found. Make sure you have Sphinx\n\techo.installed, then set the SPHINXBUILD environment variable to point\n\techo.to the full path of the 'sphinx-build' executable. Alternatively you\n\techo.may add the Sphinx directory to PATH.\n\techo.\n\techo.If you don't have Sphinx installed, grab it from\n\techo.http://sphinx-doc.org/\n\texit /b 1\n)\n\nif \"%1\" == \"html\" (\n\t%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/html.\n\tgoto end\n)\n\nif \"%1\" == \"dirhtml\" (\n\t%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.\n\tgoto end\n)\n\nif \"%1\" == \"singlehtml\" (\n\t%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.\n\tgoto end\n)\n\nif \"%1\" == \"pickle\" (\n\t%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can process the pickle files.\n\tgoto end\n)\n\nif \"%1\" == \"json\" (\n\t%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can process the JSON files.\n\tgoto end\n)\n\nif \"%1\" == \"htmlhelp\" (\n\t%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can run HTML Help Workshop with the ^\n.hhp project file in %BUILDDIR%/htmlhelp.\n\tgoto end\n)\n\nif \"%1\" == \"qthelp\" (\n\t%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can run \"qcollectiongenerator\" with the ^\n.qhcp project file in %BUILDDIR%/qthelp, like this:\n\techo.^> qcollectiongenerator %BUILDDIR%\\qthelp\\complexity.qhcp\n\techo.To view the help file:\n\techo.^> assistant -collectionFile %BUILDDIR%\\qthelp\\complexity.ghc\n\tgoto end\n)\n\nif \"%1\" == \"devhelp\" (\n\t%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished.\n\tgoto end\n)\n\nif \"%1\" == \"epub\" (\n\t%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The epub file is in %BUILDDIR%/epub.\n\tgoto end\n)\n\nif \"%1\" == \"latex\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; the LaTeX files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"latexpdf\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tcd %BUILDDIR%/latex\n\tmake all-pdf\n\tcd %BUILDDIR%/..\n\techo.\n\techo.Build finished; the PDF files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"latexpdfja\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tcd %BUILDDIR%/latex\n\tmake all-pdf-ja\n\tcd %BUILDDIR%/..\n\techo.\n\techo.Build finished; the PDF files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"text\" (\n\t%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The text files are in %BUILDDIR%/text.\n\tgoto end\n)\n\nif \"%1\" == \"man\" (\n\t%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The manual pages are in %BUILDDIR%/man.\n\tgoto end\n)\n\nif \"%1\" == \"texinfo\" (\n\t%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.\n\tgoto end\n)\n\nif \"%1\" == \"gettext\" (\n\t%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The message catalogs are in %BUILDDIR%/locale.\n\tgoto end\n)\n\nif \"%1\" == \"changes\" (\n\t%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.The overview file is in %BUILDDIR%/changes.\n\tgoto end\n)\n\nif \"%1\" == \"linkcheck\" (\n\t%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Link check complete; look for any errors in the above output ^\nor in %BUILDDIR%/linkcheck/output.txt.\n\tgoto end\n)\n\nif \"%1\" == \"doctest\" (\n\t%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Testing of doctests in the sources finished, look at the ^\nresults in %BUILDDIR%/doctest/output.txt.\n\tgoto end\n)\n\nif \"%1\" == \"xml\" (\n\t%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The XML files are in %BUILDDIR%/xml.\n\tgoto end\n)\n\nif \"%1\" == \"pseudoxml\" (\n\t%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.\n\tgoto end\n)\n\n:end"
  },
  {
    "path": "docs/readme.rst",
    "content": ".. include:: ../README.rst"
  },
  {
    "path": "docs/usage.rst",
    "content": "========\nUsage\n========\n\nTo use django-users2 in a project::\n\n    import django-users2"
  },
  {
    "path": "example/__init__.py",
    "content": "__author__ = 'mishbah'\n"
  },
  {
    "path": "example/migrations/0001_initial.py",
    "content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom django.conf import settings\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('users', '0001_initial'),\n    ]\n\n    operations = [\n        migrations.CreateModel(\n            name='Customer',\n            fields=[\n                ('user_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),\n                ('first_name', models.CharField(max_length=30, verbose_name='first name', blank=True)),\n                ('last_name', models.CharField(max_length=30, verbose_name='last name', blank=True)),\n            ],\n            options={\n                'verbose_name': 'Customer',\n                'verbose_name_plural': 'Customers',\n            },\n            bases=('users.user',),\n        ),\n    ]\n"
  },
  {
    "path": "example/migrations/__init__.py",
    "content": ""
  },
  {
    "path": "example/models.py",
    "content": "from django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom users.models import User\n\n\nclass Customer(User):\n    first_name = models.CharField(_('first name'), max_length=30, blank=True)\n    last_name = models.CharField(_('last name'), max_length=30, blank=True)\n\n    class Meta:\n        verbose_name = _('Customer')\n        verbose_name_plural = _('Customers')\n"
  },
  {
    "path": "requirements-test.txt",
    "content": "-r requirements.txt\n\ncoverage\ncoveralls\nmock>=1.0.1\nnose>=1.3.0\ndjango-nose>=1.2\nflake8>=2.1.0\ntox>=1.7.0"
  },
  {
    "path": "requirements.txt",
    "content": "-e .\nwheel==0.24.0\n\n# Additional requirements go here"
  },
  {
    "path": "runtests.py",
    "content": "import sys\n\ntry:\n    from django.conf import settings\n\n    settings.configure(\n        DEBUG=True,\n        USE_TZ=True,\n        DATABASES={\n            'default': {\n                'ENGINE': 'django.db.backends.sqlite3',\n                'NAME': 'django_users2',\n            }\n        },\n        ROOT_URLCONF='users.urls',\n        INSTALLED_APPS=[\n            'django.contrib.auth',\n            'django.contrib.sessions',\n            'django.contrib.contenttypes',\n            'django.contrib.sites',\n            'django.contrib.staticfiles',\n            'django.contrib.messages',\n            'users',\n            'example',  # used for testing user model subclasses\n        ],\n        MIDDLEWARE_CLASSES=(\n            'django.middleware.common.CommonMiddleware',\n            'django.contrib.sessions.middleware.SessionMiddleware',\n            'django.contrib.auth.middleware.AuthenticationMiddleware',\n            'django.contrib.messages.middleware.MessageMiddleware',\n        ),\n        PASSWORD_HASHERS=(\n            'django.contrib.auth.hashers.SHA1PasswordHasher',\n        ),\n        SITE_ID=1,\n        NOSE_ARGS=['-s'],\n        AUTH_USER_MODEL='users.User',\n        USERS_CREATE_SUPERUSER=False,\n        TEMPLATES = [\n            {\n                'BACKEND': 'django.template.backends.django.DjangoTemplates',\n                'DIRS': [],\n                'APP_DIRS': True,\n                'OPTIONS': {\n                    'context_processors': [\n                        'django.contrib.auth.context_processors.auth',\n                        'django.template.context_processors.debug',\n                        'django.template.context_processors.i18n',\n                        'django.template.context_processors.media',\n                        'django.template.context_processors.static',\n                        'django.template.context_processors.tz',\n                        'django.contrib.messages.context_processors.messages',\n                    ],\n                },\n            },\n        ]\n    )\n\n    try:\n        import django\n        setup = django.setup\n    except AttributeError:\n        pass\n    else:\n        setup()\n\n    from django_nose import NoseTestSuiteRunner\nexcept ImportError:\n    import traceback\n    traceback.print_exc()\n    raise ImportError('To fix this error, run: pip install -r requirements-test.txt')\n\n\ndef run_tests(*test_args):\n    if not test_args:\n        test_args = ['tests']\n\n    # Run tests\n    test_runner = NoseTestSuiteRunner(verbosity=1)\n\n    failures = test_runner.run_tests(test_args)\n\n    if failures:\n        sys.exit(failures)\n\n\nif __name__ == '__main__':\n    run_tests(*sys.argv[1:])\n"
  },
  {
    "path": "setup.cfg",
    "content": "[wheel]\nuniversal = 1"
  },
  {
    "path": "setup.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport codecs\nimport os\nimport sys\n\nimport users\n\ntry:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nversion = users.__version__\n\nif sys.argv[-1] == 'publish':\n    os.system('python setup.py sdist upload')\n    print(\"You probably want to also tag the version now:\")\n    print(\"  git tag -a %s -m 'version %s'\" % (version, version))\n    print(\"  git push --tags\")\n    sys.exit()\n\nreadme = codecs.open('README.rst', 'r', 'utf-8').read()\n\nsetup(\n    name='django-users2',\n    version=version,\n    description=\"\"\"Custom user model for django >=1.11 with support for multiple user types\"\"\",\n    long_description=readme,\n    author='Mishbah Razzaque',\n    author_email='mishbahx@gmail.com',\n    url='https://github.com/mishbahr/django-users2',\n    packages=[\n        'users',\n    ],\n    include_package_data=True,\n    install_requires=[\n        'django>=1.11',\n        'django-model-utils',\n        'django-appconf',\n    ],\n    license=\"BSD\",\n    zip_safe=False,\n    keywords='django-users2',\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Framework :: Django',\n        'Framework :: Django :: 1.11',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: BSD License',\n        'Natural Language :: English',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n    ],\n)\n"
  },
  {
    "path": "tests/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_admin.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.contrib.admin.sites import AdminSite\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.messages.storage.fallback import FallbackStorage\nfrom django.core import mail\nfrom django.test import TestCase\nfrom django.test.client import RequestFactory\nfrom django.test.utils import override_settings\n\nfrom users.admin import UserAdmin\n\n\nclass AdminTest(TestCase):\n\n    user_email = 'user@example.com'\n    user_password = 'pa$sw0Rd'\n\n    def setUp(self):\n        get_user_model().objects.create_superuser(self.user_email, self.user_password)\n\n        self.assertTrue(self.client.login(\n            username=self.user_email, password=self.user_password),\n            'Failed to login user %s' % self.user_email)\n\n        get_user_model().objects.create_user('user1@example.com', 'pa$sw0Rd1', is_active=False)\n\n        factory = RequestFactory()\n        self.request = factory.get('/admin')\n\n        # Hack to test this function as it calls 'messages.add'\n        # See https://code.djangoproject.com/ticket/17971\n        setattr(self.request, 'session', 'session')\n        messages = FallbackStorage(self.request)\n        setattr(self.request, '_messages', messages)\n\n    def test_get_queryset(self):\n        user_admin = UserAdmin(get_user_model(), AdminSite())\n        self.assertQuerysetEqual(\n            user_admin.get_queryset(self.request),\n            ['<User: user@example.com>', '<User: user1@example.com>'], ordered=False)\n\n    @override_settings(USERS_VERIFY_EMAIL=True)\n    def test_send_activation_email(self):\n        user_admin = UserAdmin(get_user_model(), AdminSite())\n\n        qs = get_user_model().objects.all()\n        user_admin.send_activation_email(self.request, qs)\n        # we created 1 inactive user, so there should be one email in outbox\n        self.assertEqual(len(mail.outbox), 1)\n\n    def test_activate_users(self):\n        user_admin = UserAdmin(get_user_model(), AdminSite())\n\n        qs = get_user_model().objects.all()\n        user_admin.activate_users(self.request, qs)\n        # both users should be active\n        self.assertEqual(get_user_model().objects.filter(is_active=True).count(), 2)\n        # superuser is automatically activated. so we test the attribute for user1@example.com\n        user = get_user_model().objects.get(email='user1@example.com')\n        self.assertTrue(user.is_active)\n\n    def tearDown(self):\n        self.client.logout()\n"
  },
  {
    "path": "tests/test_fields.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django import forms\nfrom django.test import TestCase\nfrom django.test.utils import override_settings\n\nfrom users.fields import (ComplexityValidator, EmailDomainValidator,\n                          LengthValidator)\n\n\nclass LengthValidatorTest(TestCase):\n\n    @override_settings(USERS_PASSWORD_MIN_LENGTH=6, USERS_PASSWORD_MAX_LENGTH=20)\n    def setUp(self):\n        self.length_validator = LengthValidator()\n\n    def test_password_length_validator_min_length(self):\n        value = 'abc'\n        try:\n            self.length_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n    def test_password_length_validator_max_length(self):\n        value = 'qwertyuiopasdfghjklzxcvbnm'\n        try:\n            self.length_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n\nclass ComplexityValidatorTest(TestCase):\n    password_policy = {\n        'UPPER': 1,\n        'LOWER': 1,\n        'DIGITS': 1,\n        'PUNCTUATION': 1\n    }\n\n    @override_settings(USERS_PASSWORD_POLICY={'UPPER': 1})\n    def test_complexity_validator_fails_no_uppercase(self):\n        complexity_validator = ComplexityValidator()\n        value = 'password'\n        try:\n            complexity_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n    @override_settings(USERS_PASSWORD_POLICY={'LOWER': 1})\n    def test_complexity_validator_fails_no_lowercase(self):\n        complexity_validator = ComplexityValidator()\n        value = 'PASSWORD'\n        try:\n            complexity_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n    @override_settings(USERS_PASSWORD_POLICY={'DIGITS': 1})\n    def test_complexity_validator_fails_no_digit(self):\n        complexity_validator = ComplexityValidator()\n        value = 'password'\n        try:\n            complexity_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n    @override_settings(USERS_PASSWORD_POLICY={'PUNCTUATION': 1})\n    def test_complexity_validator_fails_no_symbol(self):\n        complexity_validator = ComplexityValidator()\n        value = 'password'\n        try:\n            complexity_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n    @override_settings(USERS_PASSWORD_POLICY=password_policy)\n    def test_complexity_validator_success(self):\n        complexity_validator = ComplexityValidator()\n        value = 'Pas$word1'\n        try:\n            complexity_validator(value)\n        except forms.ValidationError:\n            self.fail('ValidationError raised when validating \\'%s\\'' % value)\n\n\nclass EmailDomainValidatorTest(TestCase):\n    domains_blacklist = ('mailinator.com', )\n    domains_whitelist = ('djangoproject.com', )\n\n    @override_settings(USERS_EMAIL_DOMAINS_WHITELIST=domains_whitelist)\n    def test_email_domain_validator_with_white_list(self):\n        email_domain_validator = EmailDomainValidator()\n        value = 'user@example.com'\n        try:\n            email_domain_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n\n    @override_settings(USERS_EMAIL_DOMAINS_BLACKLIST=domains_blacklist)\n    def test_email_domain_validator_with_black_list(self):\n        email_domain_validator = EmailDomainValidator()\n        value = 'spammer@mailinator.com'\n        try:\n            email_domain_validator(value)\n        except forms.ValidationError:\n            pass\n        else:\n            self.fail('ValidationError not raised when validating \\'%s\\'' % value)\n"
  },
  {
    "path": "tests/test_forms.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.contrib.auth import get_user_model\nfrom django.test import TestCase\nfrom django.utils.encoding import force_text\nfrom django.utils.translation import ugettext as _\n\nfrom users.forms import (RegistrationFormHoneypot,\n                         RegistrationFormTermsOfService, UserChangeForm,\n                         UserCreationForm)\n\n\nclass UserCreationFormTest(TestCase):\n\n    def test_user_already_exists(self):\n        get_user_model().objects.create_user('testuser@example.com', 'Pa$sw0rd')\n\n        data = {\n            'email': 'testuser@example.com',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n        }\n        form = UserCreationForm(data)\n        self.assertFalse(form.is_valid())\n        self.assertEqual(form['email'].errors,\n                         [force_text(form.error_messages['duplicate_email'])])\n\n    def test_invalid_email(self):\n        data = {\n            'email': 'testuser',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n        }\n        form = UserCreationForm(data)\n        self.assertFalse(form.is_valid())\n        self.assertIn(_('Enter a valid email address.'), form['email'].errors)\n\n    def test_password_verification(self):\n        # The verification password is incorrect.\n        data = {\n            'email': 'testuser@example.com',\n            'password1': 'Pa$sw0rd1',\n            'password2': 'Pa$sw0rd2',\n        }\n        form = UserCreationForm(data)\n        self.assertFalse(form.is_valid())\n        self.assertEqual(form['password2'].errors,\n                         [force_text(form.error_messages['password_mismatch'])])\n\n    def test_password_is_not_saved_raw(self):\n        raw_password = 'Pa$sw0rd2'\n        data = {\n            'email': 'testuser@example.com',\n            'password1': raw_password,\n            'password2': raw_password,\n        }\n        form = UserCreationForm(data)\n        user = form.save()\n        self.assertNotEqual(raw_password, user.password)\n\n    def test_valid_user_are_saved(self):\n        data = {\n            'email': 'validuser@example.com',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n        }\n        form = UserCreationForm(data)\n        self.assertTrue(form.is_valid())\n        user = form.save()\n        self.assertEqual(repr(user), '<%s: validuser@example.com>' % get_user_model().__name__)\n\n\nclass UserChangeFormTest(TestCase):\n\n    def test_username_validity(self):\n        user = get_user_model().objects.create_user('testuser@example.com', 'Pa$sw0rd')\n        data = {\n            'email': 'invalid-email'\n        }\n        form = UserChangeForm(data, instance=user)\n        self.assertFalse(form.is_valid())\n        self.assertIn(_('Enter a valid email address.'), form['email'].errors)\n\n    def test_unsuable_password(self):\n        user = get_user_model().objects.create_user('testuser@example.com', 'Pa$sw0rd')\n        user.set_unusable_password()\n        user.save()\n        form = UserChangeForm(instance=user)\n        self.assertIn(_('No password set.'), form.as_table())\n\n\nclass RegistrationFormTermsOfServiceTest(TestCase):\n\n    def test_registration_form_with_tos_checkbox_validates(self):\n        data = {\n            'email': 'testuser@example.com',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n            'tos': True\n        }\n        form = RegistrationFormTermsOfService(data=data)\n        self.assertTrue(form.is_valid())\n\n    def test_registration_form_with_tos_checkbox_fails(self):\n        data = {\n            'email': 'testuser@example.com',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n        }\n        form = RegistrationFormTermsOfService(data=data)\n        self.assertFalse(form.is_valid())\n        self.assertEqual(form.errors['tos'], [u'You must agree to the terms to register'])\n\n\nclass RegistrationFormHoneypotTest(TestCase):\n    def test_registration_form_with_honeypot_field(self):\n        data = {\n            'email': 'testuser@example.com',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n        }\n        form = RegistrationFormHoneypot(data=data)\n        self.assertTrue(form.is_valid())\n\n    def test_registration_form_with_honeypot_field_fails_as_expected(self):\n        data = {\n            'email': 'testuser@example.com',\n            'password1': 'Pa$sw0rd',\n            'password2': 'Pa$sw0rd',\n            'accept_terms': True\n        }\n        form = RegistrationFormHoneypot(data=data)\n        self.assertFalse(form.is_valid())\n"
  },
  {
    "path": "tests/test_managers.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.contrib.auth import get_user_model\nfrom django.test import TestCase\n\nfrom example.models import Customer\n\n\nclass UserManagerTest(TestCase):\n\n    user_email = 'user@example.com'\n    user_password = 'pa$sw0Rd'\n\n    def test_create_user(self):\n        user = get_user_model().objects.create_user(self.user_email)\n        self.assertEqual(user.email, self.user_email)\n        self.assertFalse(user.has_usable_password())\n        self.assertTrue(user.is_active)\n        self.assertFalse(user.is_staff)\n        self.assertFalse(user.is_superuser)\n\n    def test_create_superuser(self):\n        user = get_user_model().objects.create_superuser(\n            self.user_email, self.user_password)\n\n        self.assertEqual(user.email, self.user_email)\n        self.assertTrue(user.check_password, self.user_password)\n        self.assertTrue(user.is_active)\n        self.assertTrue(user.is_staff)\n        self.assertTrue(user.is_superuser)\n\n    def test_inactive_user_creation(self):\n        # Create deactivated user\n        user = get_user_model().objects.create_user(\n            self.user_email, self.user_password, is_active=False)\n        self.assertFalse(user.is_active)\n\n    def test_staff_user_creation(self):\n        # Create staff user\n        user = get_user_model().objects.create_user(\n            self.user_email, self.user_password, is_staff=True)\n        self.assertTrue(user.is_staff)\n\n    def test_empty_username(self):\n        self.assertRaises(ValueError, get_user_model().objects.create_user, email='')\n\n    def test_automatic_downcasting_of_inherited_user_models(self):\n        get_user_model().objects.create_superuser(\n            self.user_email, self.user_password)\n        Customer.objects.create_user('customer@example.com', 'cu$t0meR')\n        self.assertQuerysetEqual(\n            get_user_model().objects.all(),\n            ['<User: user@example.com>', '<Customer: customer@example.com>'], ordered=False)\n"
  },
  {
    "path": "tests/test_models.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.contrib.auth import get_user_model\nfrom django.core import mail\nfrom django.test import TestCase\n\n\nclass TestUsersModels(TestCase):\n\n    user_email = 'user@example.com'\n    user_password = 'pa$sw0Rd'\n\n    def create_user(self):\n        return get_user_model().objects.create_user(self.user_email, self.user_password)\n\n    def test_user_creation(self):\n        user = self.create_user()\n\n        self.assertEqual(get_user_model().objects.all().count(), 1)\n        self.assertEqual(user.email, self.user_email)\n\n        self.assertTrue(user.is_active)\n        self.assertFalse(user.is_staff)\n        self.assertFalse(user.is_superuser)\n\n    def test_user_get_full_name(self):\n        user = self.create_user()\n        self.assertEqual(user.get_full_name(), self.user_email)\n\n    def test_user_get_short_name(self):\n        user = self.create_user()\n        self.assertEqual(user.get_short_name(), self.user_email)\n\n    def test_email_user(self):\n        # Email definition\n        subject = 'email subject'\n        message = 'email message'\n        from_email = 'from@example.com'\n\n        user = self.create_user()\n\n        # Test that no message exists\n        self.assertEqual(len(mail.outbox), 0)\n\n        # Send test email\n        user.email_user(subject, message, from_email)\n\n        # Test that one message has been sent\n        self.assertEqual(len(mail.outbox), 1)\n\n        # Verify that the email is correct\n        self.assertEqual(mail.outbox[0].subject, subject)\n        self.assertEqual(mail.outbox[0].body, message)\n        self.assertEqual(mail.outbox[0].from_email, from_email)\n        self.assertEqual(mail.outbox[0].to, [user.email])\n\n    def test_user_activation(self):\n        user = get_user_model().objects.create_user(\n            self.user_email, self.user_password, is_active=False)\n        # check user is not active by default\n        self.assertFalse(user.is_active)\n        # activate user\n        user.activate()\n        self.assertTrue(user.is_active)\n\n    def test_(self):\n        user = self.create_user()\n        self.assertIsNotNone(user.user_type)\n"
  },
  {
    "path": "tests/test_utils.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom datetime import date, timedelta\n\nfrom django.contrib.auth import get_user_model\nfrom django.core import mail\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase\nfrom django.test.client import RequestFactory\nfrom django.test.utils import override_settings\n\nfrom users.conf import settings\nfrom users.utils import (auto_create_superuser, EmailActivationTokenGenerator,\n                         send_activation_email)\n\n\nclass CreateSuperuserTest(TestCase):\n\n    user_email = 'user@example.com'\n    user_password = 'pa$sw0Rd'\n\n    @override_settings(USERS_CREATE_SUPERUSER=True,\n                       USERS_SUPERUSER_EMAIL=user_email,\n                       USERS_SUPERUSER_PASSWORD=user_password)\n    def test_auto_create_superuser(self):\n        auto_create_superuser(sender=None)\n\n        user = get_user_model().objects.get(email=self.user_email)\n\n        self.assertTrue(user.is_active)\n        self.assertTrue(user.is_staff)\n        self.assertTrue(user.is_superuser)\n\n\nclass SendActivationEmailTest(TestCase):\n\n    user_email = 'user@example.com'\n    user_password = 'pa$sw0Rd'\n\n    @override_settings(USERS_VERIFY_EMAIL=True)\n    def test_send_activation_email(self):\n        factory = RequestFactory()\n        request = factory.get(reverse('users_register'))\n        user = get_user_model().objects.create_user(\n            self.user_email, self.user_password, is_active=False)\n\n        send_activation_email(user=user, request=request)\n        self.assertEqual(len(mail.outbox), 1)\n\n\nclass EmailActivationTokenGeneratorTest(TestCase):\n    user_email = 'user@example.com'\n    user_password = 'pa$sw0Rd'\n\n    def create_user(self):\n        return get_user_model().objects.create_user(self.user_email, self.user_password)\n\n    def test_make_token(self):\n        \"\"\"\n        Ensure that we can make a token and that it is valid\n        \"\"\"\n        user = self.create_user()\n\n        token_generator = EmailActivationTokenGenerator()\n        token = token_generator.make_token(user)\n        self.assertTrue(token_generator.check_token(user, token))\n\n    def test_bad_token(self):\n        \"\"\"\n        Ensure bad activation keys are rejected\n        \"\"\"\n        user = self.create_user()\n\n        token_generator = EmailActivationTokenGenerator()\n        bad_activation_keys = (\n            'emailactivationtokengenerator',\n            'emailactivation-tokengenerator',\n            '3rd-bademailactivationkey'\n        )\n        for key in bad_activation_keys:\n            self.assertFalse(token_generator.check_token(user, key))\n\n    def test_timeout(self):\n        \"\"\"\n        Ensure we can use the token after n days, but no greater.\n        \"\"\"\n        # Uses a mocked version of EmailActivationTokenGenerator\n        # so we can change the value of 'today'\n        class Mocked(EmailActivationTokenGenerator):\n            def __init__(self, today):\n                self._today_val = today\n\n            def _today(self):\n                return self._today_val\n\n        user = self.create_user()\n        token_generator = EmailActivationTokenGenerator()\n        token = token_generator.make_token(user)\n\n        p1 = Mocked(date.today() + timedelta(settings.USERS_EMAIL_CONFIRMATION_TIMEOUT_DAYS))\n        self.assertTrue(p1.check_token(user, token))\n\n        p2 = Mocked(date.today() + timedelta(settings.USERS_EMAIL_CONFIRMATION_TIMEOUT_DAYS + 1))\n        self.assertFalse(p2.check_token(user, token))\n"
  },
  {
    "path": "tests/test_views.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport re\n\nfrom django.contrib.auth import get_user_model\nfrom django.core import mail\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase\nfrom django.test.utils import override_settings\n\nfrom users.forms import RegistrationForm, RegistrationFormHoneypot\n\n\nclass RegisterViewTest(TestCase):\n    user_data = {\n        'email': 'user@example.com',\n        'password1': 'pa$sw0Rd',\n        'password2': 'pa$sw0Rd'\n    }\n\n    @override_settings(USERS_REGISTRATION_OPEN=True)\n    def test_registration_allowed(self):\n        resp = self.client.get(reverse('users_register'))\n        self.assertEqual(200, resp.status_code)\n\n    @override_settings(USERS_REGISTRATION_OPEN=False)\n    def test_registration_closed(self):\n        resp = self.client.get(reverse('users_register'))\n        self.assertRedirects(resp, reverse('users_registration_closed'))\n\n    @override_settings(USERS_SPAM_PROTECTION=False)\n    def test_registration_form(self):\n        resp = self.client.get(reverse('users_register'))\n        self.assertEqual(200, resp.status_code)\n        self.failUnless(isinstance(resp.context['form'], RegistrationForm))\n\n    @override_settings(USERS_SPAM_PROTECTION=True)\n    def test_registration_form_with_honeypot(self):\n        resp = self.client.get(reverse('users_register'))\n        self.assertEqual(200, resp.status_code)\n        self.failUnless(isinstance(resp.context['form'], RegistrationFormHoneypot))\n\n    def test_registration(self):\n        resp = self.client.post(reverse('users_register'), self.user_data)\n        self.assertRedirects(resp, reverse('users_registration_complete'))\n\n    def test_registration_created_new_user(self):\n        resp = self.client.post(reverse('users_register'), self.user_data)\n        self.assertEqual(get_user_model().objects.all().count(), 1)\n\n    @override_settings(LOGIN_REDIRECT_URL=reverse('users_registration_complete'))\n    def test_authenticated_users_are_redirected(self):\n        user = get_user_model().objects.create_user(\n            self.user_data['email'], self.user_data['password1'], is_active=True)\n        login = self.client.login(\n            username=self.user_data['email'],\n            password=self.user_data['password1'])\n        self.assertEqual(login, True)\n        resp = self.client.post(reverse('users_register'), self.user_data)\n        self.assertRedirects(resp, reverse('users_registration_complete'))\n\n    @override_settings(USERS_VERIFY_EMAIL=True)\n    def test_registered_user_is_not_active(self):\n        resp = self.client.post(reverse('users_register'), self.user_data)\n        new_user = get_user_model().objects.get(email=self.user_data['email'])\n        self.failIf(new_user.is_active)\n\n    @override_settings(USERS_VERIFY_EMAIL=True)\n    def test_activation_email_was_sent(self):\n        resp = self.client.post(reverse('users_register'), self.user_data)\n        self.assertEqual(len(mail.outbox), 1)\n\n\nclass ActivationViewTest(TestCase):\n    user_data = {\n        'email': 'user@example.com',\n        'password1': 'pa$sw0Rd',\n        'password2': 'pa$sw0Rd'\n    }\n\n    @override_settings(USERS_VERIFY_EMAIL=True)\n    def test_activation_view(self):\n        self.client.post(reverse('users_register'), self.user_data)\n        activation_email = mail.outbox[0]\n        urlmatch = re.search(r'https?://[^/]*(/.*activate/\\S*)', activation_email.body)\n        self.assertTrue(urlmatch is not None, 'No URL found in sent email')\n        resp = self.client.get(urlmatch.groups()[0])\n        self.assertRedirects(resp, reverse('users_activation_complete'))\n\n        new_user = get_user_model().objects.get(email=self.user_data['email'])\n        self.assertTrue(new_user.is_active)\n\n    @override_settings(USERS_VERIFY_EMAIL=True)\n    def test_activation_view_fails_as_expected(self):\n        url = reverse('users_activate', kwargs={\n            'uidb64': 'MQ',\n            'token': 'bad-69b5cdcd57c6854d1b04'\n        })\n        resp = self.client.get(url)\n        self.assertEqual(200, resp.status_code)\n        self.failUnless(resp.context['title'], 'Email confirmation unsuccessful')\n"
  },
  {
    "path": "tox.ini",
    "content": "[tox]\nenvlist = py26, py27, py33\n\n[testenv]\nsetenv =\n    PYTHONPATH = {toxinidir}:{toxinidir}/users\ncommands = python runtests.py\ndeps =\n    -r{toxinidir}/requirements-test.txt"
  },
  {
    "path": "users/__init__.py",
    "content": "__version__ = '0.2.2'\n"
  },
  {
    "path": "users/admin.py",
    "content": "from django.contrib import admin, messages\nfrom django.contrib.auth.admin import UserAdmin as BaseUserAdmin\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom .conf import settings\nfrom .forms import UserChangeForm, UserCreationForm\nfrom .models import User\nfrom .utils import send_activation_email\n\ntry:\n    from django.contrib.admin.utils import model_ngettext\nexcept ImportError:  # pragma: no cover\n    from django.contrib.admin.util import model_ngettext\n\n\nclass UserModelFilter(admin.SimpleListFilter):\n    \"\"\"\n    An admin list filter for the UserAdmin which enables\n    filtering by its child models.\n    \"\"\"\n    title = _('user type')\n    parameter_name = 'user_type'\n\n    def lookups(self, request, model_admin):\n        user_types = set([user.user_type for user in model_admin.model.objects.all()])\n        return [(user_type.id, user_type.name) for user_type in user_types]\n\n    def queryset(self, request, queryset):\n        try:\n            value = int(self.value())\n        except TypeError:\n            value = None\n\n        if value:\n            return queryset.filter(user_type_id__exact=value)\n        else:\n            return queryset\n\n\nclass UserAdmin(BaseUserAdmin):\n    fieldsets = (\n        (None, {\n            'fields': ('email', 'password')\n        }),\n        (_('Permissions'), {\n            'fields': ('is_active', 'is_staff', 'is_superuser',\n                       'groups', 'user_permissions')\n        }),\n        (_('Important dates'), {\n            'fields': ('last_login', 'date_joined')\n        }),\n    )\n\n    add_fieldsets = (\n        (None, {\n            'classes': ('wide',),\n            'fields': ('email', 'password1', 'password2')\n        }),\n    )\n\n    form = UserChangeForm\n    add_form = UserCreationForm\n\n    list_display = ('email', 'is_active')\n    list_filter = (UserModelFilter, 'is_staff', 'is_superuser', 'is_active',)\n    search_fields = ('email',)\n    ordering = ('email',)\n    actions = ('activate_users', 'send_activation_email', )\n    readonly_fields = ('last_login', 'date_joined', )\n\n    def get_queryset(self, request):\n        # optimize queryset for list display.\n        qs = self.model.base_objects.get_queryset()\n        ordering = self.get_ordering(request)\n        if ordering:\n            qs = qs.order_by(*ordering)\n        return qs\n\n    def activate_users(self, request, queryset):\n        \"\"\"\n        Activates the selected users, if they are not already\n        activated.\n\n        \"\"\"\n        n = 0\n        for user in queryset:\n            if not user.is_active:\n                user.activate()\n                n += 1\n        self.message_user(\n            request,\n            _('Successfully activated %(count)d %(items)s.') %\n            {'count': n, 'items': model_ngettext(self.opts, n)},  messages.SUCCESS)\n    activate_users.short_description = _('Activate selected %(verbose_name_plural)s')\n\n    def send_activation_email(self, request, queryset):\n        \"\"\"\n        Send activation emails for the selected users, if they are not already\n        activated.\n        \"\"\"\n        n = 0\n        for user in queryset:\n            if not user.is_active and settings.USERS_VERIFY_EMAIL:\n                send_activation_email(user=user, request=request)\n                n += 1\n\n        self.message_user(\n            request, _('Activation emails sent to %(count)d %(items)s.') %\n            {'count': n, 'items': model_ngettext(self.opts, n)},  messages.SUCCESS)\n\n    send_activation_email.short_description = \\\n        _('Send activation emails to selected %(verbose_name_plural)s')\n\n\nadmin.site.register(User, UserAdmin)\n"
  },
  {
    "path": "users/compat.py",
    "content": "import base64\nfrom binascii import Error as BinasciiError\n\ntry:\n    from django.utils.http import urlsafe_base64_encode\nexcept ImportError:\n    def urlsafe_base64_encode(s):\n        \"\"\"\n        Encodes a bytestring in base64 for use in URLs, stripping any trailing\n        equal signs.\n        \"\"\"\n        return base64.urlsafe_b64encode(s).rstrip(b'\\n=')\n\ntry:\n    from django.utils.http import urlsafe_base64_decode\nexcept ImportError:\n    def urlsafe_base64_decode(s):\n        \"\"\"\n        Decodes a base64 encoded string, adding back any trailing equal signs that\n        might have been stripped.\n        \"\"\"\n        s = s.encode('utf-8')  # base64encode should only return ASCII.\n        try:\n            return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))\n        except (LookupError, BinasciiError) as e:\n            raise ValueError(e)\n"
  },
  {
    "path": "users/conf.py",
    "content": "from appconf import AppConf\nfrom django.conf import settings\n\n\nclass UsersAppConf(AppConf):\n    VERIFY_EMAIL = False\n    CREATE_SUPERUSER = settings.DEBUG\n    SUPERUSER_EMAIL = 'superuser@djangoproject.com'\n    SUPERUSER_PASSWORD = 'django'\n    EMAIL_CONFIRMATION_TIMEOUT_DAYS = 3\n    SPAM_PROTECTION = True\n    REGISTRATION_OPEN = True\n    AUTO_LOGIN_ON_ACTIVATION = True\n    AUTO_LOGIN_AFTER_REGISTRATION = False\n    PASSWORD_MIN_LENGTH = 5\n    PASSWORD_MAX_LENGTH = None\n    CHECK_PASSWORD_COMPLEXITY = True\n    PASSWORD_POLICY = {\n        'UPPER': 0,       # Uppercase 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n        'LOWER': 0,       # Lowercase 'abcdefghijklmnopqrstuvwxyz'\n        'DIGITS': 0,      # Digits '0123456789'\n        'PUNCTUATION': 0  # Punctuation \"\"\"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\"\"\"\n    }\n    VALIDATE_EMAIL_DOMAIN = True\n    EMAIL_DOMAINS_BLACKLIST = []\n    EMAIL_DOMAINS_WHITELIST = []\n\n    class Meta:\n        prefix = 'users'\n"
  },
  {
    "path": "users/fields.py",
    "content": "import string\n\nfrom django import forms\nfrom django.core.validators import validate_email\nfrom django.forms.widgets import CheckboxInput\nfrom django.utils.encoding import force_text\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom .conf import settings\n\n\nclass LengthValidator(object):\n    code = 'length'\n\n    def __init__(self, min_length=None, max_length=None):\n        self.min_length = min_length or settings.USERS_PASSWORD_MIN_LENGTH\n        self.max_length = max_length or settings.USERS_PASSWORD_MAX_LENGTH\n\n    def __call__(self, value):\n        if self.min_length and len(value) < self.min_length:\n            raise forms.ValidationError(\n                _('Password too short (must be %s characters or more)') % self.min_length,\n                code=self.code)\n        elif self.max_length and len(value) > self.max_length:\n            raise forms.ValidationError(\n                _('Password too long (must be %s characters or less)') % self.max_length,\n                code=self.code)\n\nlength_validator = LengthValidator()\n\n\nclass ComplexityValidator(object):\n    code = 'complexity'\n    message = _('Weak password, %s')\n\n    def __init__(self):\n        self.password_policy = settings.USERS_PASSWORD_POLICY\n\n    def __call__(self, value):\n        if not settings.USERS_CHECK_PASSWORD_COMPLEXITY:  # pragma: no cover\n            return\n\n        uppercase, lowercase, digits, non_ascii, punctuation = set(), set(), set(), set(), set()\n\n        for char in value:\n            if char.isupper():\n                uppercase.add(char)\n            elif char.islower():\n                lowercase.add(char)\n            elif char.isdigit():\n                digits.add(char)\n            elif char in string.punctuation:\n                punctuation.add(char)\n            else:\n                non_ascii.add(char)\n\n        if len(uppercase) < self.password_policy.get('UPPER', 0):\n            raise forms.ValidationError(\n                self.message % _('must contain %(UPPER)s or '\n                                 'more uppercase characters (A-Z)') % self.password_policy,\n                code=self.code)\n        elif len(lowercase) < self.password_policy.get('LOWER', 0):\n            raise forms.ValidationError(\n                self.message % _('Must contain %(LOWER)s or '\n                                 'more lowercase characters (a-z)') % self.password_policy,\n                code=self.code)\n        elif len(digits) < self.password_policy.get('DIGITS', 0):\n            raise forms.ValidationError(\n                self.message % _('must contain %(DIGITS)s or '\n                                 'more numbers (0-9)') % self.password_policy,\n                code=self.code)\n        elif len(punctuation) < self.password_policy.get('PUNCTUATION', 0):\n            raise forms.ValidationError(\n                self.message % _('must contain %(PUNCTUATION)s or more '\n                                 'symbols') % self.password_policy,\n                code=self.code)\n\n\ncomplexity_validator = ComplexityValidator()\n\n\nclass PasswordField(forms.CharField):\n    widget = forms.PasswordInput()\n    default_validators = [length_validator, complexity_validator, ]\n\n\nclass HoneyPotField(forms.BooleanField):\n    widget = CheckboxInput\n\n    def __init__(self, *args, **kwargs):\n        super(HoneyPotField, self).__init__(*args, **kwargs)\n        self.required = False\n        if not self.label:\n            self.label = _('Are you human? (Sorry, we have to ask!)')\n        if not self.help_text:\n            self.help_text = _('Please don\\'t check this box if you are a human.')\n\n    def validate(self, value):\n        if value:\n            raise forms.ValidationError(_('Doh! You are a robot!'))\n\n\nclass EmailDomainValidator(object):\n    message = _('Sorry, %s emails are not allowed. Please use a different email address.')\n    code = 'invalid'\n\n    def __init__(self, ):\n        self.domain_blacklist = settings.USERS_EMAIL_DOMAINS_BLACKLIST\n        self.domain_whitelist = settings.USERS_EMAIL_DOMAINS_WHITELIST\n\n    def __call__(self, value):\n        if not settings.USERS_VALIDATE_EMAIL_DOMAIN:  # pragma: no cover\n            return\n\n        if not value or '@' not in value:\n            raise forms.ValidationError(_('Enter a valid email address.'), code=self.code)\n\n        value = force_text(value)\n        user_part, domain_part = value.rsplit('@', 1)\n\n        if self.domain_blacklist and domain_part in self.domain_blacklist:\n            raise forms.ValidationError(self.message % domain_part, code=self.code)\n\n        if self.domain_whitelist and domain_part not in self.domain_whitelist:\n            raise forms.ValidationError(self.message % domain_part, code=self.code)\n\n\nvalidate_email_domain = EmailDomainValidator()\n\n\nclass UsersEmailField(forms.EmailField):\n    default_validators = [validate_email, validate_email_domain]\n"
  },
  {
    "path": "users/forms.py",
    "content": "from django import forms\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.auth.forms import ReadOnlyPasswordHashField\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom .conf import settings\nfrom .fields import HoneyPotField, PasswordField, UsersEmailField\n\n\nclass UserCreationForm(forms.ModelForm):\n\n    error_messages = {\n        'duplicate_email': _('A user with that email already exists.'),\n        'password_mismatch': _('The two password fields didn\\'t match.'),\n    }\n\n    email = UsersEmailField(label=_('Email Address'), max_length=255)\n    password1 = PasswordField(label=_('Password'))\n    password2 = PasswordField(\n        label=_('Password Confirmation'),\n        help_text=_('Enter the same password as above, for verification.'))\n\n    class Meta:\n        model = get_user_model()\n        fields = ('email',)\n\n    def clean_email(self):\n\n        # Since User.email is unique, this check is redundant,\n        # but it sets a nicer error message than the ORM. See #13147.\n        email = self.cleaned_data['email']\n        try:\n            get_user_model()._default_manager.get(email=email)\n        except get_user_model().DoesNotExist:\n            return email\n        raise forms.ValidationError(\n            self.error_messages['duplicate_email'],\n            code='duplicate_email',\n        )\n\n    def clean_password2(self):\n\n        password1 = self.cleaned_data.get('password1')\n        password2 = self.cleaned_data.get('password2')\n        if password1 and password2 and password1 != password2:\n            raise forms.ValidationError(\n                self.error_messages['password_mismatch'],\n                code='password_mismatch',\n            )\n        return password2\n\n    def save(self, commit=True):\n        user = super(UserCreationForm, self).save(commit=False)\n        user.set_password(self.cleaned_data['password1'])\n        user.is_active = not settings.USERS_VERIFY_EMAIL\n        if commit:\n            user.save()\n        return user\n\n\nclass UserChangeForm(forms.ModelForm):\n\n    password = ReadOnlyPasswordHashField(label=_('Password'), help_text=_(\n        'Raw passwords are not stored, so there is no way to see '\n        'this user\\'s password, but you can change the password '\n        'using <a href=\\\"password/\\\">this form</a>.'))\n\n    class Meta:\n        model = get_user_model()\n        exclude = ()\n\n    def __init__(self, *args, **kwargs):\n        super(UserChangeForm, self).__init__(*args, **kwargs)\n        f = self.fields.get('user_permissions', None)\n        if f is not None:\n            f.queryset = f.queryset.select_related('content_type')\n\n    def clean_password(self):\n        return self.initial['password']\n\n\nclass RegistrationForm(UserCreationForm):\n    error_css_class = 'error'\n    required_css_class = 'required'\n\n\nclass RegistrationFormTermsOfService(RegistrationForm):\n    \"\"\"\n    Subclass of ``RegistrationForm`` which adds a required checkbox\n    for agreeing to a site's Terms of Service.\n\n    \"\"\"\n    tos = forms.BooleanField(\n        label=_('I have read and agree to the Terms of Service'),\n        widget=forms.CheckboxInput,\n        error_messages={\n            'required': _('You must agree to the terms to register')\n        })\n\n\nclass RegistrationFormHoneypot(RegistrationForm):\n    \"\"\"\n    Subclass of ``RegistrationForm`` which adds a honeypot field\n    for Spam Prevention\n\n    \"\"\"\n    accept_terms = HoneyPotField()\n"
  },
  {
    "path": "users/managers.py",
    "content": "from django.contrib.auth.models import BaseUserManager\nfrom django.utils import timezone\n\nfrom model_utils.managers import InheritanceQuerySet\n\nfrom .conf import settings\n\n\nclass UserManager(BaseUserManager):\n\n    def get_queryset(self):\n        \"\"\"\n        Fixes get_query_set vs get_queryset for Django <1.6\n        \"\"\"\n        try:\n            qs = super(UserManager, self).get_queryset()\n        except AttributeError:  # pragma: no cover\n            qs = super(UserManager, self).get_query_set()\n        return qs\n\n    get_query_set = get_queryset\n\n    def _create_user(self, email, password,\n                     is_staff, is_superuser, **extra_fields):\n\n        users_auto_activate = not settings.USERS_VERIFY_EMAIL\n        now = timezone.now()\n        if not email:\n            raise ValueError('The given email must be set')\n        email = self.normalize_email(email)\n\n        is_active = extra_fields.pop('is_active', users_auto_activate)\n        user = self.model(email=email, is_staff=is_staff, is_active=is_active,\n                          is_superuser=is_superuser, last_login=now,\n                          date_joined=now, **extra_fields)\n        user.set_password(password)\n        user.save(using=self._db)\n        return user\n\n    def create_user(self, email, password=None, **extra_fields):\n\n        is_staff = extra_fields.pop('is_staff', False)\n        return self._create_user(email=email, password=password, \n                                 is_staff=is_staff, is_superuser=False,\n                                 **extra_fields)\n\n    def create_superuser(self, email, password, **extra_fields):\n        return self._create_user(email=email, password=password, \n                                 is_staff=True, is_superuser=True,\n                                 is_active=True, **extra_fields)\n\n\nclass UserInheritanceManager(UserManager):\n    def get_queryset(self):\n        return InheritanceQuerySet(self.model).select_subclasses()\n\n    get_query_set = get_queryset\n"
  },
  {
    "path": "users/migrations/0001_initial.py",
    "content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport django.utils.timezone\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('auth', '0001_initial'),\n        ('contenttypes', '0001_initial'),\n    ]\n\n    operations = [\n        migrations.CreateModel(\n            name='User',\n            fields=[\n                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),\n                ('password', models.CharField(max_length=128, verbose_name='password')),\n                ('last_login', models.DateTimeField(default=django.utils.timezone.now, verbose_name='last login')),\n                ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),\n                ('email', models.EmailField(unique=True, max_length=255, verbose_name='email address', db_index=True)),\n                ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),\n                ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),\n                ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),\n                ('groups', models.ManyToManyField(to='auth.Group', verbose_name='groups', blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user')),\n                ('user_permissions', models.ManyToManyField(to='auth.Permission', verbose_name='user permissions', blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user')),\n                ('user_type', models.ForeignKey(editable=False, on_delete=models.SET_NULL, to='contenttypes.ContentType', null=True)),\n            ],\n            options={\n                'abstract': False,\n                'verbose_name': 'User',\n                'swappable': 'AUTH_USER_MODEL',\n                'verbose_name_plural': 'Users',\n            },\n            bases=(models.Model,),\n        ),\n    ]\n"
  },
  {
    "path": "users/migrations/0002_alter_user_last_login_null.py",
    "content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('users', '0001_initial'),\n    ]\n\n    operations = [\n        migrations.AlterField(\n            model_name='user',\n            name='last_login',\n            field=models.DateTimeField(null=True, verbose_name='last login', blank=True),\n        ),\n    ]\n"
  },
  {
    "path": "users/migrations/__init__.py",
    "content": ""
  },
  {
    "path": "users/models.py",
    "content": "from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.core.mail import send_mail\nfrom django.db import models\nfrom django.utils import timezone\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom .conf import settings\nfrom .managers import UserInheritanceManager, UserManager\n\n\nclass AbstractUser(AbstractBaseUser, PermissionsMixin):\n    USERS_AUTO_ACTIVATE = not settings.USERS_VERIFY_EMAIL\n\n    email = models.EmailField(\n        _('email address'), max_length=255, unique=True, db_index=True)\n    is_staff = models.BooleanField(\n        _('staff status'), default=False,\n        help_text=_('Designates whether the user can log into this admin site.'))\n\n    is_active = models.BooleanField(\n        _('active'), default=USERS_AUTO_ACTIVATE,\n        help_text=_('Designates whether this user should be treated as '\n                    'active. Unselect this instead of deleting accounts.'))\n    date_joined = models.DateTimeField(_('date joined'), default=timezone.now)\n    user_type = models.ForeignKey(ContentType, on_delete=models.SET_NULL, null=True, editable=False)\n\n    objects = UserInheritanceManager()\n    base_objects = UserManager()\n\n    USERNAME_FIELD = 'email'\n    REQUIRED_FIELDS = []\n\n    class Meta:\n        verbose_name = _('User')\n        verbose_name_plural = _('Users')\n        abstract = True\n\n    def get_full_name(self):\n        \"\"\" Return the email.\"\"\"\n        return self.email\n\n    def get_short_name(self):\n        \"\"\" Return the email.\"\"\"\n        return self.email\n\n    def email_user(self, subject, message, from_email=None):\n        \"\"\" Send an email to this User.\"\"\"\n        send_mail(subject, message, from_email, [self.email])\n\n    def activate(self):\n        self.is_active = True\n        self.save()\n\n    def save(self, *args, **kwargs):\n        if not self.user_type_id:\n            self.user_type = ContentType.objects.get_for_model(self, for_concrete_model=False)\n        super(AbstractUser, self).save(*args, **kwargs)\n\n\nclass User(AbstractUser):\n\n    \"\"\"\n    Concrete class of AbstractUser.\n    Use this if you don't need to extend User.\n    \"\"\"\n\n    class Meta(AbstractUser.Meta):\n        swappable = 'AUTH_USER_MODEL'\n"
  },
  {
    "path": "users/signals.py",
    "content": "from django.dispatch import Signal\n\n# A new user has registered.\nuser_registered = Signal(providing_args=['user', 'request'])\n\n# A user has activated his or her account.\nuser_activated = Signal(providing_args=['user', 'request'])\n"
  },
  {
    "path": "users/templates/base.html",
    "content": "{% load i18n staticfiles %}<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"utf-8\">\n\t<title>{% block title %}{{ title|default:\"django-users2\"}}{% endblock %}</title>\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<meta name=\"description\" content=\"\">\n\t<meta name=\"author\" content=\"\">\n</head>\n<body>\n\n<div class=\"header navbar\">\n\t<div class=\"container\">\n\t\t<a class=\"navbar-brand\" href=\"/\">Django Users</a>\n\t</div>\n</div>\n<div class=\"container\">\n\t{% if messages %}\n\t\t{% for message in messages %}\n\t\t\t<div class=\"alert {% if message.tags %}alert-{{ message.tags }}\"{% endif %}>{{ message }}</div>\n\t\t{% endfor %}\n\t{% endif %}\n\t{% block content %}\n\t\t<p>Use this template get you up and running with django-users2.</p>\n\t{% endblock content %}\n</div>\n</body>\n</html>\n"
  },
  {
    "path": "users/templates/users/activate.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"Account activation failed\" %}</p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/activation_complete.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"Your account is now activated.\" %}</p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/activation_email.html",
    "content": "{% load i18n %}\n\n{% trans \"Thank you for registering an account at\" %} {{ site.name }}\n{% trans \"To activate your registration, please visit the following page:\" %}\n\n{{ protocol }}://{{ site.domain }}{% url 'users_activate' uid token %}\n\n{% blocktrans %}This link will expire in {{ expiration_days }} days.{% endblocktrans %}\n\n{% trans \"If you didn't register this account you can simply delete this email and we won't bother you again.\" %}\n"
  },
  {
    "path": "users/templates/users/activation_email_subject.html",
    "content": "{% load i18n %}{% trans \"Account activation on\" %} {{ site.name }}\n"
  },
  {
    "path": "users/templates/users/login.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<div class=\"form-wrapper\">\n\t<form method=\"post\" action=\".\">\n\t\t{% if form.errors %}\n\t\t\t{% include \"users/partials/errors.html\" %}\n\t\t{% endif %}\n\t\t{% csrf_token %}\n\t\t{% for field in form %}\n\t\t\t{% include \"users/partials/field.html\" %}\n\t\t{% endfor %}\n\t\t<div class=\"button-wrapper submit\">\n\t\t\t<input type=\"submit\" value=\"{% trans 'Log in' %}\" />\n\t\t</div>\n\t\t<input type=\"hidden\" name=\"next\" value=\"{{ next }}\" />\n\t\t<p><a href=\"{% url 'users_password_reset' %}\">{% trans \"Forgot password\" %}</a></p>\n\t\t<p><a href=\"{% url 'users_register' %}\">{% trans \"Register\" %}</a></p>\n\t</form>\n</div>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/logout.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"Logged out\" %}</p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/partials/errors.html",
    "content": "{% if form.errors and form.non_field_errors %}\n\t<div class=\"form-errors\">\n\t\t<ul>\n\t\t\t{{ form.non_field_errors|unordered_list }}\n\t\t</ul>\n\t</div>\n{% endif %}\n"
  },
  {
    "path": "users/templates/users/partials/field.html",
    "content": "{% load form_tags %}\n\n{% if field.is_hidden %}\n\t{{ field }}\n{% elif field|is_honeypot %}\n\t{% include \"users/partials/honeypot.html\" %}\n{% else %}\n\t<div class=\"field-wrapper {{ field|input_class }} {{ field.css_classes }}{% if field|is_checkbox %} checkbox{% endif %}\">\n\t\t{% if field.errors %}\n\t\t\t<ul class=\"errorlist\">\n\t\t\t\t{{ field.errors|unordered_list }}\n\t\t\t</ul>\n\t\t{% endif %}\n\t\t{% if field|is_checkbox %}\n\t\t\t{{ field }}\n\t\t{% endif %}\n\t\t<label for=\"{{ field.id_for_label }}\"{% if field.field.required %} class=\"required\"{% endif %}>\n\t\t\t{{ field.label }}{% if field.field.required %}<span class=\"asterisk\">*</span>{% endif %}\n\t\t</label>\n\t\t{% if not field|is_checkbox %}\n\t\t\t{{ field }}\n\t\t{% endif %}\n\t\t{% if field.help_text %}\n\t\t\t<div class=\"help_text\">{{ field.help_text|safe }}</div>\n\t\t{% endif %}\n\t</div>\n{% endif %}\n"
  },
  {
    "path": "users/templates/users/partials/honeypot.html",
    "content": "{% load form_tags %}\n\n<div class=\"field-wrapper {{ field|input_class }} {{ field.css_classes }}{% if field|is_checkbox %} checkbox{% endif %}\" style=\"border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px;\">\n\t{% if field.errors %}\n\t\t<ul class=\"errorlist\">\n\t\t\t{{ field.errors|unordered_list }}\n\t\t</ul>\n\t{% endif %}\n\t{% if field|is_checkbox %}\n\t\t{{ field }}\n\t{% endif %}\n\t<label for=\"{{ field.id_for_label }}\">\n\t\t{{ field.label }}\n\t</label>\n\t{% if not field|is_checkbox %}\n\t\t{{ field }}\n\t{% endif %}\n\t{% if field.help_text %}\n\t\t<div class=\"help_text\">{{ field.help_text|safe }}</div>\n\t{% endif %}\n</div>\n"
  },
  {
    "path": "users/templates/users/password_change_done.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"Password changed\" %}</p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_change_form.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<div class=\"form-wrapper\">\n\t<form method=\"post\" action=\".\">\n\t\t{% if form.errors %}\n\t\t\t{% include \"users/partials/errors.html\" %}\n\t\t{% endif %}\n\t\t{% csrf_token %}\n\t\t{% for field in form %}\n\t\t\t{% include \"users/partials/field.html\" %}\n\t\t{% endfor %}\n\t\t<div class=\"button-wrapper submit\">\n\t\t\t<input type=\"submit\" value=\"{% trans 'Change Password' %}\" />\n\t\t</div>\n\t</form>\n</div>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_reset_complete.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"Password reset successfully\" %}</p>\n<p><a href=\"{% url 'users_login' %}\">{% trans \"Log in\" %}</a></p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_reset_confirm.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n{% if validlink %}\n\t<div class=\"form-wrapper\">\n\t\t<form method=\"post\" action=\".\">\n\t\t\t{% if form.errors %}\n\t\t\t\t{% include \"users/partials/errors.html\" %}\n\t\t\t{% endif %}\n\t\t\t{% csrf_token %}\n\t\t\t{% for field in form %}\n\t\t\t\t{% include \"users/partials/field.html\" %}\n\t\t\t{% endfor %}\n\t\t\t<div class=\"button-wrapper submit\">\n\t\t\t\t<input type=\"submit\" value=\"{% trans 'Submit' %}\" />\n\t\t\t</div>\n\t\t</form>\n\t</div>\n{% else %}\n\t<p>{% trans \"Password reset failed\" %}</p>\n{% endif %}\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_reset_done.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"Email with password reset instructions has been sent.\" %}</p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_reset_email.html",
    "content": "{% load i18n %}\n{% blocktrans %}Reset password at {{ site_name }}{% endblocktrans %}:\n{% block reset_link %}\n<a rel=\"noreferrer\" href=\"{{ protocol }}://{{ domain }}{% url 'users_password_reset_confirm' uid token %}\">\n  {{ protocol }}://{{ domain }}{% url 'users_password_reset_confirm' uid token %}\n</a>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_reset_form.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<div class=\"form-wrapper\">\n\t<form method=\"post\" action=\".\">\n\t\t{% if form.errors %}\n\t\t\t{% include \"users/partials/errors.html\" %}\n\t\t{% endif %}\n\t\t{% csrf_token %}\n\t\t{% for field in form %}\n\t\t\t{% include \"users/partials/field.html\" %}\n\t\t{% endfor %}\n\t\t<div class=\"button-wrapper submit\">\n\t\t\t<input type=\"submit\" value=\"{% trans 'Submit' %}\" />\n\t\t</div>\n\t</form>\n</div>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/password_reset_subject.html",
    "content": "{% load i18n %}{% autoescape off %}\n{% blocktrans %}Password reset on {{ site_name }}{% endblocktrans %}\n{% endautoescape %}\n"
  },
  {
    "path": "users/templates/users/registration_closed.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<h1>{% trans \"Sign Up Closed\" %}</h1>\n<p>{% trans \"We are sorry, but the sign up is currently closed.\" %}</p>\n{% endblock %}\n"
  },
  {
    "path": "users/templates/users/registration_complete.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<p>{% trans \"You are now registered. Activation email sent.\" %}</p>\n{% endblock %}"
  },
  {
    "path": "users/templates/users/registration_form.html",
    "content": "{% extends \"base.html\" %}\n{% load i18n %}\n\n{% block content %}\n<div class=\"form-wrapper\">\n\t<form method=\"post\" action=\".\">\n\t\t{% if form.errors %}\n\t\t\t{% include \"users/partials/errors.html\" %}\n\t\t{% endif %}\n\t\t{% csrf_token %}\n\t\t{% for field in form %}\n\t\t\t{% include \"users/partials/field.html\" %}\n\t\t{% endfor %}\n\t\t<div class=\"button-wrapper submit\">\n\t\t\t<input type=\"submit\" value=\"{% trans 'Register' %}\" />\n\t\t</div>\n\t</form>\n</div>\n{% endblock %}\n"
  },
  {
    "path": "users/templatetags/__init__.py",
    "content": ""
  },
  {
    "path": "users/templatetags/form_tags.py",
    "content": "from django import forms, template\n\nfrom users.fields import HoneyPotField\n\nregister = template.Library()\n\n\n@register.filter\ndef is_checkbox(field):\n    return isinstance(field.field.widget, forms.CheckboxInput)\n\n\n@register.filter\ndef input_class(field):\n    \"\"\"\n    Returns widgets class name in lowercase\n    \"\"\"\n    return field.field.widget.__class__.__name__.lower()\n\n\n@register.filter\ndef is_honeypot(field):\n    return isinstance(field.field, HoneyPotField)\n"
  },
  {
    "path": "users/urls.py",
    "content": "from django.conf.urls import url\nfrom django.contrib.auth import views as auth_views\n\nfrom .views import (activate, activation_complete, register,\n                    registration_closed, registration_complete)\n\nurlpatterns = [\n    url(r'^register/$', register, name='users_register'),\n    url(r'^register/closed/$', registration_closed,\n        name='users_registration_closed'),\n    url(r'^register/complete/$', registration_complete,\n        name='users_registration_complete'),\n    url(r'^activate/complete/$', activation_complete,\n        name='users_activation_complete'),\n    url(r'^activate/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',\n        activate, name='users_activate'),\n\n    url(r'^login/$', auth_views.LoginView.as_view(\n        template_name='users/login.html'),\n        name='users_login'),\n    url(r'^logout/$', auth_views.LogoutView.as_view(\n        template_name='users/logout.html'),\n\n        name='users_logout'),\n    url(r'^password_change/$', auth_views.PasswordChangeView.as_view(\n            template_name='users/password_change_form.html',\n            success_url='users_password_change_done'),\n        name='users_password_change'),\n    url(r'^password_change/done/$', auth_views.PasswordChangeDoneView.as_view(\n        template_name='users/password_change_done.html'),\n        name='users_password_change_done'),\n    url(r'^password_reset/$', auth_views.PasswordResetView.as_view(\n            template_name='users/password_reset_form.html',\n            email_template_name='users/password_reset_email.html',\n            subject_template_name='users/password_reset_subject.html',\n            success_url='users_password_reset_done'),\n        name='users_password_reset'),\n    url(r'^password_reset/done/$',\n        auth_views.PasswordResetDoneView.as_view(\n            template_name='users/password_reset_done.html'),\n        name='users_password_reset_done'),\n    url(r'^reset/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',\n        auth_views.PasswordResetConfirmView.as_view(\n            template_name='users/password_reset_confirm.html',\n            success_url='users_password_reset_complete'),\n        name='users_password_reset_confirm'),\n    url(r'^reset/done/$', auth_views.PasswordResetCompleteView.as_view(\n        template_name='users/password_reset_complete.html'),\n        name='users_password_reset_complete'),\n]\n"
  },
  {
    "path": "users/utils.py",
    "content": "from datetime import date\n\nfrom django.contrib.auth import get_user_model\nfrom django.core.mail import EmailMultiAlternatives\nfrom django.template.loader import render_to_string\nfrom django.utils import six\nfrom django.utils.crypto import constant_time_compare, salted_hmac\nfrom django.utils.encoding import force_bytes\nfrom django.utils.http import base36_to_int, int_to_base36\n\nfrom .compat import urlsafe_base64_encode\nfrom .conf import settings\n\ntry:\n    from django.contrib.sites.shortcuts import get_current_site\nexcept ImportError:  # pragma: no cover\n    from django.contrib.sites.models import get_current_site\n\ntry:\n    from django.db.models.signals import post_migrate\nexcept ImportError:  # pragma: no cover\n    from django.db.models.signals import post_syncdb as post_migrate\n\n\nif settings.USERS_CREATE_SUPERUSER:\n    try:\n        # create_superuser is removed in django 1.7\n        from django.contrib.auth.management import create_superuser\n    except ImportError:  # pragma: no cover\n        pass\n    else:\n        # Prevent interactive question about wanting a superuser created.\n        from django.contrib.auth import models as auth_app\n        post_migrate.disconnect(\n            create_superuser,\n            sender=auth_app,\n            dispatch_uid='django.contrib.auth.management.create_superuser')\n\n\ndef auto_create_superuser(sender, **kwargs):\n    if not settings.USERS_CREATE_SUPERUSER:\n        return\n\n    email = settings.USERS_SUPERUSER_EMAIL\n    password = settings.USERS_SUPERUSER_PASSWORD\n\n    User = get_user_model()\n    try:\n        User.base_objects.get(email=email)\n    except User.DoesNotExist:\n        print('Creating superuser ({0}:{1})'.format(email, password))\n        User.objects.create_superuser(email, password)\n\npost_migrate.connect(auto_create_superuser, sender=None)\n\n\nclass EmailActivationTokenGenerator(object):\n\n    def make_token(self, user):\n        return self._make_token_with_timestamp(user, self._num_days(self._today()))\n\n    def check_token(self, user, token):\n        \"\"\"\n        Check that a activation token is correct for a given user.\n        \"\"\"\n        # Parse the token\n        try:\n            ts_b36, hash = token.split('-')\n        except ValueError:\n            return False\n\n        try:\n            ts = base36_to_int(ts_b36)\n        except ValueError:\n            return False\n\n        # Check that the timestamp/uid has not been tampered with\n        if not constant_time_compare(self._make_token_with_timestamp(user, ts), token):\n            return False\n\n        # Check the timestamp is within limit\n        if (self._num_days(self._today()) - ts) > settings.USERS_EMAIL_CONFIRMATION_TIMEOUT_DAYS:\n            return False\n\n        return True\n\n    def _make_token_with_timestamp(self, user, timestamp):\n\n        ts_b36 = int_to_base36(timestamp)\n        key_salt = 'users.utils.EmailActivationTokenGenerator'\n        login_timestamp = '' if user.last_login is None else \\\n            user.last_login.replace(microsecond=0, tzinfo=None)\n        value = (six.text_type(user.pk) + six.text_type(user.email) +\n                 six.text_type(login_timestamp) + six.text_type(timestamp))\n        hash = salted_hmac(key_salt, value).hexdigest()[::2]\n        return '%s-%s' % (ts_b36, hash)\n\n    @staticmethod\n    def _num_days(dt):\n        return (dt - date(2001, 1, 1)).days\n\n    @staticmethod\n    def _today():\n        # Used for mocking in tests\n        return date.today()\n\n\ndef send_activation_email(\n        user=None, request=None, from_email=None,\n        subject_template='users/activation_email_subject.html',\n        email_template='users/activation_email.html', html_email_template=None):\n\n    if not user.is_active and settings.USERS_VERIFY_EMAIL:\n        token_generator = EmailActivationTokenGenerator()\n\n        current_site = get_current_site(request)\n\n        context = {\n            'email': user.email,\n            'site': current_site,\n            'expiration_days': settings.USERS_EMAIL_CONFIRMATION_TIMEOUT_DAYS,\n            'user': user,\n            'uid': urlsafe_base64_encode(force_bytes(user.pk)),\n            'token': token_generator.make_token(user=user),\n            'protocol': 'https' if request.is_secure() else 'http',\n        }\n\n        subject = render_to_string(subject_template, context)\n        # email subject *must not* contain newlines\n        subject = ''.join(subject.splitlines())\n        body = render_to_string(email_template, context)\n\n        email_message = EmailMultiAlternatives(subject, body, from_email, [user.email])\n        if html_email_template is not None:\n            html_email = render_to_string(html_email_template, context)\n            email_message.attach_alternative(html_email, 'text/html')\n\n        email_message.send()\n"
  },
  {
    "path": "users/views.py",
    "content": "from django.contrib import messages\nfrom django.contrib.auth import get_user_model, login\nfrom django.urls import reverse\nfrom django.shortcuts import redirect, resolve_url\nfrom django.template.response import TemplateResponse\nfrom django.utils.translation import ugettext as _\nfrom django.views.decorators.cache import never_cache\nfrom django.views.decorators.csrf import csrf_protect\n\nfrom .compat import urlsafe_base64_decode\nfrom .conf import settings\nfrom .signals import user_activated, user_registered\nfrom .utils import EmailActivationTokenGenerator, send_activation_email\n\ntry:\n    from django.contrib.sites.shortcuts import get_current_site\nexcept ImportError:  # pragma: no cover\n    from django.contrib.sites.models import get_current_site\n\n\nif settings.USERS_SPAM_PROTECTION:  # pragma: no cover\n    from .forms import RegistrationFormHoneypot as RegistrationForm\nelse:\n    from .forms import RegistrationForm\n\n\n@csrf_protect\n@never_cache\ndef register(request,\n             template_name='users/registration_form.html',\n             activation_email_template_name='users/activation_email.html',\n             activation_email_subject_template_name='users/activation_email_subject.html',\n             activation_email_html_template_name=None,\n             registration_form=RegistrationForm,\n             registered_user_redirect_to=None,\n             post_registration_redirect=None,\n             activation_from_email=None,\n             current_app=None,\n             extra_context=None):\n\n    if registered_user_redirect_to is None:\n        registered_user_redirect_to = getattr(settings, 'LOGIN_REDIRECT_URL')\n\n    if request.user.is_authenticated:\n            return redirect(registered_user_redirect_to)\n\n    if not settings.USERS_REGISTRATION_OPEN:\n        return redirect(reverse('users_registration_closed'))\n\n    if post_registration_redirect is None:\n        post_registration_redirect = reverse('users_registration_complete')\n\n    if request.method == 'POST':\n        form = registration_form(request.POST)\n        if form.is_valid():\n            user = form.save()\n            if settings.USERS_AUTO_LOGIN_AFTER_REGISTRATION:\n                user.backend = 'django.contrib.auth.backends.ModelBackend'\n                login(request, user)\n            elif not user.is_active and settings.USERS_VERIFY_EMAIL:\n                opts = {\n                    'user': user,\n                    'request': request,\n                    'from_email': activation_from_email,\n                    'email_template': activation_email_template_name,\n                    'subject_template': activation_email_subject_template_name,\n                    'html_email_template': activation_email_html_template_name,\n                }\n                send_activation_email(**opts)\n                user_registered.send(sender=user.__class__, request=request, user=user)\n            return redirect(post_registration_redirect)\n    else:\n        form = registration_form()\n\n    current_site = get_current_site(request)\n\n    context = {\n        'form': form,\n        'site': current_site,\n        'site_name': current_site.name,\n        'title': _('Register'),\n    }\n\n    if extra_context is not None:  # pragma: no cover\n        context.update(extra_context)\n    return TemplateResponse(request, template_name, context)\n\n\ndef registration_closed(request,\n                        template_name='users/registration_closed.html',\n                        current_app=None,\n                        extra_context=None):\n    context = {\n        'title': _('Registration closed'),\n    }\n    if extra_context is not None:  # pragma: no cover\n        context.update(extra_context)\n    return TemplateResponse(request, template_name, context)\n\n\ndef registration_complete(request,\n                          template_name='users/registration_complete.html',\n                          current_app=None,\n                          extra_context=None):\n    context = {\n        'login_url': resolve_url(settings.LOGIN_URL),\n        'title': _('Registration complete'),\n    }\n    if extra_context is not None:  # pragma: no cover\n        context.update(extra_context)\n    return TemplateResponse(request, template_name, context)\n\n\n@never_cache\ndef activate(request,\n             uidb64=None,\n             token=None,\n             template_name='users/activate.html',\n             post_activation_redirect=None,\n             current_app=None,\n             extra_context=None):\n\n    context = {\n        'title': _('Account activation '),\n    }\n\n    if post_activation_redirect is None:\n        post_activation_redirect = reverse('users_activation_complete')\n\n    UserModel = get_user_model()\n    assert uidb64 is not None and token is not None\n\n    token_generator = EmailActivationTokenGenerator()\n\n    try:\n        uid = urlsafe_base64_decode(uidb64)\n        user = UserModel._default_manager.get(pk=uid)\n    except (TypeError, ValueError, OverflowError, UserModel.DoesNotExist):\n        user = None\n\n    if user is not None and token_generator.check_token(user, token):\n        user.activate()\n        user_activated.send(sender=user.__class__, request=request, user=user)\n        if settings.USERS_AUTO_LOGIN_ON_ACTIVATION:\n            user.backend = 'django.contrib.auth.backends.ModelBackend'  # todo - remove this hack\n            login(request, user)\n            messages.info(request, 'Thanks for registering. You are now logged in.')\n        return redirect(post_activation_redirect)\n    else:\n        title = _('Email confirmation unsuccessful')\n        context = {\n            'title': title,\n        }\n\n    if extra_context is not None:  # pragma: no cover\n        context.update(extra_context)\n    return TemplateResponse(request, template_name, context)\n\n\ndef activation_complete(request,\n                        template_name='users/activation_complete.html',\n                        current_app=None,\n                        extra_context=None):\n    context = {\n        'title': _('Activation complete'),\n    }\n    if extra_context is not None:  # pragma: no cover\n        context.update(extra_context)\n    return TemplateResponse(request, template_name, context)\n"
  }
]