Skip to content

Commit

Permalink
add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Dec 9, 2024
1 parent 936dc81 commit afc0512
Show file tree
Hide file tree
Showing 11 changed files with 860 additions and 658 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ mypy = "*"
google-api-python-client-stubs = "*"
django-stubs = "*"
djangorestframework-stubs = "*"
pytest-django = "*"
mixer = "*"

[packages]
django = "*"
Expand All @@ -75,8 +77,6 @@ django-cors-headers = "*"
django-phonenumber-field = {extras = ["phonenumberslite"] }
activecampaign-python = "*"
schema = "*"
mixer = "*"
pytest-django = "*"
pygithub = "*"
google-cloud-datastore = "*"
pyfcm = "*"
Expand Down
1,401 changes: 769 additions & 632 deletions Pipfile.lock

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions breathecode/admissions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ class CapyAcademySerializer(capy.Serializer):
model = Academy
# path = "/permission"
fields = {"default": ("id", "slug", "name", "country", "city", "logo_url", "is_hidden_on_prework")}
filters = ("slug",)


class CapyCohortTimeSlotSerializer(capy.Serializer):
model = CohortTimeSlot
# path = "/permission"
path = "/v2/admissions/public/cohorttimeslot"
fields = {"default": ("id", "starting_at", "ending_at", "recurrent", "recurrency_type")}
filters = ("cohort",)

Expand Down Expand Up @@ -88,22 +89,25 @@ class CapySyllabusSerializer(capy.Serializer):
class CapySyllabusScheduleSerializer(capy.Serializer):
model = SyllabusSchedule
# path = "/permission"
fields = {"default": tuple()}
fields = {"default": ("id", "name", "schedule_type", "description")}
filters = ("syllabus",)
syllabus = CapySyllabusSerializer


class CapyVoidSyllabusVersionSerializer(capy.Serializer):
model = SyllabusVersion
# path = "/permission"
fields = {"default": tuple()}
fields = {
"default": ("id", "version", "status"),
"integrity": ("integrity_status", "integrity_check_at", "integrity_report"), # inherit this fails
}
filters = ("syllabus",)
syllabus = CapySyllabusSerializer


