diff --git a/access_controller/settings.py b/access_controller/settings.py index 8f61695..24c1abf 100644 --- a/access_controller/settings.py +++ b/access_controller/settings.py @@ -15,7 +15,6 @@ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ @@ -27,7 +26,6 @@ DEBUG = True ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = [ @@ -73,7 +71,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'access_controller.wsgi.application' - # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases @@ -84,7 +81,6 @@ DATABASES = { } } - # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators @@ -103,7 +99,6 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] - # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ @@ -117,7 +112,6 @@ USE_L10N = True USE_TZ = True - # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ @@ -127,3 +121,4 @@ STATICFILES_DIRS = [ ] MEDIA_ROOT = BASE_DIR / 'media' +MEDIA_URL = '/media/' diff --git a/access_controller/urls.py b/access_controller/urls.py index eb189ef..b9f7386 100644 --- a/access_controller/urls.py +++ b/access_controller/urls.py @@ -13,12 +13,17 @@ 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.urls import path -from main.views import Reg +from access_controller import settings +from main.views import * urlpatterns = [ path('admin/', admin.site.urls, name='admin'), path('register/', Reg.as_view(), name='registration'), + path('admin/', admin.site.urls), + path('profile/', profile_page, name="Profile"), ] +urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/main/extra_func.py b/main/extra_func.py new file mode 100644 index 0000000..6d74db6 --- /dev/null +++ b/main/extra_func.py @@ -0,0 +1,46 @@ +from main.models import UserProfile + + +# Дополнительные функции +def set_and_get_username(UP: UserProfile): # TODO: Переделать с получением данных через API + """ + Функция устанавливает поле :class:`user.username` текущим именем в Zendesk + + :param UP: Объект профиля пользователя + :type UP: :class:`main.models.UserProfile` + :return: Имя пользователя + """ + return UP.user.username + + +def set_and_get_email(UP: UserProfile): # TODO: Переделать с получением данных через API + """ + Функция устанавливает поле :class:`user.email` текущей почтой в Zendesk + + :param UP: Объект профиля пользователя + :type UP: :class:`main.models.UserProfile` + :return: Почта пользователя + """ + return UP.user.email + + +def set_and_get_role(UP: UserProfile): # TODO: Переделать с получением данных через API + """ + Функция устанавливает поле :class:`role` текущей ролью в Zendesk + + :param UP: Объект профиля пользователя + :type UP: :class:`main.models.UserProfile` + :return: Роль пользователя + """ + return UP.role + + +def load_and_get_image(UP: UserProfile): # TODO: Переделать с получением изображения через API + """ + Функция загружает и устанавливает изображение в поле :class:`image` + + :param UP: Объект профиля пользователя + :type UP: :class:`main.models.UserProfile` + :return: Название изображения + """ + return UP.image.name diff --git a/main/templates/base/base.html b/main/templates/base/base.html new file mode 100644 index 0000000..b53080c --- /dev/null +++ b/main/templates/base/base.html @@ -0,0 +1,35 @@ + + +
+ +