Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content searchfield #38

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

urlpatterns = [
path('', include(router.urls)),
path('', include('djoser.urls')), # это вроде можно убрать
# path('', include('djoser.urls')), # это вроде можно убрать
path('auth/', include('djoser.urls.authtoken')),
path('platform_about/', PlatformAboutView.as_view()),
path('feedback/', FeedbackCreateView.as_view()),
Expand Down
51 changes: 34 additions & 17 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
'djoser',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger',
# 'rest_framework_swagger', # убираем
'drf_yasg',
'taggit',
'api.apps.ApiConfig',
'content.apps.ContentConfig',
Expand Down Expand Up @@ -88,24 +89,24 @@
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': os.getenv('POSTGRES_DB', 'volunteers'),
# 'USER': os.getenv('POSTGRES_USER', 'volunteers_user'),
# 'PASSWORD': os.getenv('POSTGRES_PASSWORD', ''),
# 'HOST': os.getenv('DB_HOST', 'localhost'),
# 'PORT': os.getenv('DB_PORT', 5432),
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('POSTGRES_DB', 'volunteers'),
'USER': os.getenv('POSTGRES_USER', 'volunteers_user'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD', ''),
'HOST': os.getenv('DB_HOST', 'localhost'),
'PORT': os.getenv('DB_PORT', 5432),
}
}


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -162,7 +163,7 @@
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 10,
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend',],
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
# 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}

DJOSER = {
Expand All @@ -188,6 +189,22 @@

AUTH_USER_MODEL = 'users.User'

SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'Token': { # авторизация в джанго по токену
'type': 'apiKey',
'name': 'Authorization',
'in': 'header'
},
'Basic': { # базова авторизация
'type': 'basic'
}
},
'USE_SESSION_AUTH': True, # кнопка джанго логин можно отключить поменяв False
'JSON_EDITOR': True,
'SHOW_REQUEST_HEADERS': True,
}

# Constants
MAX_LENGTH_NAME = 50
MAX_LENGTH_SLUG = 50
Expand Down Expand Up @@ -219,9 +236,9 @@
MAX_LEN_NAME_USER = 40
MESSAGE_NAME_USER_VALID = f'Длина поля от {MIN_LEN_NAME_USER} до {MAX_LEN_NAME_USER} символов'
MESSAGE_NAME_USER_CYRILLIC = 'Введите имя кириллицей'
MAX_LENGTH_ROLE = 50
OGRN_ERROR_MESSAGE = 'ОГРН должен состоять из 13 цифр.'

OGRN_ERROR_MESSAGE = 'ОГРН должен состоять из 13 цифр.'
MAX_LENGTH_ROLE = 50
MIN_LEN_TELEGRAM = 5
MAX_LEN_TELEGRAM = 32
TELEGRAM_ERROR_MESSAGE = 'Ник в Telegram должен начинаться с @ и содержать только буквы, цифры и знаки подчеркивания. От {} до {} символов.'
Expand Down
19 changes: 16 additions & 3 deletions backend/backend/urls.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth.views import LoginView, LogoutView
from django.urls import include, path
from rest_framework_swagger.views import get_swagger_view
# from rest_framework_swagger.views import get_swagger_view
# schema_view = get_swagger_view(title='BETTER-TOGETHER Documentation API')
from .yasg import urlpatterns as doc_urls


schema_view = get_swagger_view(title='BETTER-TOGETHER Documentation API')

urlpatterns = [
path('api/', include('api.urls')),
path('admin/', admin.site.urls),
path('swagger/', schema_view),
# логин в джанго свагер Проверить никому не помешает ли!!!
path('accounts/login/', LoginView.as_view(
template_name='admin/login.html',
)),
# логаут в джанго свагер. Проверить никому не помешает ли!!!
path('accounts/logout/', LogoutView.as_view(
template_name='admin/logout.html',
)),
# path('swagger/', schema_view),
]

urlpatterns += doc_urls

if settings.DEBUG:
urlpatterns += static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
Expand Down
43 changes: 43 additions & 0 deletions backend/backend/yasg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from django.urls import path, re_path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions


schema_view = get_schema_view(
openapi.Info(
title='BETTER-TOGETHER',
default_version='v1',
description="""API documentation for Task BETTER-TOGETHER project.
Contact us.
<a href="https://t.me/yunker1" target="_blank">Yurij Pomazkin,</a>\
<a href="https://t.me/ruzal_z" target="_blank">Ruzal Zakirov,</a>\
<a href="https://t.me/ArtemKAF" target="_blank">Artem Kozin,</a>\
<a href="https://t.me/Mirabilis_ignotus" target="_blank">Olga Komleva,\
</a>\
and <a href="https://t.me/yourhot" target="_blank">Irina Yablokova
</a>""",
contact=openapi.Contact(email="[email protected]"),
license=openapi.License(name='BSD License'),
),
public=True,
permission_classes=[permissions.AllowAny],
)


urlpatterns = [
re_path(
r'swagger(?P<format>\.json|\.yaml)',
schema_view.without_ui(cache_timeout=0),
name='schema-json'
),
path(
'swagger/',
schema_view.with_ui('swagger', cache_timeout=0),
name='schema-swagger-ui'
),
path(
'redoc/',
schema_view.with_ui('redoc', cache_timeout=0),
name='schema-redoc'),
]
2 changes: 1 addition & 1 deletion backend/notifications/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.contrib import admin
# from django.contrib import admin

# Register your models here.
2 changes: 0 additions & 2 deletions backend/notifications/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.db import models

# Create your models here.
3 changes: 0 additions & 3 deletions backend/notifications/tests.py

This file was deleted.

2 changes: 0 additions & 2 deletions backend/notifications/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.shortcuts import render

# Create your views here.
Empty file removed backend/projects/tests.py
Empty file.
Empty file removed backend/projects/views.py
Empty file.
4 changes: 3 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ defusedxml==0.8.0rc2
Django==4.2.6
django-cors-headers==4.3.0
django-filter==23.3
django-rest-swagger==2.2.0
django-taggit==4.0.0
django-taggit-serializer==0.1.7
django-templated-mail==1.1.1
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.0
djoser==2.2.0
drf-yasg==1.21.7
gunicorn==21.2.0
idna==3.4
inflection==0.5.1
itypes==1.2.0
Jinja2==3.1.2
MarkupSafe==2.1.3
Expand All @@ -31,6 +32,7 @@ PyJWT==2.8.0
python-dotenv==1.0.0
python3-openid==3.2.0
pytz==2023.3.post1
PyYAML==6.0.1
requests==2.31.0
requests-oauthlib==1.3.1
simplejson==3.19.2
Expand Down
Empty file removed backend/users/tests.py
Empty file.
Empty file removed backend/users/views.py
Empty file.