Skip to content
Open
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
4 changes: 3 additions & 1 deletion files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.contrib.auth import get_user_model
from django.db import models

from django_stubs_ext.db.models import TypedModelMeta

User = get_user_model()


Expand Down Expand Up @@ -31,7 +33,7 @@ def __str__(self):
filename_with_extension = f"{self.name}.{self.extension}"
return f"UserFile<{reprlib.repr(filename_with_extension)}>"

class Meta:
class Meta(TypedModelMeta):
verbose_name = "Файл"
verbose_name_plural = "Файлы"
ordering = ["datetime_uploaded"]
2 changes: 1 addition & 1 deletion files/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from files.models import UserFile


class UserFileSerializer(ModelSerializer):
class UserFileSerializer(ModelSerializer[UserFile]):
class Meta:
model = UserFile
fields = [
Expand Down
3 changes: 2 additions & 1 deletion industries/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django_stubs_ext.db.models import TypedModelMeta


class Industry(models.Model):
Expand All @@ -20,7 +21,7 @@ class Industry(models.Model):
def __str__(self):
return f"Industry<{self.id}> - {self.name}"

class Meta:
class Meta(TypedModelMeta):
verbose_name = "Индустрия"
verbose_name_plural = "Индустрии"
ordering = ["name"]
3 changes: 2 additions & 1 deletion industries/serializers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django_stubs_ext.db.models import TypedModelMeta
from rest_framework import serializers

from industries.models import Industry


class IndustrySerializer(serializers.ModelSerializer):
class Meta:
class Meta(TypedModelMeta):
model = Industry
fields = ["id", "name", "datetime_created"]
2 changes: 1 addition & 1 deletion industries/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_industry_update_with_wrong_data(self):

self.assertEqual(response.status_code, 400)

def _user_create(self):
def _user_create(self) -> CustomUser:
request = self.factory.post("auth/users/", USER_CREATE_DATA)
response = self.user_list_view(request)
user_id = response.data["id"]
Expand Down
4 changes: 3 additions & 1 deletion mailing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.db import models
from .constants import get_default_mailing_schema

from django_stubs_ext.db.models import TypedModelMeta


def get_template_path(instance, filename):
ext = filename.split(".")[-1]
Expand All @@ -16,7 +18,7 @@ class MailingSchema(models.Model):
schema = models.JSONField(default=get_default_mailing_schema, null=True, blank=True)
template = models.TextField()

class Meta:
class Meta(TypedModelMeta):
verbose_name = "Схема шаблона письма"
verbose_name_plural = "Схемы шаблонов писем"

Expand Down
5 changes: 3 additions & 2 deletions mailing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from django.http import JsonResponse
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.request import Request

from users.models import CustomUser
from .utils import send_mass_mail
from .models import MailingSchema


class SendMailView(APIView):
def post(self, request):
def post(self, request: Request) -> JsonResponse:
users = request.POST.getlist("users[]")
schema_id = request.POST["schemas"]
subject = request.POST["subject"]
Expand All @@ -30,7 +31,7 @@ def get(self, request):


class TemplateFieldsView(APIView):
def get(self, request, schema_id):
def get(self, request: Request, schema_id: int) -> JsonResponse:
return JsonResponse(
dict(MailingTemplateRender().get_template_fields_context(schema_id))
)
Expand Down