Merge develop into feature/registration_failed/html
This commit is contained in:
@@ -9,8 +9,9 @@ https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'access_controller.settings')
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
application = get_asgi_application()
|
||||
|
||||
19
access_controller/auth.py
Normal file
19
access_controller/auth.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class EmailAuthBackend(ModelBackend):
|
||||
def authenticate(self, request, username=None, password=None, **kwargs):
|
||||
try:
|
||||
user = User.objects.get(email=username)
|
||||
if user.check_password(password):
|
||||
return user
|
||||
return None
|
||||
except User.DoesNotExist:
|
||||
return None
|
||||
|
||||
def get_user(self, user_id):
|
||||
try:
|
||||
return User.objects.get(pk=user_id)
|
||||
except User.DoesNotExist:
|
||||
return None
|
||||
@@ -19,12 +19,16 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'v1i_fb$_jf2#1v_lcsbu&eon4u-os0^px=s^iycegdycqy&5)6'
|
||||
SECRET_KEY = os.getenv('ACTRL_SECRET_KEY','empty')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = bool(int(os.getenv('ACTRL_DEBUG',1)))
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
ALLOWED_HOSTS = [
|
||||
'127.0.0.1',
|
||||
'localhost',
|
||||
os.getenv('ACTRL_HOST'),
|
||||
]
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -36,6 +40,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django_registration',
|
||||
'rest_framework',
|
||||
'main',
|
||||
]
|
||||
|
||||
@@ -51,6 +56,15 @@ MIDDLEWARE = [
|
||||
|
||||
ROOT_URLCONF = 'access_controller.urls'
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_HOST = os.getenv('ACTRL_EMAIL_HOST','smtp.gmail.com')
|
||||
EMAIL_PORT = int(os.getenv('ACTRL_EMAIL_PORT',587))
|
||||
EMAIL_USE_TLS = bool(int(os.getenv('ACTRL_EMAIL_TLS',1)))
|
||||
EMAIL_HOST_USER = os.getenv('ACTRL_EMAIL_HOST_USER','group02django@gmail.com')
|
||||
EMAIL_HOST_PASSWORD = os.getenv('ACTRL_EMAIL_HOST_PASSWORD','djangogroup02')
|
||||
DEFAULT_FROM_EMAIL = os.getenv('ACTRL_FROM_EMAIL',EMAIL_HOST_USER)
|
||||
SERVER_EMAIL = os.getenv('ACTRL_SERVER_EMAIL',EMAIL_HOST_USER)
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
@@ -77,7 +91,7 @@ WSGI_APPLICATION = 'access_controller.wsgi.application'
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
'NAME': BASE_DIR / 'db' / 'zd_db.sqlite3'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,11 +133,47 @@ STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticroot')
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'static'),
|
||||
os.path.join(BASE_DIR, 'media'),
|
||||
]
|
||||
|
||||
MEDIA_ROOT = BASE_DIR / 'media'
|
||||
MEDIA_URL = '/media/'
|
||||
ACCOUNT_ACTIVATION_DAYS = 7
|
||||
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
LOGOUT_REDIRECT_URL = '/'
|
||||
|
||||
# Название_приложения.Название_файла.Название_класса_обработчика
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'access_controller.auth.EmailAuthBackend',
|
||||
]
|
||||
|
||||
# Logging system
|
||||
# https://docs.djangoproject.com/en/3.1/topics/logging/
|
||||
|
||||
|
||||
ZENDESK_ROLES = {
|
||||
'engineer': int(os.getenv('ENG_CROLE_ID',0)),
|
||||
'light_agent': int(os.getenv('LA_CROLE_ID',0)),
|
||||
}
|
||||
|
||||
ZENDESK_GROUPS = {
|
||||
'employees': os.getenv('EMPL_GROUP'),
|
||||
'buffer': os.getenv('BUF_GROUP'),
|
||||
}
|
||||
|
||||
SOLVED_TICKETS_EMAIL = os.getenv('ST_EMAIL')
|
||||
|
||||
ZENDESK_MAX_AGENTS = int(os.getenv('LICENSE_NO',0))
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
# Use Django's standard `django.contrib.auth` permissions,
|
||||
# or allow read-only access for unauthenticated users.
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||
]
|
||||
}
|
||||
|
||||
ONE_DAY = int(os.getenv('SHIFTH',0)) # Количество часов в 1 рабочем дне
|
||||
|
||||
ACTRL_ZENDESK_SUBDOMAIN = os.getenv('ACTRL_ZENDESK_SUBDOMAIN') or os.getenv('ZD_DOMAIN')
|
||||
ACTRL_API_EMAIL = os.getenv('ACTRL_API_EMAIL') or os.getenv('ACCESS_CONTROLLER_API_EMAIL')
|
||||
ACTRL_API_TOKEN = os.getenv('ACTRL_API_TOKEN') or os.getenv('ACCESS_CONTROLLER_API_TOKEN')
|
||||
ACTRL_API_PASSWORD = os.getenv('ACTRL_API_PASSWORD') or os.getenv('ACCESS_CONTROLLER_API_PASSWORD')
|
||||
|
||||
@@ -13,22 +13,35 @@ Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.urls import path, include
|
||||
|
||||
from access_controller import settings
|
||||
from access_controller.settings import DEBUG
|
||||
from main.views import main_page, profile_page, CustomRegistrationView, registration_failed
|
||||
from main.urls import router
|
||||
from main.views import main_page, profile_page, CustomRegistrationView, CustomLoginView, registration_error
|
||||
from main.views import registration_failed
|
||||
from main.views import work_page, work_hand_over, work_become_engineer, work_get_tickets, \
|
||||
AdminPageView, statistic_page
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls, name='admin'),
|
||||
path('', main_page, name='index'),
|
||||
path('accounts/profile/', profile_page, name='profile'),
|
||||
path('accounts/register/', CustomRegistrationView.as_view(), name='registration'),
|
||||
path('accounts/login/', LoginView.as_view(extra_context={}), name='login'), # TODO add extra context
|
||||
path('accounts/register/error/', registration_error, name='registration_email_error'),
|
||||
path('accounts/login/', CustomLoginView.as_view(), name='login'),
|
||||
path('accounts/', include('django.contrib.auth.urls')),
|
||||
path('accounts/', include('django_registration.backends.one_step.urls')),
|
||||
path('work/<int:id>', work_page, name="work"),
|
||||
path('work/hand_over/', work_hand_over, name="work_hand_over"),
|
||||
path('work/become_engineer/', work_become_engineer, name="work_become_engineer"),
|
||||
path('work/get_tickets', work_get_tickets, name='work_get_tickets'),
|
||||
path('accounts/', include('django_registration.backends.activation.urls')),
|
||||
path('registration_failed/', registration_failed, name='registration_failed'),
|
||||
path('control/', AdminPageView.as_view(), name='control'),
|
||||
path('statistic/', statistic_page, name='statistic'),
|
||||
]
|
||||
|
||||
# Django REST
|
||||
urlpatterns += [
|
||||
path('api/', include(router.urls))
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user