Remove non-required code and format with black

This commit is contained in:
Gonçalo Valério 2019-10-14 13:13:54 +01:00
parent 811e87ff09
commit 996ac1312c
14 changed files with 138 additions and 231 deletions

3
.gitignore vendored
View File

@ -48,3 +48,6 @@ docs/_build
# Editors # Editors
.vscode .vscode
# Project specific
example/db.sqlite3

View File

@ -62,7 +62,7 @@ Does the code actually work?
source <YOURVIRTUALENV>/bin/activate source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox (myenv) $ pip install tox
(myenv) $ tox (myenv) $ tox -e <your-python-version>-django-22
Credits Credits
------- -------

View File

@ -3,4 +3,4 @@ from django.apps import AppConfig
class DjangoCryptolockConfig(AppConfig): class DjangoCryptolockConfig(AppConfig):
name = 'django_cryptolock' name = "django_cryptolock"

View File

@ -7,6 +7,3 @@ from model_utils.models import TimeStampedModel
class Address(TimeStampedModel): class Address(TimeStampedModel):
pass pass

View File

@ -5,31 +5,5 @@ from django.views.generic import TemplateView
from . import views from . import views
app_name = 'django_cryptolock' app_name = "django_cryptolock"
urlpatterns = [ urlpatterns = []
url(
regex="^Address/~create/$",
view=views.AddressCreateView.as_view(),
name='Address_create',
),
url(
regex="^Address/(?P<pk>\d+)/~delete/$",
view=views.AddressDeleteView.as_view(),
name='Address_delete',
),
url(
regex="^Address/(?P<pk>\d+)/$",
view=views.AddressDetailView.as_view(),
name='Address_detail',
),
url(
regex="^Address/(?P<pk>\d+)/~update/$",
view=views.AddressUpdateView.as_view(),
name='Address_update',
),
url(
regex="^Address/$",
view=views.AddressListView.as_view(),
name='Address_list',
),
]

View File

@ -4,35 +4,7 @@ from django.views.generic import (
DeleteView, DeleteView,
DetailView, DetailView,
UpdateView, UpdateView,
ListView ListView,
) )
from .models import ( from .models import Address
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

View File

@ -29,57 +29,54 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', "django.contrib.admin",
'django.contrib.auth', "django.contrib.auth",
'django.contrib.contenttypes', "django.contrib.contenttypes",
'django.contrib.sessions', "django.contrib.sessions",
'django.contrib.messages', "django.contrib.messages",
'django.contrib.staticfiles', "django.contrib.staticfiles",
"django_cryptolock",
'django_cryptolock',
# if your app has other dependencies that need to be added to the site # if your app has other dependencies that need to be added to the site
# they should be added here # they should be added here
] ]
MIDDLEWARE_CLASSES = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', "django.middleware.security.SecurityMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware', "django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.common.CommonMiddleware', "django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware', "django.middleware.csrf.CsrfViewMiddleware",
'django.contrib.auth.middleware.AuthenticationMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware",
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', "django.contrib.messages.middleware.MessageMiddleware",
'django.contrib.messages.middleware.MessageMiddleware', "django.middleware.clickjacking.XFrameOptionsMiddleware",
'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
ROOT_URLCONF = 'example.urls' ROOT_URLCONF = "example.urls"
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', "BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [os.path.join(BASE_DIR, 'templates'), ], "DIRS": [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True, "APP_DIRS": True,
'OPTIONS': { "OPTIONS": {
'context_processors': [ "context_processors": [
'django.template.context_processors.debug', "django.template.context_processors.debug",
'django.template.context_processors.request', "django.template.context_processors.request",
'django.contrib.auth.context_processors.auth', "django.contrib.auth.context_processors.auth",
'django.contrib.messages.context_processors.messages', "django.contrib.messages.context_processors.messages",
], ]
}, },
}, }
] ]
WSGI_APPLICATION = 'example.wsgi.application' WSGI_APPLICATION = "example.wsgi.application"
# Database # Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.db.backends.sqlite3', "ENGINE": "django.db.backends.sqlite3",
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
} }
} }
@ -88,25 +85,19 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', "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.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
] ]
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/ # 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 USE_I18N = True
@ -117,4 +108,4 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/ # https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = "/static/"

