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

chore: update dependencies #1660

Merged
merged 2 commits into from
Jan 20, 2022
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/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ updates:
ignore:
- dependency-name: django
versions:
- ">=3"
- ">=3.3"
commit-message:
prefix: chore
include: scope
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7.6@sha256:46e17eae392c2d99e0ac9c26e867807c5022958ec19a9cc46b9668962e0dff78
FROM python:3.7.12@sha256:3908249ce6b2d28284e3610b07bf406c3035bc2e3ce328711a2b42e1c5a75fc1

WORKDIR /app

Expand Down
10 changes: 6 additions & 4 deletions caluma/caluma_core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import graphene
from django import forms
from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.contrib.postgres.fields.hstore import KeyTransform
from django.contrib.postgres.fields.jsonb import KeyTextTransform
from django.contrib.postgres.search import SearchVector
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import OrderBy, RawSQL
from django.db.models.fields.json import KeyTextTransform
from django.db.models.functions import Cast
from django.utils import translation
from django_filters.constants import EMPTY_VALUES
Expand Down Expand Up @@ -328,7 +327,7 @@ def _build_search_expression(self, field_lookup):
if isinstance(model_field, LocalizedField):
lang = translation.get_language()
return KeyTransform(lang, field_lookup)
elif isinstance(model_field, JSONField):
elif isinstance(model_field, models.JSONField):
return Cast(field_lookup, models.TextField())

return field_lookup
Expand Down Expand Up @@ -480,7 +479,10 @@ def filter(self, qs, value):
# https://code.djangoproject.com/ticket/26511
if isinstance(expr["value"], str):
qs = qs.annotate(
field_val=KeyTextTransform(expr["key"], self.field_name)
field_val=Cast(
KeyTextTransform(expr["key"], self.field_name),
models.CharField(),
),
)
lookup = {f"field_val__{lookup_expr}": expr["value"]}
else:
Expand Down
14 changes: 12 additions & 2 deletions caluma/caluma_core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from graphene_django import types
from graphene_django.fields import DjangoConnectionField
from graphene_django.utils import maybe_queryset
from graphql_relay.connection.arrayconnection import get_offset_with_default

from .pagination import connection_from_list, connection_from_list_slice

