PK!1 AUTHORS.rst======= Credits ======= Development Lead ---------------- * Federico Jaramillo Martínez Contributors ------------ None yet. Why not be the first? PK!\7* * CONTRIBUTING.rst============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Types of Contributions ---------------------- Report Bugs ~~~~~~~~~~~ Report bugs at https://github.com/jmfederico/django-use-email-as-username/issues. If you are reporting a bug, please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. Fix Bugs ~~~~~~~~ Look through the GitHub issues for bugs. Anything tagged with "bug" is open to whoever wants to implement it. Implement Features ~~~~~~~~~~~~~~~~~~ Look through the GitHub issues for features. Anything tagged with "feature" is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ Django use Email as Username could always use more documentation, whether as part of the official Django use Email as Username docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ The best way to send feedback is to file an issue at https://github.com/jmfederico/django-use-email-as-username/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ------------ Ready to contribute? Here's how to set up `django-use-email-as-username` for local development. 1. Fork the `django-use-email-as-username` repo on GitHub. 2. Clone your fork locally:: $ git clone https://github.com/YOUR_NAME_HERE/django-use-email-as-username.git 3. Install for local development:: $ cd django-use-email-as-username/ $ poetry install 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you're done making changes, run the tests, adding new as required:: $ make test-all 6. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. Make sure that the tests pass for all supported Python versions, check https://travis-ci.org/jmfederico/django-use-email-as-username/pull_requests PK!.* HISTORY.rst.. :changelog: History ------- 1.0.1 (2018-12-30) ++++++++++++++++++ * Add tests for Python 3.7 * Add tests for Django 2.1 * Remove Pipenv * Change packaging and dependency manager to Poetry 1.0.0 (2018-02-18) ++++++++++++++++++ * First release on PyPI. PK!I"tLICENSEThe Clear BSD License Copyright (c) 2018 Federico Jaramillo Martínez All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK!ȏ README.rst============================ Django use Email as Username ============================ .. image:: https://badge.fury.io/py/django-use-email-as-username.svg :target: https://badge.fury.io/py/django-use-email-as-username .. image:: https://travis-ci.org/jmfederico/django-use-email-as-username.svg?branch=master :target: https://travis-ci.org/jmfederico/django-use-email-as-username .. image:: https://codecov.io/gh/jmfederico/django-use-email-as-username/branch/master/graph/badge.svg :target: https://codecov.io/gh/jmfederico/django-use-email-as-username A Django app to use email as username for user authentication. Features -------- * Custom User model with no username field * Use email as username * Includes a django-admin command for quick install * Follow Django `best practices`_ for new Django projects and User models. .. _`best practices`: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project Quickstart ---------- 1. Install **Django use Email as Username**:: $ pip install django-use-email-as-username 2. Add it to your *INSTALLED_APPS*:: INSTALLED_APPS = ( ... 'django_use_email_as_username.apps.DjangoUseEmailAsUsernameConfig', ... ) 3. Create you new django app:: $ python manage.py create_custom_user_app 4. Add the new app to your *INSTALLED_APPS*:: INSTALLED_APPS = ( ... 'django_use_email_as_username.apps.DjangoUseEmailAsUsernameConfig', 'custom_user.apps.CustomUserConfig', ... ) 5. Now instruct Django to use your new model:: AUTH_USER_MODEL = 'custom_user.User' 6. Create and run migrations:: $ python manage.py makemigrations $ python manage.py migrate You now have a new Django app which provides a custom User model. You can further modify the new User Model any time in the future, just remember to create and run the migrations. Notes ----- This app gives you a custom User model, which is `good practice`_ for new Django projects. `Changing to a custom user model mid-project`_ is not easy. .. _`good practice`: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project .. _`Changing to a custom user model mid-project`: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#changing-to-a-custom-user-model-mid-project It is recommended to always create a custom User model at the beginning of every Django project. Credits ------- Tools used in rendering this package: * Cookiecutter_ * `Cookiecutter Django Package`_ by jmfederico_ .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`Cookiecutter Django Package`: https://github.com/jmfederico/cookiecutter-djangopackage .. _jmfederico: https://github.com/jmfederico PK!Bs(django_use_email_as_username/__init__.py__version__ = '1.0.1' PK!U %django_use_email_as_username/admin.py"""Integrate DjangoUseEmailAsUsername with admin module.""" from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin from django.utils.translation import ugettext_lazy as _ class BaseUserAdmin(DjangoUserAdmin): """Define admin model for custom User model with no email field.""" fieldsets = ( (None, { 'fields': ('email', 'password') }), (_('Personal info'), { 'fields': ('first_name', 'last_name') }), (_('Permissions'), { 'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions') }), (_('Important dates'), { 'fields': ('last_login', 'date_joined') }), ) add_fieldsets = ((None, { 'classes': ('wide', ), 'fields': ('email', 'password1', 'password2'), }), ) list_display = ('email', 'first_name', 'last_name', 'is_staff') search_fields = ('email', 'first_name', 'last_name') ordering = ('email', ) PK!{$django_use_email_as_username/apps.pyfrom django.apps import AppConfig class DjangoUseEmailAsUsernameConfig(AppConfig): name = 'django_use_email_as_username' PK!Mdjango_use_email_as_username/management/commands/app_template/__init__.py-tplPK!UVJdjango_use_email_as_username/management/commands/app_template/admin.py-tplfrom django.contrib import admin from django_use_email_as_username.admin import BaseUserAdmin from .models import User admin.site.register(User, BaseUserAdmin) PK!qIIdjango_use_email_as_username/management/commands/app_template/apps.py-tplfrom django.apps import AppConfig class {{ camel_case_app_name }}Config(AppConfig): name = '{{ app_name }}' verbose_name = 'Custom User Management' PK!Xdjango_use_email_as_username/management/commands/app_template/migrations/__init__.py-tplPK!qKdjango_use_email_as_username/management/commands/app_template/models.py-tplfrom django_use_email_as_username.models import BaseUser, BaseUserManager class User(BaseUser): objects = BaseUserManager() PK!DVFJdjango_use_email_as_username/management/commands/create_custom_user_app.py"""Define create_emailuser_app command.""" import os from django.core.management import call_command from django.core.management.templates import BaseCommand class Command(BaseCommand): """Define create_emailuser_app command.""" help = ("Creates a Django app hat subclasses the User model declared by Django Use Email as Username.") def add_arguments(self, parser): """Define arguments for create_emailuser_app command.""" parser.add_argument( 'name', nargs='?', default='custom_user', help='Optional name of the application or project. [custom_user]') parser.add_argument('directory', nargs='?', help='Optional destination directory') def handle(self, **options): """Call "startapp" to generate app with custom user model.""" template = os.path.dirname(os.path.abspath(__file__)) + '/app_template' name = options.pop('name') call_command('startapp', name, template=template, **options) PK!Tԇ&django_use_email_as_username/models.py"""Declare models for DjangoUseEmailAsUsername app.""" from django.contrib.auth.models import AbstractUser, BaseUserManager from django.db import models from django.utils.translation import ugettext_lazy as _ class BaseUserManager(BaseUserManager): """Define a model manager for User model with no username field.""" use_in_migrations = True def _create_user(self, email, password, **extra_fields): """Create and save a User with the given email and password.""" if not email: raise ValueError('The given email must be set') email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_user(self, email, password=None, **extra_fields): """Create and save a regular User with the given email and password.""" extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(email, password, **extra_fields) def create_superuser(self, email, password, **extra_fields): """Create and save a SuperUser with the given email and password.""" extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) if extra_fields.get('is_staff') is not True: raise ValueError('Superuser must have is_staff=True.') if extra_fields.get('is_superuser') is not True: raise ValueError('Superuser must have is_superuser=True.') return self._create_user(email, password, **extra_fields) class BaseUser(AbstractUser): """User model.""" username = None email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: """Define Meta class for BaseUser model.""" abstract = True PK!I"t4django_use_email_as_username-1.0.1.dist-info/LICENSEThe Clear BSD License Copyright (c) 2018 Federico Jaramillo Martínez All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK!HnHTU2django_use_email_as_username-1.0.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!HL'q5django_use_email_as_username-1.0.1.dist-info/METADATAWr6}WL;#q3:*ҙ> QI@9?+c/E/"=Τp"Ct1|\!E@Bea eWU Sa,i@ ,t0\N¡5\Hܹ0Un^My.Dp+S¢_&~0ɍ3) M$od6C8nˆ\e3a?C+ԸB쮓NiKWE:7`j$ȅtcJ WYpatRŔ7\;Fú'ۧ=%r/غ" D"^ &ۖ$!%LF!=Mm)cvWH<*LIntM?U¸Nf# PJf lr'EU R$؟ݓ"{Pu"PXEt;AiX(Ehor_2׉-oP6|S"L"tT )Ua>` ,"h}1xqDk;wS8&ȇ :|ww8d1C.Yo%QrDZWvOίGGhtqq[]_Cx;]D_$lw%r& c.{3 >}cҗ6ټw3ő6؛!:QS#BVwVp7M¶dpA 0x麠mz%Eم7~\]Fg&Gߚwr I\+Z4"2^.?)%R1XFB=U<^fjďgoLĢ&i1訠 nGE2`%)F̟ 1ѐWsCD*E|O :raqJ* Z5 XQTRgj-hkبzKb_PK!Hb]3django_use_email_as_username-1.0.1.dist-info/RECORD͕˲H> "E/* \M"HAqӏ=v83m,3̬G?pN(N*^BH@!pKcΰȉIЋ FBvlեիsc )USC-꨾5q Ѧ"%F XdpXfYv:/QvyZvV45vKR(FXltY=yݺ4)M2n+NlEE}6T8XX+U ŊqMBPΧ,*iLCr5HA$0@ٔ#$"﻽5hѰH$KxPO2X6/U:(/>\{}RYғQl<*A-&q=Tٵblg'Ea 1z &)r7㷴(~1NƿQXrC#1|2谢ޤEgq_@NbKXUG{Ӷ|O5]|!nWb${ +@}0J&ʔ1A3*qփz,>˶ m,H83\%)Rff{S@Hai[Qzȳ(YvVd@/vdo oI>+ۆWsf+Q)79f`g[S"H;Mx3x8A|Y9xٜo_]eUuUSOoccwPb{ S" u*"A2EN.q3Q^1nAF {n*;a?PK!1 AUTHORS.rstPK!\7* * CONTRIBUTING.rstPK!.* 7 HISTORY.rstPK!I"tc LICENSEPK!ȏ ,README.rstPK!Bs(]django_use_email_as_username/__init__.pyPK!U %django_use_email_as_username/admin.pyPK!{$#django_use_email_as_username/apps.pyPK!M큢$django_use_email_as_username/management/commands/app_template/__init__.py-tplPK!UVJ %django_use_email_as_username/management/commands/app_template/admin.py-tplPK!qII&django_use_email_as_username/management/commands/app_template/apps.py-tplPK!X'django_use_email_as_username/management/commands/app_template/migrations/__init__.py-tplPK!qK큒'django_use_email_as_username/management/commands/app_template/models.py-tplPK!DVFJ}(django_use_email_as_username/management/commands/create_custom_user_app.pyPK!Tԇ&,django_use_email_as_username/models.pyPK!I"t44django_use_email_as_username-1.0.1.dist-info/LICENSEPK!HnHTU2;django_use_email_as_username-1.0.1.dist-info/WHEELPK!HL'q5@<django_use_email_as_username-1.0.1.dist-info/METADATAPK!Hb]3Adjango_use_email_as_username-1.0.1.dist-info/RECORDPKmE