Skip to content

Commit c14f710

Browse files
Merge pull request #18 from RustamovAkrom/main
Main
2 parents fb30118 + 1ceccb5 commit c14f710

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+852
-335
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude =
1515
__pycache__,
1616
migrations,
1717
static,
18-
env, # your virtual environment directory
18+
venv, # your virtual environment directory
1919

2020
# Enable checking for complexity
2121
max-complexity = 10

.github/workflows/django.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Django CI
1+
name: Django Test
22

33
on:
44
push:
@@ -20,23 +20,21 @@ jobs:
2020

2121
steps:
2222
- name: Check out the repository
23-
uses: actions/checkout@v4 # This is an action, so it uses 'uses'
23+
uses: actions/checkout@v4
2424

2525
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v3 # This is an action, so it uses 'uses'
26+
uses: actions/setup-python@v3
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929

3030
- name: Install OpenSSL
31-
run: sudo apt-get install -y openssl # This is a command, so it uses 'run'
31+
run: sudo apt-get install -y openssl
3232

3333
- name: Generate private and public keys
3434
run: |
35-
# Очистка старых файлов перед созданием новых
3635
rm -rf security
3736
mkdir -p security
3837
39-
# Генерация приватного и публичного ключа
4038
openssl genpkey -algorithm RSA -out security/private_key.pem -pkeyopt rsa_keygen_bits:2048
4139
openssl rsa -pubout -in security/private_key.pem -out security/public_key.pem
4240
@@ -53,17 +51,17 @@ jobs:
5351
5452
5553
- name: Check if .env has been updated
56-
run: cat .env # This is a command, so it uses 'run'
54+
run: cat .env
5755

5856
- name: Install Dependencies
5957
run: |
6058
python -m pip install --upgrade pip
61-
pip install -r requirements.txt # This is a command, so it uses 'run'
59+
pip install -r requirements.txt
6260
6361
- name: Run Tests
64-
run: python manage.py test # This is a command, so it uses 'run'
62+
run: python manage.py test
6563

6664
- name: Clean up keys (Optional)
6765
run: |
6866
rm -rf security
69-
echo "Keys removed after use." # This is a command, so it uses 'run'
67+
echo "Keys removed after use."

.github/workflows/lint.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Lint Code
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "master"
8+
pull_request:
9+
branches:
10+
- "main"
11+
- "master"
12+
13+
jobs:
14+
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [3.8, 3.9]
20+
21+
steps:
22+
- name: Check out the repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install OpenSSL
31+
run: sudo apt-get install -y openssl
32+
33+
- name: Generate private and public keys
34+
run: |
35+
rm -rf security
36+
mkdir -p security
37+
38+
openssl genpkey -algorithm RSA -out security/private_key.pem -pkeyopt rsa_keygen_bits:2048
39+
openssl rsa -pubout -in security/private_key.pem -out security/public_key.pem
40+
41+
echo "Private key saved as security/private_key.pem"
42+
echo "Public key saved as security/public_key.pem"
43+
44+
- name: Create .env file
45+
run: |
46+
touch .env
47+
echo PRIVATE_KEY_PATH=$(pwd)/security/private_key.pem >> .env
48+
echo PUBLIC_KEY_PATH=$(pwd)/security/public_key.pem >> .env
49+
DJANGO_SETTINGS_MODULE=core.settings.development >> .env
50+
echo DATABASE_ENVIRON=sqlite3 >> .env
51+
52+
53+
- name: Check if .env has been updated
54+
run: cat .env
55+
56+
- name: Install Dependencies
57+
run: |
58+
pip install flake8
59+
python -m pip install --upgrade pip
60+
pip install -r requirements.txt
61+
62+
- name: Lint Code
63+
run: flake8 .
64+
65+
- name: Clean up keys (Optional)
66+
run: |
67+
rm -rf security
68+
echo "Keys removed after use."
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
from rest_framework import routers
22

33
from .blog import (
4-
PostViewSet,
5-
PostCommentViewSet,
4+
PostViewSet,
5+
PostCommentViewSet,
66
PostCommentLikeViewSet,
77
PostLikeViewSet,
8-
PostDislikeViewSet
8+
PostDislikeViewSet,
99
)
1010

1111
router = routers.DefaultRouter()
1212
router.register("post", PostViewSet, basename="post")
1313
router.register("post_comment", PostCommentViewSet, basename="post-comment")
14-
router.register("post_comment_like", PostCommentLikeViewSet, basename="post-comment-like")
14+
router.register(
15+
"post_comment_like", PostCommentLikeViewSet, basename="post-comment-like"
16+
)
1517
router.register("post_like", PostLikeViewSet, basename="post-like")
1618
router.register("post_dislike", PostDislikeViewSet, basename="post-dislike")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .views import * # noqa
1+
from .views import * # noqa

apps/blog/api_endpoints/blog/Post/serializer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Meta:
88
model = Post
99
fields = [
1010
"id",
11-
"title",
11+
"title",
1212
"get_absolute_url",
1313
"status",
1414
"description",
@@ -21,4 +21,4 @@ class Meta:
2121
"watching",
2222
"created_at",
2323
"updated_at",
24-
]
24+
]

apps/blog/api_endpoints/blog/Post/views.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
class PostViewSet(viewsets.ModelViewSet):
88
queryset = Post.published.all().order_by("-created_at")
99
serializer_class = PostSerializer
10-
10+
1111
def get_permissions(self):
12-
if self.action in ['list', 'retrieve']:
12+
if self.action in ["list", "retrieve"]:
1313
return [permissions.AllowAny()]
1414
return [permissions.IsAuthenticated()]
15-
16-
__all__ = ("PostViewSet", )
15+
16+
17+
__all__ = ("PostViewSet",)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .views import * # noqa
1+
from .views import * # noqa

apps/blog/api_endpoints/blog/PostComment/views.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ class PostCommentViewSet(viewsets.ModelViewSet):
99
serializer_class = PostCommentSerializer
1010

1111
def get_permissions(self):
12-
if self.action in ['list', 'retrieve']:
12+
if self.action in ["list", "retrieve"]:
1313
return [permissions.AllowAny()]
14-
return [permissions.IsAuthenticated()]
15-
16-
__all__ = ("PostCommentViewSet", )
14+
return [permissions.IsAuthenticated()]
15+
16+
17+
__all__ = ("PostCommentViewSet",)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .views import * # noqa
1+
from .views import * # noqa

0 commit comments

Comments
 (0)