Expand Down Expand Up @@ -68,7 +69,7 @@ class DjangoConnectionField(DjangoConnectionField):
"""

@classmethod
def resolve_connection(cls, connection, args, iterable):
def resolve_connection(cls, connection, args, iterable, max_limit):
iterable = maybe_queryset(iterable)
if isinstance(iterable, QuerySet):
# only query count on database when pagination is needed
Expand All @@ -80,8 +81,17 @@ def resolve_connection(cls, connection, args, iterable):
_len = len(iterable)
else: # pragma: no cover
_len = len(iterable)

# If after is higher than list_length, connection_from_list_slice
# would try to do a negative slicing which makes django throw an
# AssertionError
after = min(get_offset_with_default(args.get("after"), -1) + 1, _len)

if max_limit is not None and "first" not in args:
args["first"] = max_limit

connection = connection_from_list_slice(
iterable,
iterable[after:],
args,
slice_start=0,
list_length=_len,
Expand Down
15 changes: 7 additions & 8 deletions caluma/caluma_form/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import uuid

import django.contrib.postgres.fields.jsonb
import django.db.models.deletion
import localized_fields.fields.field
from django.db import migrations, models
Expand Down Expand Up @@ -39,8 +38,8 @@ class Migration(migrations.Migration):
serialize=False,
),
),
("value", django.contrib.postgres.fields.jsonb.JSONField()),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default={})),
("value", models.JSONField()),
("meta", models.JSONField(default={})),
],
),
migrations.CreateModel(
Expand All @@ -65,7 +64,7 @@ class Migration(migrations.Migration):
serialize=False,
),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default={})),
("meta", models.JSONField(default={})),
],
options={"abstract": False},
),
Expand All @@ -90,7 +89,7 @@ class Migration(migrations.Migration):
blank=True, null=True, required=[]
),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default={})),
("meta", models.JSONField(default={})),
("is_published", models.BooleanField(default=False)),
("is_archived", models.BooleanField(default=False)),
],
Expand Down Expand Up @@ -149,7 +148,7 @@ class Migration(migrations.Migration):
),
("slug", models.SlugField(primary_key=True, serialize=False)),
("label", localized_fields.fields.field.LocalizedField(required=[])),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default={})),
("meta", models.JSONField(default={})),
],
options={"abstract": False},
),
Expand Down Expand Up @@ -187,9 +186,9 @@ class Migration(migrations.Migration):
("is_archived", models.BooleanField(default=False)),
(
"configuration",
django.contrib.postgres.fields.jsonb.JSONField(default={}),
models.JSONField(default={}),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default={})),
("meta", models.JSONField(default={})),
],
options={"abstract": False},
),
Expand Down
13 changes: 6 additions & 7 deletions caluma/caluma_form/migrations/0002_auto_20181221_1517.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Generated by Django 1.11.17 on 2018-12-21 15:17
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models


Expand All @@ -21,7 +20,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="answer",
name="meta",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name="document",
Expand All @@ -33,7 +32,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="document",
name="meta",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name="form",
Expand All @@ -45,7 +44,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="form",
name="meta",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name="formquestion",
Expand All @@ -64,12 +63,12 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="option",
name="meta",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name="question",
name="configuration",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name="question",
Expand All @@ -81,7 +80,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="question",
name="meta",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name="questionoption",
Expand Down
3 changes: 1 addition & 2 deletions caluma/caluma_form/migrations/0003_auto_20190130_0920.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import uuid

import django.contrib.postgres.fields.jsonb
import django.db.models.deletion
from django.db import migrations, models

Expand Down Expand Up @@ -72,7 +71,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="answer",
name="value",
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True),
field=models.JSONField(blank=True, null=True),
),
migrations.AlterField(
model_name="question",
Expand Down
3 changes: 1 addition & 2 deletions caluma/caluma_form/migrations/0008_auto_20190319_1720.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Generated by Django 1.11.20 on 2019-03-19 17:20
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
import django.core.serializers.json
from django.db import migrations, models

Expand All @@ -15,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="answer",
name="value",
field=django.contrib.postgres.fields.jsonb.JSONField(
field=models.JSONField(
blank=True,
encoder=django.core.serializers.json.DjangoJSONEncoder,
null=True,
Expand Down
3 changes: 1 addition & 2 deletions caluma/caluma_form/migrations/0011_auto_20190411_0607.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Generated by Django 1.11.20 on 2019-04-11 06:07
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models


Expand All @@ -19,6 +18,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="answer",
name="value",
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True),
field=models.JSONField(blank=True, null=True),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import uuid

import django.contrib.postgres.fields
import django.contrib.postgres.fields.jsonb
import django.db.models.deletion
import localized_fields.fields.field
import localized_fields.fields.text_field
Expand Down Expand Up @@ -40,11 +39,9 @@ class Migration(migrations.Migration):
),
(
"value",
django.contrib.postgres.fields.jsonb.JSONField(
blank=True, null=True
),
models.JSONField(blank=True, null=True),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
("meta", models.JSONField(default=dict)),
("date", models.DateField(blank=True, null=True)),
(
"history_id",
Expand Down Expand Up @@ -205,7 +202,7 @@ class Migration(migrations.Migration):
db_index=True, help_text="Family id which document belongs too."
),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
("meta", models.JSONField(default=dict)),
(
"history_id",
models.UUIDField(
Expand Down Expand Up @@ -314,7 +311,7 @@ class Migration(migrations.Migration):
blank=True, null=True, required=[]
),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
("meta", models.JSONField(default=dict)),
("is_published", models.BooleanField(default=False)),
("is_archived", models.BooleanField(default=False)),
(
Expand Down Expand Up @@ -447,7 +444,7 @@ class Migration(migrations.Migration):
("history_user_id", models.CharField(max_length=150, null=True)),
("slug", models.SlugField()),
("label", localized_fields.fields.field.LocalizedField(required=[])),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
("meta", models.JSONField(default=dict)),
(
"history_id",
models.UUIDField(
Expand Down Expand Up @@ -548,9 +545,9 @@ class Migration(migrations.Migration):
),
(
"configuration",
django.contrib.postgres.fields.jsonb.JSONField(default=dict),
models.JSONField(default=dict),
),
("meta", django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
("meta", models.JSONField(default=dict)),
(
"data_source",
models.CharField(blank=True, max_length=255, null=True),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 3.2.11 on 2022-01-19 09:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("caluma_form", "0042_auto_20220110_1051"),
]

operations = [
migrations.AlterField(
model_name="historicalanswer",
name="history_question_type",
field=models.CharField(
choices=[
("multiple_choice", "multiple_choice"),
("integer", "integer"),
("float", "float"),
("date", "date"),
("choice", "choice"),
("textarea", "textarea"),
("text", "text"),
("table", "table"),
("form", "form"),
("file", "file"),
("dynamic_choice", "dynamic_choice"),
("dynamic_multiple_choice", "dynamic_multiple_choice"),
("static", "static"),
("calculated_float", "calculated_float"),
("action_button", "action_button"),
],
max_length=23,
),
),
]
Loading