From 996ac1312cf5d57b213cd3c92c67ffa24beb15fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Val=C3=A9rio?= Date: Mon, 14 Oct 2019 13:13:54 +0100 Subject: [PATCH] Remove non-required code and format with black --- .gitignore | 3 + README.rst | 2 +- django_cryptolock/apps.py | 2 +- django_cryptolock/models.py | 3 - django_cryptolock/urls.py | 30 +--- django_cryptolock/views.py | 32 +--- example/example/settings.py | 85 +++++------ example/example/urls.py | 4 +- example/templates/django_cryptolock/base.html | 138 ++++++++---------- runtests.py | 6 +- setup.py | 54 ++++--- tests/settings.py | 7 +- tests/test_models.py | 1 - tests/urls.py | 2 +- 14 files changed, 138 insertions(+), 231 deletions(-) diff --git a/.gitignore b/.gitignore index 6241b02..1d86873 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ docs/_build # Editors .vscode + +# Project specific +example/db.sqlite3 diff --git a/README.rst b/README.rst index d2c0f78..40b4a2b 100644 --- a/README.rst +++ b/README.rst @@ -62,7 +62,7 @@ Does the code actually work? source /bin/activate (myenv) $ pip install tox - (myenv) $ tox + (myenv) $ tox -e -django-22 Credits ------- diff --git a/django_cryptolock/apps.py b/django_cryptolock/apps.py index a77ac37..bdac4ab 100644 --- a/django_cryptolock/apps.py +++ b/django_cryptolock/apps.py @@ -3,4 +3,4 @@ from django.apps import AppConfig class DjangoCryptolockConfig(AppConfig): - name = 'django_cryptolock' + name = "django_cryptolock" diff --git a/django_cryptolock/models.py b/django_cryptolock/models.py index 21921b8..d54eaa4 100644 --- a/django_cryptolock/models.py +++ b/django_cryptolock/models.py @@ -7,6 +7,3 @@ from model_utils.models import TimeStampedModel class Address(TimeStampedModel): pass - - - diff --git a/django_cryptolock/urls.py b/django_cryptolock/urls.py index 1bc7ebd..c20046a 100644 --- a/django_cryptolock/urls.py +++ b/django_cryptolock/urls.py @@ -5,31 +5,5 @@ from django.views.generic import TemplateView from . import views -app_name = 'django_cryptolock' -urlpatterns = [ - url( - regex="^Address/~create/$", - view=views.AddressCreateView.as_view(), - name='Address_create', - ), - url( - regex="^Address/(?P\d+)/~delete/$", - view=views.AddressDeleteView.as_view(), - name='Address_delete', - ), - url( - regex="^Address/(?P\d+)/$", - view=views.AddressDetailView.as_view(), - name='Address_detail', - ), - url( - regex="^Address/(?P\d+)/~update/$", - view=views.AddressUpdateView.as_view(), - name='Address_update', - ), - url( - regex="^Address/$", - view=views.AddressListView.as_view(), - name='Address_list', - ), - ] +app_name = "django_cryptolock" +urlpatterns = [] diff --git a/django_cryptolock/views.py b/django_cryptolock/views.py index 7b16b14..d52d966 100644 --- a/django_cryptolock/views.py +++ b/django_cryptolock/views.py @@ -4,35 +4,7 @@ from django.views.generic import ( DeleteView, DetailView, UpdateView, - ListView + ListView, ) -from .models import ( - Address, -) - - -class AddressCreateView(CreateView): - - model = Address - - -class AddressDeleteView(DeleteView): - - model = Address - - -class AddressDetailView(DetailView): - - model = Address - - -class AddressUpdateView(UpdateView): - - model = Address - - -class AddressListView(ListView): - - model = Address - +from .models import Address diff --git a/example/example/settings.py b/example/example/settings.py index 3a32ef0..2d0e868 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -29,57 +29,54 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - - 'django_cryptolock', - + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django_cryptolock", # if your app has other dependencies that need to be added to the site # they should be added here ] -MIDDLEWARE_CLASSES = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'example.urls' +ROOT_URLCONF = "example.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates'), ], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [os.path.join(BASE_DIR, "templates")], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ] }, - }, + } ] -WSGI_APPLICATION = 'example.wsgi.application' +WSGI_APPLICATION = "example.wsgi.application" # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), } } @@ -88,25 +85,19 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" }, + {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"}, + {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"}, + {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"}, ] # Internationalization # https://docs.djangoproject.com/en/1.9/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -117,4 +108,4 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ -STATIC_URL = '/static/' +STATIC_URL = "/static/" diff --git a/example/example/urls.py b/example/example/urls.py index 6651818..9d14463 100644 --- a/example/example/urls.py +++ b/example/example/urls.py @@ -18,6 +18,6 @@ from django.contrib import admin urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'', include('django_cryptolock.urls', namespace='django_cryptolock')), + url(r"^admin/", admin.site.urls), + url(r"", include("django_cryptolock.urls", namespace="django_cryptolock")), ] diff --git a/example/templates/django_cryptolock/base.html b/example/templates/django_cryptolock/base.html index c70e9be..92f8e45 100644 --- a/example/templates/django_cryptolock/base.html +++ b/example/templates/django_cryptolock/base.html @@ -1,88 +1,66 @@ -{% load staticfiles i18n %} - - - - - {% block title %}Django-Cryptolock{% endblock title %} - - - +{% load staticfiles i18n %} + + + + + + {% block title %}Django-Cryptolock{% endblock title %} + + + - - + + - {% block css %} - - + {% block css %} {% endblock %} + - - - {% endblock %} - - - - -
- -
-
+
+ {% if messages %} {% for message in messages %} +
+ {{ message }} +
+ {% endfor %} {% endif %} + + {% block content %} +
+

