diff --git a/.gitignore b/.gitignore index 7d8d699..894a44c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,35 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] +*$py.class # C extensions *.so # Distribution / packaging .Python -env/ -bin/ build/ develop-eggs/ dist/ +downloads/ eggs/ +.eggs/ lib/ lib64/ parts/ sdist/ var/ +wheels/ *.egg-info/ .installed.cfg *.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec # Installer logs pip-log.txt @@ -30,28 +39,66 @@ pip-delete-this-directory.txt htmlcov/ .tox/ .coverage +.coverage.* .cache nosetests.xml coverage.xml -coverage_html +*.cover +.hypothesis/ +.pytest_cache/ -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Rope -.ropeproject +# Translations +*.mo +*.pot # Django stuff: *.log -*.pot +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy # Sphinx documentation docs/_build/ -.DS_Store -db.sqlite3 +# PyBuilder +target/ -# IntelliJ IDE files -.idea +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/.travis.yml b/.travis.yml index b05a3f7..b059c1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,10 @@ python: - "3.5" - "3.6" env: - - DJANGO=1.8.* DRF=3.6.* - DJANGO=1.11.* DRF=3.7.* + - DJANGO=1.11.* DRF=3.8.* - DJANGO=2.0.* DRF=3.7.* + - DJANGO=2.0.* DRF=3.8.* install: - pip install -q Django==$DJANGO djangorestframework==$DRF - pip install coveralls @@ -21,3 +22,5 @@ matrix: exclude: - python: "2.7" env: DJANGO=2.0.* DRF=3.7.* + - python: "2.7" + env: DJANGO=2.0.* DRF=3.8.* diff --git a/docs/conf.py b/docs/conf.py index faba401..c8ecb3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,16 +44,16 @@ master_doc = 'index' # General information about the project. project = u'django-rest-auth' -copyright = u'2014, Tivix Inc.' +copyright = u'2018, Tivix Inc.' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.3.0' +version = '0.9.3' # The full version, including alpha/beta/rc tags. -release = '0.3.0' +release = '0.9.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/flake8 b/flake8 deleted file mode 100644 index 401fdf4..0000000 --- a/flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 120 -exclude = docs/*,demo/* -ignore = F403 \ No newline at end of file diff --git a/rest_auth/locale/cs/LC_MESSAGES/django.mo b/rest_auth/locale/cs/LC_MESSAGES/django.mo new file mode 100644 index 0000000..3dd71df Binary files /dev/null and b/rest_auth/locale/cs/LC_MESSAGES/django.mo differ diff --git a/rest_auth/locale/cs/LC_MESSAGES/django.po b/rest_auth/locale/cs/LC_MESSAGES/django.po new file mode 100644 index 0000000..eb8c60c --- /dev/null +++ b/rest_auth/locale/cs/LC_MESSAGES/django.po @@ -0,0 +1,102 @@ +# Czech translations of Tivix/django-rest-auth +# +# This file is distributed under the same license as the Tivix/django-rest-auth package. +# +msgid "" +msgstr "" +"Project-Id-Version: Tivix/django-rest-auth\n" +"Report-Msgid-Bugs-To: https://github.com/Tivix/django-rest-auth/issues\n" +"POT-Creation-Date: 2018-06-27 23:05+0200\n" +"PO-Revision-Date: 2018-06-27 23:22+0200\n" +"Language: cs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" +"Last-Translator: Václav Dohnal \n" +"Language-Team: N/A\n" +"X-Generator: Poedit 2.0.8\n" + +#: .\registration\serializers.py:67 +msgid "View is not defined, pass it as a context variable" +msgstr "View není definováno, předejte jej jako proměnnou kontextu" + +#: .\registration\serializers.py:72 +msgid "Define adapter_class in view" +msgstr "Definujte adapter_class ve view" + +#: .\registration\serializers.py:91 +msgid "Define callback_url in view" +msgstr "Definujte callback_url ve view" + +#: .\registration\serializers.py:95 +msgid "Define client_class in view" +msgstr "Definujte client_class ve view" + +#: .\registration\serializers.py:116 +msgid "Incorrect input. access_token or code is required." +msgstr "Nesprávný vstup. access_token je povinný." + +#: .\registration\serializers.py:125 +msgid "Incorrect value" +msgstr "Nesprávná hodnota" + +#: .\registration\serializers.py:139 +msgid "User is already registered with this e-mail address." +msgstr "Uživatel s touto adresou je již registrován." + +#: .\registration\serializers.py:185 +msgid "A user is already registered with this e-mail address." +msgstr "Uživatel s touto adresou je již registrován." + +#: .\registration\serializers.py:193 +msgid "The two password fields didn't match." +msgstr "Zadaná hesla se neshodují." + +#: .\registration\views.py:51 +msgid "Verification e-mail sent." +msgstr "Ověřovací e-mail odeslán." + +#: .\registration\views.py:98 +msgid "ok" +msgstr "ok" + +#: .\serializers.py:30 +msgid "Must include \"email\" and \"password\"." +msgstr "Musí obsahovat \"e-mail\" a \"heslo\"." + +#: .\serializers.py:41 +msgid "Must include \"username\" and \"password\"." +msgstr "Musí obsahovat \"uživatelské jméno\" a \"heslo\"." + +#: .\serializers.py:54 +msgid "Must include either \"username\" or \"email\" and \"password\"." +msgstr "Musí obsahovat \"uživatelské jméno\" nebo \"e-mail\" a \"heslo\"." + +#: .\serializers.py:95 +msgid "User account is disabled." +msgstr "Uživatelský účet je zakázán." + +#: .\serializers.py:98 +msgid "Unable to log in with provided credentials." +msgstr "Pomocí zadaných údajů se nelze přihlásit." + +#: .\serializers.py:107 +msgid "E-mail is not verified." +msgstr "E-mail není ověřený." + +#: .\views.py:127 +msgid "Successfully logged out." +msgstr "Byli jste úspěšně odhlášeni." + +#: .\views.py:175 +msgid "Password reset e-mail has been sent." +msgstr "E-mail pro resetování hesla byl odeslán." + +#: .\views.py:201 +msgid "Password has been reset with the new password." +msgstr "Vaše heslo bylo resetováno." + +#: .\views.py:223 +msgid "New password has been saved." +msgstr "Nové heslo bylo uloženo." diff --git a/rest_auth/serializers.py b/rest_auth/serializers.py index 16eb5a9..2a49f96 100644 --- a/rest_auth/serializers.py +++ b/rest_auth/serializers.py @@ -21,11 +21,14 @@ class LoginSerializer(serializers.Serializer): email = serializers.EmailField(required=False, allow_blank=True) password = serializers.CharField(style={'input_type': 'password'}) + def authenticate(self, **kwargs): + return authenticate(self.context['request'], **kwargs) + def _validate_email(self, email, password): user = None if email and password: - user = authenticate(email=email, password=password) + user = self.authenticate(email=email, password=password) try: username = UserModel.objects.get(email__iexact=email).get_username() user = authenticate(username=username, password=password) @@ -42,7 +45,7 @@ class LoginSerializer(serializers.Serializer): user = None if username and password: - user = authenticate(username=username, password=password) + user = self.authenticate(username=username, password=password) else: msg = _('Must include "username" and "password".') raise exceptions.ValidationError(msg) @@ -53,7 +56,7 @@ class LoginSerializer(serializers.Serializer): user = None if email and password: - user = authenticate(email=email, password=password) + user = self.authenticate(email=email, password=password) try: username = UserModel.objects.get(email__iexact=email).get_username() user = authenticate(username=username, password=password) @@ -61,7 +64,7 @@ class LoginSerializer(serializers.Serializer): msg = _('Unable to log in with provided credentials.') raise exceptions.ValidationError(msg) elif username and password: - user = authenticate(username=username, password=password) + user = self.authenticate(username=username, password=password) else: msg = _('Must include either "username" or "email" and "password".') raise exceptions.ValidationError(msg) diff --git a/.coveragerc b/setup.cfg similarity index 70% rename from .coveragerc rename to setup.cfg index 70d6d0d..8d915a7 100644 --- a/.coveragerc +++ b/setup.cfg @@ -1,8 +1,21 @@ -# .coveragerc to control coverage.py -[run] +[bdist_wheel] +universal = 1 + + +[metadata] +license_file = LICENSE + + +[flake8] +max-line-length = 120 +exclude = docs/*,demo/* +ignore = F403 + + +[coverage:run] omit=*site-packages*,*distutils*,*migrations* -[report] +[coverage:report] # Regexes for lines to exclude from consideration exclude_lines = # Have to re-enable the standard pragma @@ -22,5 +35,5 @@ exclude_lines = ignore_errors = True -[html] -directory = coverage_html \ No newline at end of file +[coverage:html] +directory = coverage_html diff --git a/setup.py b/setup.py index 2c9dad4..66c4c04 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,8 @@ #!/usr/bin/env python -try: - from setuptools import setup, find_packages -except ImportError: - from ez_setup import use_setuptools - use_setuptools() - from setuptools import setup, find_packages - - import os +from setuptools import setup, find_packages + here = os.path.dirname(os.path.abspath(__file__)) f = open(os.path.join(here, 'README.rst'))