chore: Reformat files
This commit is contained in:
parent
96f4a81a3b
commit
79b7bc8364
15 changed files with 63 additions and 94 deletions
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
|
||||
from setuptools import find_namespace_packages, setup, find_packages
|
||||
from setuptools import find_namespace_packages, setup
|
||||
|
||||
from userausfall import __version__
|
||||
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -11,7 +11,7 @@ deps =
|
|||
flake8
|
||||
flake8-import-order
|
||||
setenv =
|
||||
FORMAT_PATHS = userausfall{/} setup.py libpy{/}
|
||||
FORMAT_PATHS = userausfall{/} setup.py
|
||||
commands =
|
||||
python3 -m flake8 {env:FORMAT_PATHS}
|
||||
python3 -m black --check {env:FORMAT_PATHS}
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
__version__ = "0.1.0"
|
||||
|
||||
default_app_config = 'userausfall.apps.UserausfallConfig'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from userausfall.models import User, TrustBridge
|
||||
from userausfall.models import TrustBridge, User
|
||||
|
||||
admin.site.register(TrustBridge)
|
||||
admin.site.register(User)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UserausfallConfig(AppConfig):
|
||||
name = 'userausfall'
|
||||
|
||||
def ready(self):
|
||||
from . import signals
|
|
@ -1,4 +1,5 @@
|
|||
from djeveric import Confirmation
|
||||
|
||||
from userausfall.emails import ConfidantConfirmationEmail
|
||||
from userausfall.models import User
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.conf import settings
|
||||
from ldap3 import Server, Connection, SYNC
|
||||
from ldap3 import Connection, Server, SYNC
|
||||
|
||||
|
||||
def create_account(username, raw_password):
|
||||
|
@ -14,9 +14,7 @@ def create_account(username, raw_password):
|
|||
|
||||
def account_exists(username):
|
||||
connection = _get_connection()
|
||||
exists = connection.search(
|
||||
f"cn={username},dc=local", "(objectclass=simpleSecurityObject)"
|
||||
)
|
||||
exists = connection.search(f"cn={username},dc=local", "(objectclass=simpleSecurityObject)")
|
||||
return exists
|
||||
|
||||
|
||||
|
|
|
@ -58,9 +58,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||
username = models.CharField(
|
||||
_("username"),
|
||||
max_length=150,
|
||||
help_text=_(
|
||||
"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only."
|
||||
),
|
||||
help_text=_("Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only."),
|
||||
validators=[username_validator],
|
||||
error_messages={"unique": _("A user with that username already exists.")},
|
||||
unique=True,
|
||||
|
@ -96,9 +94,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||
if not self.username:
|
||||
raise MissingUserAttribute("User is missing a username.")
|
||||
if not self.check_password(raw_password):
|
||||
raise PasswordMismatch(
|
||||
"The given password does not match the user's password."
|
||||
)
|
||||
raise PasswordMismatch("The given password does not match the user's password.")
|
||||
return ldap.create_account(self.username, raw_password)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from userausfall.models import User, TrustBridge
|
||||
from userausfall.models import TrustBridge, User
|
||||
|
||||
|
||||
class TrustBridgeSerializer(serializers.ModelSerializer):
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
from django.urls import path
|
||||
from rest_framework import routers
|
||||
|
||||
from userausfall.rest_api.views import UserViewSet
|
||||
|
||||
router = routers.DefaultRouter(trailing_slash=True)
|
||||
router.register(r'users', UserViewSet, basename="user")
|
||||
router.register(r"users", UserViewSet, basename="user")
|
||||
|
||||
urlpatterns = [
|
||||
# path("confirm/confidant/", ConfidantConfirmationView.as_view())
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from rest_framework import viewsets, status
|
||||
from rest_framework import status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
|
||||
from userausfall.models import User, MissingUserAttribute, PasswordMismatch
|
||||
from userausfall.models import MissingUserAttribute, PasswordMismatch, User
|
||||
from userausfall.rest_api.permissions import UserPermission
|
||||
from userausfall.rest_api.serializers import (
|
||||
ActivateUserSerializer,
|
||||
|
|
|
@ -19,7 +19,7 @@ DATA_DIR = os.environ.get("USERAUSFALL_DATA_DIR", BASE_DIR)
|
|||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = os.environ.get('LOCAL_DJANGO_SECRET_KEY')
|
||||
SECRET_KEY = os.environ.get("LOCAL_DJANGO_SECRET_KEY")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
@ -30,55 +30,55 @@ ALLOWED_HOSTS = []
|
|||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.staticfiles',
|
||||
'userausfall',
|
||||
'rest_framework',
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.staticfiles",
|
||||
"userausfall",
|
||||
"rest_framework",
|
||||
]
|
||||
|
||||
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',
|
||||
"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 = 'userausfall.urls'
|
||||
ROOT_URLCONF = "userausfall.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'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": [],
|
||||
"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 = 'userausfall.wsgi.application'
|
||||
WSGI_APPLICATION = "userausfall.wsgi.application"
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(DATA_DIR, 'db.sqlite3'),
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.path.join(DATA_DIR, "db.sqlite3"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ DATABASES = {
|
|||
# User model
|
||||
#
|
||||
|
||||
AUTH_USER_MODEL = 'userausfall.User'
|
||||
AUTH_USER_MODEL = "userausfall.User"
|
||||
|
||||
|
||||
# Password validation
|
||||
|
@ -94,16 +94,16 @@ AUTH_USER_MODEL = 'userausfall.User'
|
|||
|
||||
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.MinimumLengthValidator",
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -111,9 +111,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'de-de'
|
||||
LANGUAGE_CODE = "de-de"
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
@ -125,30 +125,28 @@ USE_TZ = True
|
|||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_URL = "/static/"
|
||||
|
||||
|
||||
# Media files
|
||||
# https://docs.djangoproject.com/en/2.2/topics/files/
|
||||
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_URL = "/media/"
|
||||
|
||||
|
||||
# Sending email
|
||||
# https://docs.djangoproject.com/en/3.2/topics/email/
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
|
||||
|
||||
# Django Rest Framework
|
||||
# https://www.django-rest-framework.org/api-guide/settings/
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
),
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": ("rest_framework.authentication.SessionAuthentication",),
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,6 +157,6 @@ SITE_ID = 1
|
|||
|
||||
|
||||
USERAUSFALL_LDAP = {
|
||||
'ADMIN_USER_DN': 'cn=admin,dc=local',
|
||||
'ADMIN_USER_PASSWORD': os.environ.get('USERAUSFALL_LDAP_PASSWORD'),
|
||||
"ADMIN_USER_DN": "cn=admin,dc=local",
|
||||
"ADMIN_USER_PASSWORD": os.environ.get("USERAUSFALL_LDAP_PASSWORD"),
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from userausfall.models import User
|
||||
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def user_saved(sender, instance: User, **kwargs):
|
||||
# if instance.confidant_unconfirmed is not None:
|
||||
# ConfidantConfirmation(instance.confidant_unconfirmed, instance).send_request()
|
||||
pass
|
|
@ -1,10 +1,8 @@
|
|||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
from userausfall.rest_api import urls as rest_api_urls
|
||||
from django.urls import include, path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/', include("userausfall.rest_api.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
path("api/", include("userausfall.rest_api.urls")),
|
||||
path("api-auth/", include("rest_framework.urls")),
|
||||
]
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"""
|
||||
WSGI config for userausfall project.
|
||||
WSGI config for memoorje project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
|
||||
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'userausfall.settings')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "userausfall.settings")
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
|
Reference in a new issue