Use this document as a way to quick start any new project.

+

+ The current template is loaded from + django-cryptolock/example/templates/base.html. +

+

+ Whenever you overwrite the contents of + django-cryptolock/django_cryptolock/urls.py with your own + content, you should see it here. +

+
+ {% endblock content %} +
- {% if messages %} - {% for message in messages %} -
{{ message }}
- {% endfor %} - {% endif %} + {% block modal %}{% endblock modal %} - {% block content %} -
-

Use this document as a way to quick start any new project.

-

The current template is loaded from - django-cryptolock/example/templates/base.html.

-

Whenever you overwrite the contents of django-cryptolock/django_cryptolock/urls.py with your - own content, you should see it here.

-
- {% endblock content %} - -
- -{% block modal %}{% endblock modal %} - - - -{% block javascript %} - - - - - - - - - - - -{% endblock javascript %} - + + + {% block javascript %} {% endblock javascript %} + - diff --git a/runtests.py b/runtests.py index a68cf32..035a375 100644 --- a/runtests.py +++ b/runtests.py @@ -12,9 +12,9 @@ from django.test.utils import get_runner def run_tests(*test_args): if not test_args: - test_args = ['tests'] + test_args = ["tests"] - os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' + os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings" django.setup() TestRunner = get_runner(settings) test_runner = TestRunner() @@ -22,5 +22,5 @@ def run_tests(*test_args): sys.exit(bool(failures)) -if __name__ == '__main__': +if __name__ == "__main__": run_tests(*sys.argv[1:]) diff --git a/setup.py b/setup.py index 0f6f118..0169be9 100755 --- a/setup.py +++ b/setup.py @@ -14,61 +14,59 @@ def get_version(*file_paths): """Retrieves the version from django_cryptolock/__init__.py""" filename = os.path.join(os.path.dirname(__file__), *file_paths) version_file = open(filename).read() - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: return version_match.group(1) - raise RuntimeError('Unable to find version string.') + raise RuntimeError("Unable to find version string.") version = get_version("django_cryptolock", "__init__.py") -if sys.argv[-1] == 'publish': +if sys.argv[-1] == "publish": try: import wheel + print("Wheel version: ", wheel.__version__) except ImportError: print('Wheel library missing. Please run "pip install wheel"') sys.exit() - os.system('python setup.py sdist upload') - os.system('python setup.py bdist_wheel upload') + os.system("python setup.py sdist upload") + os.system("python setup.py bdist_wheel upload") sys.exit() -if sys.argv[-1] == 'tag': +if sys.argv[-1] == "tag": print("Tagging the version on git:") os.system("git tag -a %s -m 'version %s'" % (version, version)) os.system("git push --tags") sys.exit() -readme = open('README.rst').read() -history = open('HISTORY.rst').read().replace('.. :changelog:', '') +readme = open("README.rst").read() +history = open("HISTORY.rst").read().replace(".. :changelog:", "") setup( - name='django-cryptolock', + name="django-cryptolock", version=version, description="""Django authentication using cryptocurrency wallets""", - long_description=readme + '\n\n' + history, - author='Gonçalo Valério', - author_email='gon@ovalerio.net', - url='https://github.com/dethos/django-cryptolock', - packages=[ - 'django_cryptolock', - ], + long_description=readme + "\n\n" + history, + author="Gonçalo Valério", + author_email="gon@ovalerio.net", + url="https://github.com/dethos/django-cryptolock", + packages=["django_cryptolock"], include_package_data=True, - install_requires=["django-model-utils>=2.0",], + install_requires=["django-model-utils>=2.0"], license="MIT", zip_safe=False, - keywords='django-cryptolock', + keywords="django-cryptolock", classifiers=[ - 'Development Status :: 3 - Alpha', - 'Framework :: Django :: 2.2', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', + "Development Status :: 3 - Alpha", + "Framework :: Django :: 2.2", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ], ) diff --git a/tests/settings.py b/tests/settings.py index 102c0df..3997583 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -9,12 +9,7 @@ USE_TZ = True # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = "!z^^097u*@)yq#w1n14m%uh-l67#h&uft9p+m%$$(0y(s%-q7o" -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": ":memory:", - } -} +DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}} ROOT_URLCONF = "tests.urls" diff --git a/tests/test_models.py b/tests/test_models.py index 4de7a99..089a8fc 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -14,7 +14,6 @@ from django_cryptolock import models class TestDjango_cryptolock(TestCase): - def setUp(self): pass diff --git a/tests/urls.py b/tests/urls.py index e49b024..99d679c 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -5,5 +5,5 @@ from django.conf.urls import url, include urlpatterns = [ - url(r'^', include('django_cryptolock.urls', namespace='django_cryptolock')), + url(r"^", include("django_cryptolock.urls", namespace="django_cryptolock")) ]