-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add .venv * fix: add code checking and type hints * data access layer * quick save * tidy up * add partial_update and destroy * base model serializer * previous_values_are_unequal * feedback * feedback * minor fixes
- Loading branch information
Showing
23 changed files
with
1,593 additions
and
769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Pytest", | ||
"type": "python", | ||
"request": "test", | ||
"justMyCode": false, | ||
"presentation": { | ||
"hidden": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
"""Helpers for module "django.db.models". | ||
https://docs.djangoproject.com/en/3.2/ref/models/ | ||
""" | ||
© Ocado Group | ||
Created on 19/01/2024 at 15:20:45(+00:00). | ||
""" | ||
|
||
import typing as t | ||
|
||
from django.db.models import Model as _Model | ||
|
||
|
||
class Model(_Model): | ||
"""A base class for all Django models. | ||
Args: | ||
_Model (django.db.models.Model): Django's model class. | ||
""" | ||
|
||
id: int | ||
pk: int | ||
|
||
|
||
AnyModel = t.TypeVar("AnyModel", bound=Model) | ||
from .base import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
© Ocado Group | ||
Created on 19/01/2024 at 15:18:48(+00:00). | ||
Base model for all Django models. | ||
""" | ||
|
||
import typing as t | ||
|
||
from django.db.models import Model as _Model | ||
from django_stubs_ext.db.models import TypedModelMeta | ||
|
||
Id = t.TypeVar("Id") | ||
|
||
|
||
class Model(_Model, t.Generic[Id]): | ||
"""A base class for all Django models.""" | ||
|
||
id: Id | ||
pk: Id | ||
|
||
# pylint: disable-next=missing-class-docstring,too-few-public-methods | ||
class Meta(TypedModelMeta): | ||
abstract = True | ||
|
||
|
||
AnyModel = t.TypeVar("AnyModel", bound=Model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
© Ocado Group | ||
Created on 20/01/2024 at 11:19:12(+00:00). | ||
""" | ||
|
||
from .base import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
© Ocado Group | ||
Created on 20/01/2024 at 11:19:24(+00:00). | ||
Base model serializers. | ||
""" | ||
|
||
import typing as t | ||
|
||
from django.db.models import Model | ||
from rest_framework.serializers import ModelSerializer as _ModelSerializer | ||
|
||
AnyModel = t.TypeVar("AnyModel", bound=Model) | ||
|
||
|
||
class ModelSerializer(_ModelSerializer[AnyModel], t.Generic[AnyModel]): | ||
"""Base model serializer for all model serializers.""" | ||
|
||
# pylint: disable-next=useless-parent-delegation | ||
def update(self, instance, validated_data: t.Dict[str, t.Any]): | ||
return super().update(instance, validated_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
from .api import APITestCase, APIClient | ||
from .cron import CronTestCase, CronTestClient | ||
""" | ||
© Ocado Group | ||
Created on 19/01/2024 at 17:17:23(+00:00). | ||
Custom test cases. | ||
""" | ||
|
||
from .cron import CronTestCase | ||
from .model_view_set import ModelViewSetTestCase |
Oops, something went wrong.