Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from cookiecutter:master #716

Merged
merged 7 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@
"twitter_username": "Qoyyuum"
},
{
"name": "mfosterw",
"name": "Matthew Foster Walsh",
"github_login": "mfosterw",
"twitter_username": ""
},
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
args: ["--tab-width", "2"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py311-plus]
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ All enhancements and patches to Cookiecutter Django will be documented in this f

<!-- GENERATOR_PLACEHOLDER -->

## 2024.02.21


### Changed

- Switch to `celery.shared_task` to define tasks ([#4881](https://github.com/cookiecutter/cookiecutter-django/pull/4881))

- Replace usages of `get_user_model` by importing model directly ([#4879](https://github.com/cookiecutter/cookiecutter-django/pull/4879))

### Updated

- Auto-update pre-commit hooks ([#4873](https://github.com/cookiecutter/cookiecutter-django/pull/4873))

- Update pre-commit to 3.6.2 ([#4874](https://github.com/cookiecutter/cookiecutter-django/pull/4874))

- Update ruff to 0.2.2 ([#4871](https://github.com/cookiecutter/cookiecutter-django/pull/4871))

## 2024.02.19


Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,13 @@ Listed in alphabetical order.
</td>
<td></td>
</tr>
<tr>
<td>Matthew Foster Walsh</td>
<td>
<a href="https://github.com/mfosterw">mfosterw</a>
</td>
<td></td>
</tr>
<tr>
<td>Matthew Sisley</td>
<td>
Expand Down Expand Up @@ -1489,13 +1496,6 @@ Listed in alphabetical order.
</td>
<td></td>
</tr>
<tr>
<td>mfosterw</td>
<td>
<a href="https://github.com/mfosterw">mfosterw</a>
</td>
<td></td>
</tr>
<tr>
<td>Michael Gecht</td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ binaryornot==0.4.4

# Code quality
# ------------------------------------------------------------------------------
ruff==0.2.1
ruff==0.2.2
django-upgrade==1.16.0
djlint==1.34.1
pre-commit==3.6.1
pre-commit==3.6.2

# Testing
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from distutils.core import setup

# We use calendar versioning
version = "2024.02.19"
version = "2024.02.21"

with open("README.md") as readme_file:
long_description = readme_file.read()
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:

# Run the Ruff linter.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.2.2
hooks:
# Linter
- id: ruff
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ sphinx-autobuild==2024.2.4 # https://github.com/GaretJax/sphinx-autobuild

# Code quality
# ------------------------------------------------------------------------------
ruff==0.2.1 # https://github.com/astral-sh/ruff
ruff==0.2.2 # https://github.com/astral-sh/ruff
coverage==7.4.1 # https://github.com/nedbat/coveragepy
djlint==1.34.1 # https://github.com/Riverside-Healthcare/djLint
pre-commit==3.6.1 # https://github.com/pre-commit/pre-commit
pre-commit==3.6.2 # https://github.com/pre-commit/pre-commit

# Django
# ------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.auth import admin as auth_admin
from django.contrib.auth import decorators
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from django.utils.translation import gettext_lazy as _

from {{ cookiecutter.project_slug }}.users.forms import UserAdminChangeForm
from {{ cookiecutter.project_slug }}.users.forms import UserAdminCreationForm

User = get_user_model()
from {{ cookiecutter.project_slug }}.users.models import User

if settings.DJANGO_ADMIN_FORCE_ALLAUTH:
# Force the `admin` sign in process to go through the `django-allauth` workflow:
# https://docs.allauth.org/en/latest/common/admin.html#admin
admin.site.login = decorators.login_required(admin.site.login) # type: ignore[method-assign]
admin.site.login = login_required(admin.site.login) # type: ignore[method-assign]


@admin.register(User)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from django.contrib.auth import get_user_model
from rest_framework import serializers

from {{ cookiecutter.project_slug }}.users.models import User as UserType
from {{ cookiecutter.project_slug }}.users.models import User

User = get_user_model()


class UserSerializer(serializers.ModelSerializer[UserType]):
class UserSerializer(serializers.ModelSerializer[User]):
class Meta:
model = User
{%- if cookiecutter.username_type == "email" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.contrib.auth import get_user_model
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.mixins import ListModelMixin
Expand All @@ -7,9 +6,9 @@
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

from .serializers import UserSerializer
from {{ cookiecutter.project_slug }}.users.models import User

User = get_user_model()
from .serializers import UserSerializer


class UserViewSet(RetrieveModelMixin, ListModelMixin, UpdateModelMixin, GenericViewSet):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from allauth.account.forms import SignupForm
from allauth.socialaccount.forms import SignupForm as SocialSignupForm
from django.contrib.auth import forms as admin_forms
from django.contrib.auth import get_user_model
{%- if cookiecutter.username_type == "email" %}
from django.forms import EmailField
{%- endif %}
from django.utils.translation import gettext_lazy as _

User = get_user_model()
from {{ cookiecutter.project_slug }}.users.models import User


class UserAdminChangeForm(admin_forms.UserChangeForm):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from django.contrib.auth import get_user_model
from celery import shared_task

from config import celery_app
from {{ cookiecutter.project_slug }}.users.models import User

User = get_user_model()


@celery_app.task()
@shared_task()
def get_users_count():
"""A pointless Celery task to demonstrate usage."""
return User.objects.count()
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from collections.abc import Sequence
from typing import Any

from django.contrib.auth import get_user_model
from factory import Faker
from factory import post_generation
from factory.django import DjangoModelFactory

from {{ cookiecutter.project_slug }}.users.models import User


class UserFactory(DjangoModelFactory):
{%- if cookiecutter.username_type == "username" %}
Expand Down Expand Up @@ -38,5 +39,5 @@ def _after_postgeneration(cls, instance, create, results=None):
instance.save()

class Meta:
model = get_user_model()
model = User
django_get_or_create = ["{{cookiecutter.username_type}}"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.urls import reverse
Expand All @@ -7,7 +6,7 @@
from django.views.generic import RedirectView
from django.views.generic import UpdateView

User = get_user_model()
from {{ cookiecutter.project_slug }}.users.models import User


class UserDetailView(LoginRequiredMixin, DetailView):
Expand Down