class CapyPublicCohortSerializer(capy.Serializer):
model = Cohort
# path = "/permission"
path = "/v2/admissions/public/cohort"
fields = {
"default": (
"id",
Expand All @@ -120,9 +124,10 @@ class CapyPublicCohortSerializer(capy.Serializer):
"timezone",
"academy",
),
"syllabus_version": ("syllabus_version[]",),
"syllabus_version": ("syllabus_version[integrity]",),
"academy": ("academy[]",),
"schedule": ("schedule[]",),
"timeslots": ("timeslots[]",),
}
rewrites = {
"cohorttimeslot_set": "timeslots",
Expand All @@ -131,6 +136,7 @@ class CapyPublicCohortSerializer(capy.Serializer):
syllabus_version = CapyVoidSyllabusVersionSerializer
schedule = CapySyllabusScheduleSerializer
timeslots = CapyCohortTimeSlotSerializer
academy = CapyAcademySerializer


class CapyPublicCohortUserSerializer(capy.Serializer):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path

from .views import (
from ..views import (
AcademyActivateView,
AcademyCohortHistoryView,
AcademyCohortTimeSlotView,
Expand All @@ -18,9 +18,7 @@
CohortUserView,
MeCohortUserHistoryView,
PublicCohortUserView,
PublicCohortUserView2,
PublicCohortView,
PublicCohortView2,
SyllabusAssetView,
SyllabusScheduleView,
SyllabusVersionCSVView,
Expand All @@ -44,7 +42,6 @@
path("public/syllabus", get_public_syllabus),
# deprecated methods, soon to be deleted
path("cohort/all", PublicCohortView.as_view(), name="cohort_all"),
path("cohort/all2", PublicCohortView2.as_view(), name="cohort_all2"),
path("cohort/user", CohortUserView.as_view(), name="cohort_user"),
path("cohort/<int:cohort_id>/join", CohortJoinView.as_view(), name="cohort_id_join"),
path("cohort/<int:cohort_id>/user/<int:user_id>", CohortUserView.as_view(), name="cohort_id_user_id"),
Expand Down Expand Up @@ -166,5 +163,4 @@
path("admin/syllabus/asset/<str:asset_slug>", SyllabusAssetView.as_view(), name="syllabus_asset"),
# Public Endpoints anyone can call
path("public/cohort/user", PublicCohortUserView.as_view(), name="public_cohort_user"),
path("public/cohort/user2", PublicCohortUserView2.as_view(), name="public_cohort_user2"),
]
19 changes: 19 additions & 0 deletions breathecode/admissions/urls/v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.urls import path

from ..views import PublicCohortTimeSlotV2View, PublicCohortUserV2View, PublicCohortV2View
from .v1 import urlpatterns as urlpatterns_v1

deprecation_list = [
"upload",
]

app_name = "admissions"
urlpatterns = [
path("public/cohort", PublicCohortV2View.as_view(), name="cohort_all2"),
path("public/cohort/user", PublicCohortUserV2View.as_view(), name="public_cohort_user2"),
# path("public/cohort/<int:id>", PublicCohortV2View.as_view(), name="cohort_id"),
# path("public/cohort/<int:id>/user", PublicCohortUserV2View.as_view(), name="cohort_id_user"),
path("public/cohort/<int:id>/timeslot", PublicCohortTimeSlotV2View.as_view(), name="cohort_id_timeslot"),
path("public/cohorttimeslot", PublicCohortTimeSlotV2View.as_view(), name="public_cohorttimeslot"),
*[r for r in urlpatterns_v1 if r.pattern._route not in deprecation_list],
]
43 changes: 31 additions & 12 deletions breathecode/admissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from .serializers import (
AcademyReportSerializer,
AcademySerializer,
CapyCohortTimeSlotSerializer,
CapyPublicCohortSerializer,
CapyPublicCohortUserSerializer,
CohortPUTSerializer,
Expand Down Expand Up @@ -354,14 +355,43 @@ def get(self, request, id=None):
return handler.response(data)


class PublicCohortView2(APIView):
class PublicCohortV2View(APIView):
permission_classes = [AllowAny]

def get(self, request, id=None):
serializer = CapyPublicCohortSerializer(request=request)
return serializer.filter()


class PublicCohortUserV2View(APIView, GenerateLookupsMixin):
"""List all snippets, or create a new snippet."""

permission_classes = [AllowAny]

def get(self, request):
serializer = CapyPublicCohortUserSerializer(request=request)
return serializer.filter()


class PublicCohortTimeSlotV2View(APIView, GenerateLookupsMixin):
"""List all snippets, or create a new snippet."""

extensions = APIViewExtensions(cache=CohortUserCache, paginate=True)
permission_classes = [AllowAny]

def get(self, request, id=None, cohort_id=None):
serializer = CapyCohortTimeSlotSerializer(request=request)

if id:
return serializer.get(cohort=id)

filters = {}
if cohort_id:
filters["cohort"] = cohort_id

return serializer.filter(**filters)


class AcademyReportView(APIView):

@capable_of("academy_reporting")
Expand Down Expand Up @@ -1951,17 +1981,6 @@ def get(self, request):
return handler.response(serializer.data)


class PublicCohortUserView2(APIView, GenerateLookupsMixin):
"""List all snippets, or create a new snippet."""

extensions = APIViewExtensions(cache=CohortUserCache, paginate=True)
permission_classes = [AllowAny]

def get(self, request):
serializer = CapyPublicCohortUserSerializer(request=request)
return serializer.filter()


class AcademyCohortHistoryView(APIView):
"""List all snippets, or create a new snippet."""

Expand Down
1 change: 0 additions & 1 deletion breathecode/marketing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ def _storage_status(self, obj):
"DRAFT": "bg-error",
"PENDING_TRANSLATION": "bg-error",
"PENDING": "bg-warning",
"WARNING": "bg-warning",
"NOT_STARTED": "bg-error",
"UNLISTED": "bg-warning",
}
Expand Down
6 changes: 6 additions & 0 deletions breathecode/media/tests/urls/v2/tests_operationtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
import capyc.pytest as capy
from django.urls.base import reverse_lazy
from django.utils import timezone
import pytest
from rest_framework import status

UTC_NOW = timezone.now()


@pytest.fixture(autouse=True)
def setup(db):
yield


def test_list_op_types(client: capy.Client):
url = reverse_lazy("v2:media:operationtype")

Expand Down
5 changes: 5 additions & 0 deletions breathecode/media/tests/urls/v2/tests_operationtype_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
UTC_NOW = timezone.now()


@pytest.fixture(autouse=True)
def setup(db):
yield


@pytest.mark.parametrize(
"op_type, expected",
[
Expand Down
14 changes: 14 additions & 0 deletions breathecode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ def get(self, key, *args, **kwargs):
},
}

CAPYC = {
"pagination": {
"pks": 200,
"pages": 20,
},
"cache": {
"enabled": False,
},
"compression": {
"enabled": False,
"min_kb_size": 10,
},
}

heroku_redis_ssl_host = {
"address": REDIS_URL, # The 'rediss' schema denotes a SSL connection.
}
Expand Down
3 changes: 2 additions & 1 deletion breathecode/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
path("activity/", include("breathecode.activity.urls.v2", namespace="activity")),
path("registry/", include("breathecode.registry.urls.v2", namespace="registry")),
path("media/", include("breathecode.media.urls.v2", namespace="media")),
path("admissions/", include("breathecode.admissions.urls.v2", namespace="admissions")),
],
}

apps = [
("v1/auth/", "breathecode.authenticate.urls", "auth"),
("v1/admissions/", "breathecode.admissions.urls", "admissions"),
("v1/admissions/", "breathecode.admissions.urls.v1", "admissions"),
("v1/assignment/", "breathecode.assignments.urls", "assignments"),
("v1/freelance/", "breathecode.freelance.urls", "freelance"),
("v1/events/", "breathecode.events.urls", "events"),
Expand Down

0 comments on commit afc0512

Please sign in to comment.