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

fixes after removal of NullBooleanField from DRF #85

Merged
merged 2 commits into from
Nov 8, 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
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
django-version: [2.2.20, 3.2.12, 4.0.2]
drf-version: [3.13.1]
include:
- python-version: "3.10"
django-version: 4.1.2
drf-version: 3.14.0
variant: default
- python-version: "3.10"
django-version: 4.0.2
drf-version: 3.13.1
variant: default
- python-version: 3.9
django-version: 3.2.12
drf-version: 3.12.4
variant: default
- python-version: 3.9
django-version: 3.2.12
drf-version: 3.13.1
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
[![Python Support](https://img.shields.io/pypi/pyversions/wq.db.svg)](https://pypi.org/project/wq.db)
[![Django Support](https://img.shields.io/pypi/djversions/wq.db.svg)](https://pypi.org/project/wq.db)

**Note:** EAV mustache context helpers do not work in Django 4.1 and above.

### [Documentation][docs]

[**Installation**][installation]
Expand Down
8 changes: 0 additions & 8 deletions rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def to_representation(self, value):

MODEL_BOOLEAN_FIELDS = (
model_fields.BooleanField,
model_fields.NullBooleanField,
)


Expand Down Expand Up @@ -173,13 +172,6 @@ def get_fields_for_config(self):

if not has_wq_config:
fields.pop(name)
elif isinstance(field, serializers.NullBooleanField):
fields[name] = serializers.ChoiceField(
choices=self.get_boolean_choices(field),
required=False,
label=field.label,
help_text=field.help_text,
)
elif isinstance(field, serializers.BooleanField):
fields[name] = serializers.ChoiceField(
choices=self.get_boolean_choices(field),
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def find_wq_packages(submodule):
long_description_content_type="text/markdown",
install_requires=[
'Django>=1.11,<5.0',
'djangorestframework>=3.8.0,<3.14.0',
'djangorestframework>=3.8.0,<3.15.0',
'html-json-forms',
'natural-keys>=1.6.0',
],
Expand All @@ -75,9 +75,6 @@ def find_wq_packages(submodule):
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand All @@ -90,6 +87,7 @@ def find_wq_packages(submodule):
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Text Processing :: Markup :: HTML',
'Topic :: Scientific/Engineering :: GIS',
Expand Down
2 changes: 1 addition & 1 deletion tests/rest_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=10)),
('active', models.NullBooleanField(default=True)),
('active', models.BooleanField(default=True, null=True)),
],
options={
'abstract': False,
Expand Down
2 changes: 1 addition & 1 deletion tests/rest_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Child(LabelModel):

class ItemType(LabelModel):
name = models.CharField(max_length=10)
active = models.NullBooleanField(default=True)
active = models.BooleanField(default=True, null=True)


class Item(LabelModel):
Expand Down
12 changes: 12 additions & 0 deletions tests/test_custompatterns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
from wq.db import rest
from .base import APITestCase
from rest_framework import status
import django
from django.contrib.auth.models import User
from tests.patterns_app.models import (
CustomPatternModel, CustomTypedPatternModel, CustomType,
Expand All @@ -13,6 +15,8 @@
EntitySerializerCategoryEmpty, EntitySerializerCategoryCtxt,
)

DJANGO_AFTER_4_0 = (django.VERSION[0] >= 4 and django.VERSION[1] > 0)


class CustomPatternTestCase(APITestCase):
def setUp(self):
Expand Down Expand Up @@ -188,6 +192,7 @@ def test_customtypedpattern_put(self):
self.typeinstance.attachments.first().type, self.type
)

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_empty(self):
rest.router.register_serializer(
Entity,
Expand All @@ -198,6 +203,7 @@ def test_eavfilter_empty(self):
[self.att1.id, self.att2.id, self.att3.id, self.att4.id],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_cid(self):
rest.router.register_serializer(
Entity,
Expand All @@ -209,6 +215,7 @@ def test_eavfilter_cid(self):
[self.att3.id, self.att4.id],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_cid_miss(self):
rest.router.register_serializer(
Entity,
Expand All @@ -219,6 +226,7 @@ def test_eavfilter_cid_miss(self):
[],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_isactive(self):
rest.router.register_serializer(
Entity,
Expand All @@ -238,6 +246,7 @@ def test_eavfilter_isactive(self):
[self.att2.id, self.att4.id],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_isactivecid(self):
rest.router.register_serializer(
Entity,
Expand All @@ -249,6 +258,7 @@ def test_eavfilter_isactivecid(self):
[self.att1.id],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_category(self):
rest.router.register_serializer(
Entity,
Expand All @@ -259,6 +269,7 @@ def test_eavfilter_category(self):
[self.att1.id, self.att2.id],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_category_empty(self):
rest.router.register_serializer(
Entity,
Expand All @@ -269,6 +280,7 @@ def test_eavfilter_category_empty(self):
[self.att4.id],
[i['attribute_id'] for i in response.data['values']])

@unittest.skipIf(DJANGO_AFTER_4_0, "EAV mustache context helpers do not work since Django 4.1")
def test_eavfilter_category_ctxt_empty(self):
rest.router.register_serializer(
Entity,
Expand Down
Loading