Skip to content

Commit b278141

Browse files
committed
end configure
1 parent 7d88b18 commit b278141

File tree

18 files changed

+197
-35
lines changed

18 files changed

+197
-35
lines changed

apps/blog/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from unfold.admin import ModelAdmin
55

6+
67
@admin.register(Post)
78
class PostAdmin(ModelAdmin):
89
list_display = ["title", "content", "author", "is_active"]

apps/blog/filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class PostFilter(django_filters.FilterSet):
1111

1212
class Meta:
1313
model = Post
14-
fields = ['title', 'description', 'content', 'created_at']
14+
fields = ["title", "description", "content", "created_at"]

apps/blog/utils.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
from django.db.models import QuerySet
22
from django.db.models import Q
33
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
4-
from django.core.paginator import Paginator, Page, EmptyPage, PageNotAnInteger, InvalidPage
4+
from django.core.paginator import (
5+
Paginator,
6+
Page,
7+
EmptyPage,
8+
PageNotAnInteger,
9+
InvalidPage,
10+
)
511
from django.conf import settings
612

713
from .models import PostLike, PostDislike, Post, PostComment
814

915

10-
def get_search_model_queryset(
11-
model_queryset: QuerySet, query: str = None
12-
) -> QuerySet:
16+
def get_search_model_queryset(model_queryset: QuerySet, query: str = None) -> QuerySet:
1317
if not query:
1418
return model_queryset
1519

1620
search_vector = SearchVector("title", "description", "content")
1721
search_query = SearchQuery(query)
1822

19-
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql':
23+
if settings.DATABASES["default"]["ENGINE"] == "django.db.backends.postgresql":
2024
# PostgreSQL search
21-
queryset = model_queryset.annotate(
22-
search=search_vector,
23-
rank=SearchRank(search_vector, search_query),
24-
).filter(search=search_query).order_by('-rank')
25+
queryset = (
26+
model_queryset.annotate(
27+
search=search_vector,
28+
rank=SearchRank(search_vector, search_query),
29+
)
30+
.filter(search=search_query)
31+
.order_by("-rank")
32+
)
2533
else:
2634
# SQLite3 search
2735
queryset = model_queryset.filter(

apps/shared/management/commands/createadmin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.core.management import BaseCommand
55

66
from dotenv import load_dotenv
7+
78
load_dotenv()
89

910

apps/users/admin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from django.contrib import admin
2-
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
2+
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin # noqa
33
from .models import User, UserProfile
44

55
from unfold.admin import ModelAdmin
66

7+
78
@admin.register(User)
89
class UserAdmin(ModelAdmin):
910
list_display = ["username", "post_count"]
10-
search_fields = ["first_name", "last_name", "username"]
11+
search_fields = ["first_name", "last_name", "username", "email"]
1112
list_display_links = ["username"]
1213

1314
def get_post_count(self):
@@ -16,4 +17,4 @@ def get_post_count(self):
1617

1718
@admin.register(UserProfile)
1819
class UserProfileAdmin(ModelAdmin):
19-
pass
20+
list_display = ["user", "avatar", "bio"]

apps/users/api_endpoints/users/User/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ def _create_user():
104104
_create_user()
105105

106106
def test_api_user_update(self):
107-
pass
107+
pass

apps/users/api_endpoints/users/UserProfile/tests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from rest_framework.test import APITestCase
22
from rest_framework_simplejwt.tokens import RefreshToken
3-
from apps.users.models import UserProfile, User
3+
from apps.users.models import UserProfile, User # noqa
44

55

66
class UserProfileApiTestCase(APITestCase):
@@ -18,5 +18,3 @@ def setUp(self) -> None:
1818
refresh = RefreshToken.for_user(self.user)
1919
self.token = str(refresh.access_token)
2020
return super().setUp()
21-
22-

core/asgi.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
from django.core.asgi import get_asgi_application
44

55
from dotenv import load_dotenv
6+
67
load_dotenv()
78

89
os.environ.setdefault(
9-
"DJANGO_SETTINGS_MODULE",
10-
os.getenv("DJANGO_SETTINGS_MODULE", "core.settings.development")
10+
"DJANGO_SETTINGS_MODULE",
11+
os.getenv("DJANGO_SETTINGS_MODULE", "core.settings.development"),
1112
)
1213

1314
application = get_asgi_application()
1415

15-
app = application
16+
app = application

core/config/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from .apps import * # noqa
22
from .jwt import * # noqa
33
from .rest_framework import * # noqa
4-
from .unfold_navigation import * # noqa
5-
from .unfold import * # noqa
4+
from .unfold_navigation import * # noqa
5+
from .unfold import * # noqa
6+
7+
# from .cheditor5 import * # noqa

core/config/apps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"unfold.contrib.simple_history",
2727
# Translation
2828
"modeltranslation",
29+
#
30+
"django_ckeditor_5",
2931
# Translation pannel
3032
"rosetta",
3133
# DRF Swaggers

0 commit comments

Comments
 (0)