View File

@ -18,6 +18,6 @@ from django.contrib import admin
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r"^admin/", admin.site.urls),
url(r'', include('django_cryptolock.urls', namespace='django_cryptolock')), url(r"", include("django_cryptolock.urls", namespace="django_cryptolock")),
] ]

View File

@ -1,88 +1,66 @@
{% load staticfiles i18n %}<!DOCTYPE html> {% load staticfiles i18n %}
<html lang="en" > <!DOCTYPE html>
<head> <html lang="en">
<meta charset="utf-8"> <head>
<meta http-equiv="x-ua-compatible" content="ie=edge"> <meta charset="utf-8" />
<title>{% block title %}Django-Cryptolock{% endblock title %}</title> <meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %}Django-Cryptolock{% endblock title %}</title>
<meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content=""> <meta name="description" content="" />
<meta name="author" content="" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script> <script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
{% block css %} {% block css %} {% endblock %}
<!-- Latest compiled and minified CSS --> </head>
<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css">
<!-- Your stuff: Third-party css libraries go here --> <body>
<div class="m-b">
{% endblock %} <nav>
</head> <div>
<div>
<body> <ul>
<li>
<div class="m-b"> <a href="/">Home</a>
<nav class="navbar navbar-dark navbar-static-top bg-inverse"> </li>
<div class="container"> </ul>
<a class="navbar-brand" href="/">django-cryptolock</a> </div>
<button type="button" class="navbar-toggler hidden-sm-up pull-xs-right" data-toggle="collapse" </div>
data-target="#bs-navbar-collapse-1"> </nav>
&#9776;
</button>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-toggleable-xs" id="bs-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
</ul>
</div>
</div> </div>
</nav>
</div>
<div class="container"> <div>
{% if messages %} {% for message in messages %}
<div
class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}"
>
{{ message }}
</div>
{% endfor %} {% endif %}
<!-- Page content -->
{% block content %}
<div>
<p>Use this document as a way to quick start any new project.</p>
<p>
The current template is loaded from
<code>django-cryptolock/example/templates/base.html</code>.
</p>
<p>
Whenever you overwrite the contents of
<code>django-cryptolock/django_cryptolock/urls.py</code> with your own
content, you should see it here.
</p>
</div>
{% endblock content %}
</div>
{% if messages %} {% block modal %}{% endblock modal %}
{% for message in messages %}
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">{{ message }}</div>
{% endfor %}
{% endif %}
{% block content %} <!-- Javascript ======================= -->
<div class="row m-t-2"> <!-- Placed at the end of the document so the pages load faster -->
<p>Use this document as a way to quick start any new project.</p> {% block javascript %} {% endblock javascript %}
<p>The current template is loaded from </body>
<code>django-cryptolock/example/templates/base.html</code>. </p>
<p>Whenever you overwrite the contents of <code>django-cryptolock/django_cryptolock/urls.py</code> with your
own content, you should see it here.</p>
</div>
{% endblock content %}
</div> <!-- /container -->
{% block modal %}{% endblock modal %}
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
{% block javascript %}
<!-- Latest JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<!-- Tether - a requirement for Bootstrap tooltips -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
<!-- Your stuff: Third-party javascript libraries go here -->
{% endblock javascript %}
</body>
</html> </html>

View File

@ -12,9 +12,9 @@ from django.test.utils import get_runner
def run_tests(*test_args): def run_tests(*test_args):
if not 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() django.setup()
TestRunner = get_runner(settings) TestRunner = get_runner(settings)
test_runner = TestRunner() test_runner = TestRunner()
@ -22,5 +22,5 @@ def run_tests(*test_args):
sys.exit(bool(failures)) sys.exit(bool(failures))
if __name__ == '__main__': if __name__ == "__main__":
run_tests(*sys.argv[1:]) run_tests(*sys.argv[1:])

View File

