Skip to content

Commit

Permalink
[*] Changing the creation of a project R: Implementation according to…
Browse files Browse the repository at this point in the history
… the requirements FB: Refactored the creation project and other code.
  • Loading branch information
ArtemKAF committed Mar 14, 2024
1 parent 5d72860 commit 2709ce0
Show file tree
Hide file tree
Showing 33 changed files with 3,375 additions and 781 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RESTfull API приложение, разработанное для поиск
реализовать что-то новое, для менеджеров проектов и для компаний которые хотят
создать тестовое МВП нового продукта.

![workflow](https://github.com/Pet-projects-CodePET/Backend/actions/workflows/main.yml/badge.svg)
[![Code cheсks](https://github.com/Pet-projects-CodePET/Backend/actions/workflows/code_check.yml/badge.svg)](https://github.com/Pet-projects-CodePET/Backend/actions/workflows/code_check.yml)

## Стек технологий:

Expand Down
5 changes: 5 additions & 0 deletions src/backend/api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.urls import include, path

urlpatterns = [
path("v1/", include("api.v1.urls")),
]
10 changes: 5 additions & 5 deletions src/backend/api/v1/general/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import serializers

from apps.general.models import Section, Skill, Specialization
from apps.general.models import Section, Skill, Specialist


class SectionSerializer(serializers.ModelSerializer):
Expand All @@ -9,17 +9,17 @@ class Meta:
fields = "__all__"


class SpecializationSerializer(serializers.ModelSerializer):
class SpecialistSerializer(serializers.ModelSerializer):
"""Сериализатор специализации."""

class Meta:
model = Specialization
fields = ("id", "name")
model = Specialist
fields = "__all__"


class SkillSerializer(serializers.ModelSerializer):
"""Сериализатор навыков."""

class Meta:
model = Skill
fields = ("id", "name")
fields = "__all__"
19 changes: 15 additions & 4 deletions src/backend/api/v1/general/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
from django.urls import path
from django.urls import include, path
from rest_framework.routers import DefaultRouter

from api.v1.general.views import CounterApiView, SectionViewSet
from api.v1.general.views import (
CounterApiView,
SectionViewSet,
SkillViewSet,
SpecialistViewSet,
)

router = DefaultRouter()
router.register("specialists", SpecialistViewSet, basename="specialists")
router.register("skills", SkillViewSet, basename="skills")

urlpatterns = [
path("section", SectionViewSet.as_view({"get": "list"})),
path("counter", CounterApiView.as_view()),
path("section/", SectionViewSet.as_view({"get": "list"})),
path("counter/", CounterApiView.as_view()),
path("", include(router.urls)),
]
30 changes: 25 additions & 5 deletions src/backend/api/v1/general/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
from django.views.decorators.cache import cache_page
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import generics, viewsets
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

from apps.general.models import Section
from api.v1.general.serializers import (
SectionSerializer,
SkillSerializer,
SpecialistSerializer,
)
from apps.general.models import Section, Skill, Specialist

from .serializers import SectionSerializer


class SectionViewSet(viewsets.ModelViewSet):
class SectionViewSet(viewsets.ReadOnlyModelViewSet):
"""Текстовая секция на странице"""

queryset = Section.objects.all()
Expand All @@ -26,7 +30,23 @@ class CounterApiView(generics.RetrieveAPIView):
def get(self, request):
with connection.cursor() as cursor:
cursor.execute(
"SELECT count(*) from project_project union all SELECT count(*) from users_user "
"SELECT count(*) from projects_project union all SELECT count(*) from users_user "
)
row = cursor.fetchall()
return Response({"projects": row[0][0], "users": row[1][0]})


class SpecialistViewSet(viewsets.ReadOnlyModelViewSet):
"""Представление специальностей."""

queryset = Specialist.objects.all()
serializer_class = SpecialistSerializer
permission_classes = (IsAuthenticated,)


class SkillViewSet(viewsets.ReadOnlyModelViewSet):
"""Представление специальностей."""

queryset = Skill.objects.all()
serializer_class = SkillSerializer
permission_classes = (IsAuthenticated,)
7 changes: 0 additions & 7 deletions src/backend/api/v1/projects/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
PROJECT_PREVIEW_MAIN_PAGE_SIZE = 6
PROJECT_PAGE_SIZE = 7
MAX_PAGE_SIZE = 100
PROJECT_PREVIEW_MAIN_FIELDS = (
"id",
"name",
"started",
"ended",
"direction",
)
Loading

0 comments on commit 2709ce0

Please sign in to comment.