Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Merge branch 'tough-dev-school:master' into lesson1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKupreev authored Sep 23, 2023
2 parents a010229 + 352aa9b commit 73203ab
Show file tree
Hide file tree
Showing 22 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
run: cp config/.env.template config/.env

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build the image
uses: docker/bake-action@v3
uses: docker/bake-action@v4
with:
files: docker-compose.yml
targets: web
Expand Down
4 changes: 2 additions & 2 deletions .importlinter
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ containers =
layers =
(urls) | (admin)
(views)
(infrastructure)
(container)
(logic)
(infrastructure)
(models)
(container)


[importlinter:contract:apps-independence]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UserResponse(pydantic_model.BaseModel):
# TODO: use redis-based caching
@final
class LeadCreate(http.BaseFetcher):
"""Service around creating new users and fething their :term:`lead_id`."""
"""Service around creating new users and fetching their :term:`lead_id`."""

_url_path = '/users'

Expand All @@ -33,7 +33,7 @@ def __call__(
timeout=self._api_timeout,
)
response.raise_for_status()
return UserResponse.parse_raw(response.text)
return UserResponse.model_validate_json(response.text)


@final
Expand Down
2 changes: 1 addition & 1 deletion server/apps/identity/logic/usecases/user_create_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import attr

from server.apps.identity.intrastructure.services import placeholder
from server.apps.identity.infrastructure.services import placeholder
from server.apps.identity.models import User
from server.common.django.types import Settings

Expand Down
2 changes: 1 addition & 1 deletion server/apps/identity/logic/usecases/user_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import attr

from server.apps.identity.intrastructure.services import placeholder
from server.apps.identity.infrastructure.services import placeholder
from server.apps.identity.models import User
from server.common.django.types import Settings

Expand Down
4 changes: 2 additions & 2 deletions server/apps/identity/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from ratelimit.mixins import RatelimitMixin

from server.apps.identity.container import container
from server.apps.identity.intrastructure.django.decorators import (
from server.apps.identity.infrastructure.django.decorators import (
redirect_logged_in_users,
)
from server.apps.identity.intrastructure.django.forms import (
from server.apps.identity.infrastructure.django.forms import (
AuthenticationForm,
RegistrationForm,
)
Expand Down
4 changes: 2 additions & 2 deletions server/apps/identity/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ratelimit.mixins import RatelimitMixin

from server.apps.identity.container import container
from server.apps.identity.intrastructure.django.forms import UserUpdateForm
from server.apps.identity.infrastructure.django.forms import UserUpdateForm
from server.apps.identity.logic.usecases.user_update import UserUpdate
from server.apps.identity.models import User
from server.common.django.decorators import dispatch_decorator
Expand All @@ -31,7 +31,7 @@ class UserUpdateView(RatelimitMixin, UpdateView[User, UserUpdateForm]):
ratelimit_key = 'ip'
ratelimit_rate = '10/h'
ratelimit_block = True
retelimit_method = ['POST', 'PUT'] # GET is safe
ratelimit_method = ['POST', 'PUT'] # GET is safe

def get_object(self, queryset: QuerySet[User] | None = None) -> User:
"""We only work with the current user."""
Expand Down
2 changes: 1 addition & 1 deletion server/apps/pictures/logic/usecases/pictures_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import attr

from server.apps.pictures.intrastructure.services import placeholder
from server.apps.pictures.infrastructure.services import placeholder
from server.common.django.types import Settings


Expand Down
2 changes: 1 addition & 1 deletion server/apps/pictures/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ class FavouritePicture(TimedMixin, models.Model):
url = models.URLField()

def __str__(self) -> str:
"""Beatuful representation."""
"""Beautiful representation."""
return '<Picture {0} by {1}>'.format(self.foreign_id, self.user_id)
8 changes: 4 additions & 4 deletions server/apps/pictures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.views.generic import CreateView, ListView, TemplateView

from server.apps.pictures.container import container
from server.apps.pictures.intrastructure.django.forms import FavouritesForm
from server.apps.pictures.infrastructure.django.forms import FavouritesForm
from server.apps.pictures.logic.usecases import favourites_list, pictures_fetch
from server.apps.pictures.models import FavouritePicture
from server.common.django.decorators import dispatch_decorator
Expand Down Expand Up @@ -40,11 +40,11 @@ class DashboardView(CreateView[FavouritePicture, FavouritesForm]):
success_url = reverse_lazy('pictures:dashboard')

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
"""Innject extra context to template rendering."""
fetch_puctures = container.instantiate(pictures_fetch.PicturesFetch)
"""Inject extra context to template rendering."""
fetch_pictures = container.instantiate(pictures_fetch.PicturesFetch)

context = super().get_context_data(**kwargs)
context['pictures'] = fetch_puctures() # sync http call, may hang
context['pictures'] = fetch_pictures() # sync http call, may hang
return context

def get_form_kwargs(self) -> dict[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if messages %}
{% for message in messages %}
{# We don't have any non-succesful messages just yet #}
{# We don't have any non-successful messages just yet #}
<p>{{ message }}</p>
{% endfor %}
{% endif %}
2 changes: 1 addition & 1 deletion tests/test_server/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from plugins.identity.user import ProfileAssertion, ProfileDataFactory


@pytest.mark.django_db()()
@pytest.mark.django_db()
def test_health_check(client: Client) -> None:
"""This test ensures that health check is accessible."""
response = client.get('/health/')
Expand Down

0 comments on commit 73203ab

Please sign in to comment.