@ -14,61 +14,59 @@ def get_version(*file_paths):
"""Retrieves the version from django_cryptolock/__init__.py""" """Retrieves the version from django_cryptolock/__init__.py"""
filename = os.path.join(os.path.dirname(__file__), *file_paths) filename = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = open(filename).read() version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
version_file, re.M)
if version_match: if version_match:
return version_match.group(1) 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") version = get_version("django_cryptolock", "__init__.py")
if sys.argv[-1] == 'publish': if sys.argv[-1] == "publish":
try: try:
import wheel import wheel
print("Wheel version: ", wheel.__version__) print("Wheel version: ", wheel.__version__)
except ImportError: except ImportError:
print('Wheel library missing. Please run "pip install wheel"') print('Wheel library missing. Please run "pip install wheel"')
sys.exit() sys.exit()
os.system('python setup.py sdist upload') os.system("python setup.py sdist upload")
os.system('python setup.py bdist_wheel upload') os.system("python setup.py bdist_wheel upload")
sys.exit() sys.exit()
if sys.argv[-1] == 'tag': if sys.argv[-1] == "tag":
print("Tagging the version on git:") print("Tagging the version on git:")
os.system("git tag -a %s -m 'version %s'" % (version, version)) os.system("git tag -a %s -m 'version %s'" % (version, version))
os.system("git push --tags") os.system("git push --tags")
sys.exit() sys.exit()
readme = open('README.rst').read() readme = open("README.rst").read()
history = open('HISTORY.rst').read().replace('.. :changelog:', '') history = open("HISTORY.rst").read().replace(".. :changelog:", "")
setup( setup(
name='django-cryptolock', name="django-cryptolock",
version=version, version=version,
description="""Django authentication using cryptocurrency wallets""", description="""Django authentication using cryptocurrency wallets""",
long_description=readme + '\n\n' + history, long_description=readme + "\n\n" + history,
author='Gonçalo Valério', author="Gonçalo Valério",
author_email='gon@ovalerio.net', author_email="gon@ovalerio.net",
url='https://github.com/dethos/django-cryptolock', url="https://github.com/dethos/django-cryptolock",
packages=[ packages=["django_cryptolock"],
'django_cryptolock',
],
include_package_data=True, include_package_data=True,
install_requires=["django-model-utils>=2.0",], install_requires=["django-model-utils>=2.0"],
license="MIT", license="MIT",
zip_safe=False, zip_safe=False,
keywords='django-cryptolock', keywords="django-cryptolock",
classifiers=[ classifiers=[
'Development Status :: 3 - Alpha', "Development Status :: 3 - Alpha",
'Framework :: Django :: 2.2', "Framework :: Django :: 2.2",
'Intended Audience :: Developers', "Intended Audience :: Developers",
'License :: OSI Approved :: MIT License', "License :: OSI Approved :: MIT License",
'Natural Language :: English', "Natural Language :: English",
'Programming Language :: Python :: 3', "Programming Language :: Python :: 3",
'Programming Language :: Python :: 3.5', "Programming Language :: Python :: 3.5",
'Programming Language :: Python :: 3.6', "Programming Language :: Python :: 3.6",
'Programming Language :: Python :: 3.7', "Programming Language :: Python :: 3.7",
], ],
) )

View File

@ -9,12 +9,7 @@ USE_TZ = True
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "!z^^097u*@)yq#w1n14m%uh-l67#h&uft9p+m%$$(0y(s%-q7o" SECRET_KEY = "!z^^097u*@)yq#w1n14m%uh-l67#h&uft9p+m%$$(0y(s%-q7o"
DATABASES = { DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
}
ROOT_URLCONF = "tests.urls" ROOT_URLCONF = "tests.urls"

View File

@ -14,7 +14,6 @@ from django_cryptolock import models
class TestDjango_cryptolock(TestCase): class TestDjango_cryptolock(TestCase):
def setUp(self): def setUp(self):
pass pass

View File

@ -5,5 +5,5 @@ from django.conf.urls import url, include
urlpatterns = [ urlpatterns = [
url(r'^', include('django_cryptolock.urls', namespace='django_cryptolock')), url(r"^", include("django_cryptolock.urls", namespace="django_cryptolock"))
] ]