Fix style in users api views and serializers

This commit is contained in:
Bruno Alla 2023-04-04 22:24:45 +01:00
parent fc06128f9e
commit 742321f64d
No known key found for this signature in database
4 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ User = get_user_model()
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
{% if cookiecutter.username_type == "email" -%}
{%- if cookiecutter.username_type == "email" %}
fields = ["name", "url"]
extra_kwargs = {

View File

@ -13,7 +13,7 @@ User = get_user_model()
class UserViewSet(RetrieveModelMixin, ListModelMixin, UpdateModelMixin, GenericViewSet):
serializer_class = UserSerializer
queryset = User.objects.all()
{% if cookiecutter.username_type == "email" -%}
{%- if cookiecutter.username_type == "email" %}
lookup_field = "pk"
{%- else %}
lookup_field = "username"

View File

@ -4,7 +4,7 @@ from {{ cookiecutter.project_slug }}.users.models import User
def test_user_detail(user: User):
{% if cookiecutter.username_type == "email" -%}
{%- if cookiecutter.username_type == "email" %}
assert (
reverse("api:user-detail", kwargs={"pk": user.pk})
== f"/api/users/{user.pk}/"

View File

@ -29,7 +29,7 @@ class TestUserViewSet:
response = view.me(request) # type: ignore
assert response.data == {
{% if cookiecutter.username_type == "email" -%}
{%- if cookiecutter.username_type == "email" %}
"url": f"http://testserver/api/users/{user.pk}/",
{%- else %}
"username": user.username,