Skip to content

Commit

Permalink
migrate to capy core i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Oct 31, 2024
1 parent 1318fa4 commit f87a23f
Show file tree
Hide file tree
Showing 44 changed files with 512 additions and 688 deletions.
787 changes: 445 additions & 342 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions breathecode/activity/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib.auth.models import User
from django.db.models import Avg, Count, Q, Sum
from google.cloud import bigquery
Expand All @@ -14,8 +16,6 @@
from breathecode.authenticate.actions import get_user_language
from breathecode.services.google_cloud.big_query import BigQuery
from breathecode.utils import HeaderLimitOffsetPagination, capable_of, getLogger
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .utils import (
generate_created_at,
Expand Down
6 changes: 3 additions & 3 deletions breathecode/admissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

import pytz
from adrf.decorators import api_view
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib.auth.models import AnonymousUser, User
from django.db.models import FloatField, Max, Q, Value
from django.utils import timezone
from slugify import slugify
from rest_framework import status
from rest_framework.decorators import permission_classes
from rest_framework.exceptions import ParseError, PermissionDenied, ValidationError
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from slugify import slugify

from breathecode.admissions import tasks
from breathecode.admissions.caches import CohortCache, CohortUserCache, SyllabusVersionCache, TeacherCache, UserCache
Expand All @@ -26,8 +28,6 @@
localize_query,
)
from breathecode.utils.find_by_full_name import query_like_by_full_name
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .actions import find_asset_on_json, test_syllabus, update_asset_on_json
from .models import (
Expand Down
4 changes: 2 additions & 2 deletions breathecode/assessment/serializers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib.auth.models import AnonymousUser
from django.utils import timezone
from rest_framework import serializers

from breathecode.admissions.models import Academy
from breathecode.utils import serpy
from breathecode.utils.datetime_integer import duration_to_str, from_now
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .models import Answer, Assessment, Option, Question, UserAssessment

Expand Down
5 changes: 3 additions & 2 deletions breathecode/assessment/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from datetime import datetime

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.db.models import Q
from django.utils import timezone
from rest_framework import status
Expand All @@ -12,8 +15,6 @@
from breathecode.marketing.serializers import FormEntryBigSerializer, PostFormEntrySerializer
from breathecode.marketing.tasks import persist_single_lead
from breathecode.utils import APIViewExtensions, GenerateLookupsMixin, capable_of
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .models import Answer, Assessment, AssessmentLayout, AssessmentThreshold, Option, Question, UserAssessment
from .serializers import (
Expand Down
5 changes: 3 additions & 2 deletions breathecode/assignments/permissions/consumers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import PaymentException

from breathecode.admissions.actions import is_no_saas_student_up_to_date_in_any_cohort
from breathecode.authenticate.actions import get_user_language
from breathecode.payments.models import Service
from breathecode.utils.decorators import ServiceContext
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import PaymentException

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion breathecode/assignments/receivers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging
from typing import Any, Type

from capyc.core.i18n import translation
from django.dispatch import receiver

from breathecode.admissions.signals import syllabus_asset_slug_updated
from breathecode.assignments import tasks
from breathecode.authenticate.actions import get_user_settings
from breathecode.authenticate.models import CredentialsGithub
from breathecode.notify.actions import send_email_message
from breathecode.utils.i18n import translation

from .models import RepositoryDeletionOrder, Task
from .signals import assignment_status_updated, status_updated
Expand Down
2 changes: 1 addition & 1 deletion breathecode/assignments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from adrf.views import APIView
from asgiref.sync import sync_to_async
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from circuitbreaker import CircuitBreakerError
from django.contrib import messages
Expand All @@ -30,7 +31,6 @@
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import consume, has_permission
from breathecode.utils.decorators.capable_of import acapable_of
from breathecode.utils.i18n import translation
from breathecode.utils.multi_status_response import MultiStatusResponse

from .actions import deliver_task, sync_cohort_tasks
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from adrf.requests import AsyncRequest
from asgiref.sync import sync_to_async
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib.auth.models import User
from django.core.handlers.wsgi import WSGIRequest
from django.db.models import Q
Expand All @@ -17,8 +19,6 @@
import breathecode.notify.actions as notify_actions
from breathecode.admissions.models import Academy, CohortUser
from breathecode.services.github import Github
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .models import (
AcademyAuthSettings,
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import random
import urllib.parse

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib.auth.models import Permission, User
from django.db import IntegrityError
from django.db.models import Q
Expand All @@ -18,8 +20,6 @@
from breathecode.events.models import Event
from breathecode.registry.models import Asset
from breathecode.utils import serpy, validate_conversion_info
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .models import (
AcademyAuthSettings,
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
import os

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from celery import shared_task
from django.contrib.auth.models import User
from task_manager.core.exceptions import AbortTask, RetryTask
Expand All @@ -10,8 +12,6 @@
from breathecode.marketing.actions import validate_email
from breathecode.notify import actions as notify_actions
from breathecode.utils.decorators import TaskPriority
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .actions import add_to_organization, get_user_settings, remove_from_organization, set_gitpod_user_expiration

Expand Down
2 changes: 1 addition & 1 deletion breathecode/authenticate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from adrf.decorators import api_view
from adrf.views import APIView
from asgiref.sync import sync_to_async
from capyc.core.i18n import translation
from capyc.core.managers import feature
from capyc.rest_framework.exceptions import ValidationException
from circuitbreaker import CircuitBreakerError
Expand Down Expand Up @@ -50,7 +51,6 @@
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import has_permission
from breathecode.utils.find_by_full_name import query_like_by_full_name
from breathecode.utils.i18n import translation
from breathecode.utils.shorteners import C
from breathecode.utils.views import private_view, render_message, set_query_parameter

Expand Down
4 changes: 2 additions & 2 deletions breathecode/events/permissions/consumers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import PaymentException, ValidationException
from django.db.models import Q
from django.utils import timezone

Expand All @@ -9,8 +11,6 @@
from breathecode.events.actions import get_my_event_types
from breathecode.events.models import Event, LiveClass
from breathecode.utils.decorators import ServiceContext
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import PaymentException, ValidationException

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions breathecode/events/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from datetime import timedelta
from typing import Any

from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.db.models.query_utils import Q
from django.utils import timezone
from rest_framework import serializers
Expand All @@ -15,8 +17,6 @@
from breathecode.registry.models import Asset
from breathecode.registry.serializers import AssetSmallSerializer
from breathecode.utils import serpy
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .models import Event, EventbriteWebhook, EventCheckin, EventType, LiveClass, Organization

Expand Down
4 changes: 2 additions & 2 deletions breathecode/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from datetime import datetime, timedelta

import pytz
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib.auth.models import User
from django.db.models.query_utils import Q
from django.http.response import HttpResponse
Expand Down Expand Up @@ -36,10 +38,8 @@
)
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import consume
from breathecode.utils.i18n import translation
from breathecode.utils.multi_status_response import MultiStatusResponse
from breathecode.utils.views import private_view, render_message
from capyc.rest_framework.exceptions import ValidationException

from .actions import fix_datetime_weekday, get_my_event_types, update_timeslots_out_of_range
from .models import (
Expand Down
2 changes: 1 addition & 1 deletion breathecode/marketing/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import numpy as np
import requests
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.db.models import Q
from django.utils import timezone
Expand All @@ -17,7 +18,6 @@
from breathecode.services.activecampaign import ACOldClient, ActiveCampaign, ActiveCampaignClient, acp_ids, map_ids
from breathecode.services.brevo import Brevo
from breathecode.utils import getLogger
from breathecode.utils.i18n import translation

from .models import AcademyAlias, ActiveCampaignAcademy, Automation, FormEntry, Tag

Expand Down
2 changes: 1 addition & 1 deletion breathecode/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import pandas as pd
import pytz
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from circuitbreaker import CircuitBreakerError
from django.contrib.auth.models import AnonymousUser
Expand Down Expand Up @@ -37,7 +38,6 @@
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import validate_captcha, validate_captcha_challenge
from breathecode.utils.find_by_full_name import query_like_by_full_name
from breathecode.utils.i18n import translation

from .actions import convert_data_frame, sync_automations, sync_tags, validate_email
from .models import (
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Awaitable, Callable, Literal, Optional, Type, TypedDict

from adrf.requests import AsyncRequest
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
from PIL import Image
Expand All @@ -11,7 +12,6 @@
from breathecode.media.models import Chunk, File
from breathecode.notify.models import Notification
from breathecode.services.google_cloud.storage import Storage
from breathecode.utils.i18n import translation

type TypeValidator = Callable[[str, Any], None]
type TypeValidatorWrapper = Callable[[Type[Any]], TypeValidator]
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tasks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging
from typing import Any, Optional

from capyc.core.i18n import translation
from django.core.cache import cache
from task_manager.core.exceptions import AbortTask, RetryTask
from task_manager.django.decorators import task

from breathecode.authenticate.actions import get_user_settings
from breathecode.notify.models import Notification
from breathecode.utils.decorators import TaskPriority
from breathecode.utils.i18n import translation

from .models import File
from .utils import media_settings
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, Optional, Tuple, overload

from adrf.views import APIView
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from rest_framework import status
from rest_framework.response import Response
Expand All @@ -15,7 +16,6 @@
from breathecode.media.models import Chunk, File
from breathecode.media.signals import schedule_deletion
from breathecode.services.google_cloud.storage import Storage
from breathecode.utils.i18n import translation

from .settings import MEDIA_MIME_ALLOWED, MEDIA_SETTINGS, MediaSettings, Schema

Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import requests
from adrf.views import APIView
from adrf.viewsets import ViewSet
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from circuitbreaker import CircuitBreakerError
from django.db.models import Q
Expand Down Expand Up @@ -35,7 +36,6 @@
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import has_permission
from breathecode.utils.decorators.capable_of import acapable_of
from breathecode.utils.i18n import translation

logger = logging.getLogger(__name__)
MIME_ALLOWED = [
Expand Down
2 changes: 1 addition & 1 deletion breathecode/mentorship/permissions/consumers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from capyc.core.i18n import translation
from capyc.core.managers import feature
from capyc.rest_framework.exceptions import PaymentException, ValidationException

Expand All @@ -9,7 +10,6 @@
from breathecode.mentorship.models import MentorProfile, MentorshipService
from breathecode.payments.models import Consumable, ConsumptionSession
from breathecode.utils.decorators import ServiceContext
from breathecode.utils.i18n import translation

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions breathecode/mentorship/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from rest_framework import serializers

import breathecode.activity.tasks as tasks_activity
Expand All @@ -8,8 +10,6 @@
from breathecode.services.calendly import Calendly
from breathecode.utils import serpy
from breathecode.utils.datetime_integer import duration_to_str
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import ValidationException

from .actions import generate_mentor_bill
from .models import CalendlyOrganization, MentorProfile, MentorshipBill, MentorshipService, MentorshipSession
Expand Down
2 changes: 1 addition & 1 deletion breathecode/mentorship/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import urllib.parse

import timeago
from capyc.core.i18n import translation
from capyc.rest_framework.exceptions import ValidationException
from django.contrib import messages
from django.contrib.auth.models import User
Expand Down Expand Up @@ -36,7 +37,6 @@
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import consume, has_permission
from breathecode.utils.find_by_full_name import query_like_by_full_name
from breathecode.utils.i18n import translation
from breathecode.utils.multi_status_response import MultiStatusResponse
from breathecode.utils.views import private_view, render_message, set_query_parameter

Expand Down
Loading

0 comments on commit f87a23f

Please sign in to comment.