Skip to content

Commit

Permalink
feat: upgrade Django to 4.2 & upgrade all packages to latest
Browse files Browse the repository at this point in the history
done:
 - upgrade postgres from 11 to 12
   - required, didn't work without this change
 - change import paths
   - graphql.execution.base.ResolveInfo ->
     graphql.type.GraphQLResolveInfo
 - add arbitrary primary keys to objects used in dummy notification
   contexts because factory's build doesn't create a primary key yet,
   and without it generating the URLs using the object's ID fails
 - remove QUERY_TOO_DEEP_ERROR and DepthAnalysisBackend, use graphene's
   depth_limit_validator instead which should give a GraphQLError like
   `<operation_name> exceeds maximum operation depth of <max_depth>.
 - fix executed_graphql_request() has no `invalid` member
 - fix graphene enums to work similarly to graphene v2 -> using values
   - graphene v3 changed enums so they work differently than in
     graphene v2, forcing backward compatibility by converting enums
     to their values
 - fix using django-parler translations, map enums to their values
 - fix enums in TranslatableQuerySet objects, map them to their values

refs KK-1108
  • Loading branch information
karisal-anders committed Jul 17, 2024
1 parent 718d92c commit f9a8200
Show file tree
Hide file tree
Showing 53 changed files with 922 additions and 829 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.0
hooks:
- id: flake8
args: ['--config=setup.cfg', '--ignore=W503,E741']
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ==============================
FROM registry.access.redhat.com/ubi9/python-39 as appbase
FROM registry.access.redhat.com/ubi9/python-39 AS appbase
# ==============================

USER root
Expand All @@ -20,7 +20,7 @@ COPY --chown=default:root docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]

# ==============================
FROM appbase as development
FROM appbase AS development
# ==============================

COPY --chown=default:root requirements-dev.txt /app/requirements-dev.txt
Expand All @@ -34,7 +34,7 @@ USER default
EXPOSE 8081/tcp

# ==============================
FROM appbase as production
FROM appbase AS production
# ==============================

COPY --chown=default:root . /app/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The project is now running at [localhost:8081](http://localhost:8081)

Prerequisites:

- PostgreSQL 11
- PostgreSQL 12
- Python 3.9

### Installing Python requirements
Expand Down
2 changes: 2 additions & 0 deletions children/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ChildFactory(factory.django.DjangoModelFactory):

class Meta:
model = Child
skip_postgeneration_save = True # Not needed after factory v4.0.0


class RelationshipFactory(factory.django.DjangoModelFactory):
Expand All @@ -35,6 +36,7 @@ class RelationshipFactory(factory.django.DjangoModelFactory):

class Meta:
model = Relationship
skip_postgeneration_save = True # Not needed after factory v4.0.0


class ChildWithGuardianFactory(ChildFactory):
Expand Down
15 changes: 11 additions & 4 deletions children/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import binascii
import datetime
import logging
from datetime import datetime, timedelta
from datetime import timedelta

import graphene
from django.conf import settings
Expand All @@ -19,7 +20,7 @@

from children.notifications import NotificationType
from common.schema import set_obj_languages_spoken_at_home
from common.utils import login_required, update_object
from common.utils import login_required, map_enums_to_values_in_kwargs, update_object
from events.models import Event, Occurrence
from kukkuu.exceptions import (
ApiUsageError,
Expand Down Expand Up @@ -267,7 +268,7 @@ def resolve_active_internal_and_ticket_system_enrolments(self, info, **kwargs):
)
)

datetime_max = make_aware(datetime.max, timezone=timezone.utc)
datetime_max = make_aware(datetime.datetime.max, timezone=datetime.timezone.utc)
return sorted(
(
*EnrolmentNode.get_queryset(internal_enrolments, info),
Expand Down Expand Up @@ -391,6 +392,7 @@ class Input:
@classmethod
@login_required
@transaction.atomic
@map_enums_to_values_in_kwargs
def mutate_and_get_payload(cls, root, info, **kwargs):
user = info.context.user
if hasattr(user, "guardian"):
Expand Down Expand Up @@ -478,6 +480,7 @@ class Input(BaseNewChildInput):
@classmethod
@login_required
@transaction.atomic
@map_enums_to_values_in_kwargs
def mutate_and_get_payload(cls, root, info, **kwargs):
user = info.context.user
if not hasattr(user, "guardian"):
Expand Down Expand Up @@ -521,6 +524,7 @@ class Input(BaseUpdateChildInput):
@classmethod
@login_required
@transaction.atomic
@map_enums_to_values_in_kwargs
def mutate_and_get_payload(cls, root, info, **kwargs):
validate_child_data(kwargs)
user = info.context.user
Expand Down Expand Up @@ -558,6 +562,7 @@ class Input:
@classmethod
@login_required
@transaction.atomic
@map_enums_to_values_in_kwargs
def mutate_and_get_payload(cls, root, info, **kwargs):
user = info.context.user

Expand Down Expand Up @@ -586,6 +591,7 @@ class Input:
@classmethod
@login_required
@transaction.atomic
@map_enums_to_values_in_kwargs
def mutate_and_get_payload(cls, root, info, **kwargs):
user = info.context.user
child_global_id = kwargs.pop("child_id")
Expand Down Expand Up @@ -636,9 +642,10 @@ def resolve_child_notes(self, info, id):
)

if id_type != "ChildNode":
formatted_id_type = "empty" if id_type == "" else id_type
raise ApiUsageError(
"childNotes must be queried using ChildNode type ID, "
+ f"was queried with {id_type} type ID"
+ f"was queried with {formatted_id_type} type ID"
)
return ChildNotesNode.get_node(info, child_id)

Expand Down
14 changes: 7 additions & 7 deletions children/tests/snapshots/snap_test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"email": "[email protected]",
"firstName": "Denise",
"lastName": "Thompson",
"phoneNumber": "001-067-506-4976x3803",
"phoneNumber": "001-206-575-0649x7638",
},
"type": "OTHER_RELATION",
}
Expand All @@ -132,7 +132,7 @@
"email": "[email protected]",
"firstName": "Timothy",
"lastName": "Baldwin",
"phoneNumber": "803.466.9727",
"phoneNumber": "480.934.6697",
},
"type": "PARENT",
}
Expand Down Expand Up @@ -202,7 +202,7 @@
"email": "[email protected]",
"firstName": "Denise",
"lastName": "Thompson",
"phoneNumber": "001-067-506-4976x3803",
"phoneNumber": "001-206-575-0649x7638",
},
"type": "OTHER_RELATION",
}
Expand Down Expand Up @@ -250,7 +250,7 @@
"email": "[email protected]",
"firstName": "Blake",
"lastName": "Newton",
"phoneNumber": "976-380-3466x9727",
"phoneNumber": "497-963-8034x6697",
},
"type": "PARENT",
}
Expand Down Expand Up @@ -281,7 +281,7 @@
"email": "[email protected]",
"firstName": "Sarah",
"lastName": "Larsen",
"phoneNumber": "8981710123",
"phoneNumber": "4895817101",
},
"type": "OTHER_RELATION",
}
Expand All @@ -303,7 +303,7 @@
"email": "[email protected]",
"firstName": "Michael",
"lastName": "Patton",
"phoneNumber": "355.777.6712x406",
"phoneNumber": "235.857.7767x124",
},
"type": "OTHER_GUARDIAN",
}
Expand All @@ -325,7 +325,7 @@
"email": "[email protected]",
"firstName": "Michael",
"lastName": "Patton",
"phoneNumber": "355.777.6712x406",
"phoneNumber": "235.857.7767x124",
},
"type": "OTHER_GUARDIAN",
}
Expand Down
Loading

0 comments on commit f9a8200

Please sign in to comment.