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

Releases/0.1.40 #13

Merged
merged 9 commits into from
Jun 7, 2023
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/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
django-version: ['>3.1', '<3.2', '<3.3', '<4.1']
django-version: ['>3.1', '<3.2', '<3.3', '<4.3']

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

clean: ## Removing cached python compiled files
find . -name \*pyc | xargs rm -fv
find . -name \*pyc | xargs rm -rfv
find . -name \*pyo | xargs rm -fv
find . -name \*~ | xargs rm -fv
find . -name __pycache__ | xargs rm -rfv

install: ## Install dependencies
pip install flit
make clean
flit install --deps develop --symlink
pre-commit install
Expand Down
2 changes: 1 addition & 1 deletion easy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Django Easy API - Easy and Fast Django REST framework based on Django-ninja-extra"""

__version__ = "0.1.39"
__version__ = "0.1.40"

from easy.main import EasyAPI

Expand Down
2 changes: 1 addition & 1 deletion easy/controller/auto_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_api_controller(
},
)

return api_controller(
return api_controller( # type: ignore
f"/{app_name}/{model_name.lower()}",
tags=[f"{model_name} {controller_name_prefix}API"],
permissions=[permission_class],
Expand Down
23 changes: 12 additions & 11 deletions easy/domain/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@


class DjangoOrmModel(CrudModel):
def __init__(self, model: Type[models.Model]):
def __init__(self, model: Optional[Type[models.Model]] = None) -> None:
self.model = model
config = ModelMetaConfig()
exclude_list = config.get_final_excluded_list(self.model())
self.m2m_fields_list: List = list(
_field
for _field in self.model._meta.get_fields(include_hidden=True)
if (
isinstance(_field, models.ManyToManyField)
and ((_field not in exclude_list) if exclude_list else True)
if self.model:
config = ModelMetaConfig()
exclude_list = config.get_final_excluded_list(self.model())
self.m2m_fields_list: List = list(
_field
for _field in self.model._meta.get_fields(include_hidden=True)
if (
isinstance(_field, models.ManyToManyField)
and ((_field not in exclude_list) if exclude_list else True)
)
)
)
super().__init__(self.model)
super().__init__(self.model)

def _separate_payload(self, payload: Dict) -> Tuple[Dict, Dict]:
m2m_fields = {}
Expand Down
7 changes: 2 additions & 5 deletions easy/services/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Type
from typing import Optional, Type

from django.db import models

Expand All @@ -10,9 +10,6 @@


class BaseService(CrudService, PermissionService):
def __init__(
self,
model: Type[models.Model],
):
def __init__(self, model: Optional[Type[models.Model]] = None):
self.model = model
super().__init__(model=self.model)
4 changes: 2 additions & 2 deletions easy/services/crud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Any, Type
from typing import Any, Optional, Type

from asgiref.sync import sync_to_async
from django.db import models
Expand All @@ -10,7 +10,7 @@


class CrudService(DjangoOrmModel):
def __init__(self, model: Type[models.Model]):
def __init__(self, model: Optional[Type[models.Model]] = None):
super().__init__(model)
self.model = model

Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ classifiers = [
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: AsyncIO",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Internet :: WWW/HTTP",
]

requires = [
"Django >= 3.1",
"django-ninja-extra-easy >= 0.15.0",
"django-ninja-extra >= 0.16.0",
]
description-file = "README.md"
requires-python = ">=3.6"
Expand All @@ -64,8 +65,8 @@ test = [
"django-stubs",
"factory-boy==3.2.1",
"django_coverage_plugin",
"django-ninja-extra-easy >= 0.15.0",
"django-ninja-jwt",
"django-ninja-extra >= 0.16.0",
"django-ninja-jwt>=5.1.0",
"Django >= 3.1",
]
dev = [
Expand Down