Skip to content

Commit

Permalink
Merge pull request #11974 from rtibbles/django_unchained
Browse files Browse the repository at this point in the history
Update Django to version 3.2
  • Loading branch information
rtibbles authored May 6, 2024
2 parents 0b2aa57 + 2418619 commit 142b0a9
Show file tree
Hide file tree
Showing 148 changed files with 754 additions and 643 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pex:
ls dist/*.whl | while read whlfile; do $(MAKE) read-whl-file-version whlfile=$$whlfile; pex $$whlfile --disable-cache -o dist/kolibri-`cat kolibri/VERSION | sed 's/+/_/g'`.pex -m kolibri --python-shebang=/usr/bin/python3; done

i18n-extract-backend:
cd kolibri && python -m kolibri manage makemessages -- -l en --ignore 'node_modules/*' --ignore 'kolibri/dist/*'
cd kolibri && python -m kolibri manage makemessages -- -l en --ignore 'node_modules/*' --ignore 'kolibri/dist/*' --all

i18n-extract-frontend:
yarn run makemessages
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def process_docstring(app, what, name, obj, options, lines):

# Add the field's type to the docstring
if isinstance(field, models.ForeignKey):
to = field.rel.to
to = field.remote_field.model
lines.append(
u":type %s: %s to :class:`~%s`"
% (field.attname, type(field).__name__, to)
Expand Down
26 changes: 13 additions & 13 deletions kolibri/core/api_urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from django.conf.urls import include
from django.conf.urls import url
from django.urls import include
from django.urls import re_path

urlpatterns = [
url(r"^auth/", include("kolibri.core.auth.api_urls")),
url(r"^bookmarks/", include("kolibri.core.bookmarks.api_urls")),
url(r"^content/", include("kolibri.core.content.api_urls")),
url(r"^logger/", include("kolibri.core.logger.api_urls")),
url(r"^tasks/", include("kolibri.core.tasks.api_urls")),
url(r"^exams/", include("kolibri.core.exams.api_urls")),
url(r"^device/", include("kolibri.core.device.api_urls")),
url(r"^lessons/", include("kolibri.core.lessons.api_urls")),
url(r"^discovery/", include("kolibri.core.discovery.api_urls")),
url(r"^notifications/", include("kolibri.core.analytics.api_urls")),
url(r"^public/", include("kolibri.core.public.api_urls")),
re_path(r"^auth/", include("kolibri.core.auth.api_urls")),
re_path(r"^bookmarks/", include("kolibri.core.bookmarks.api_urls")),
re_path(r"^content/", include("kolibri.core.content.api_urls")),
re_path(r"^logger/", include("kolibri.core.logger.api_urls")),
re_path(r"^tasks/", include("kolibri.core.tasks.api_urls")),
re_path(r"^exams/", include("kolibri.core.exams.api_urls")),
re_path(r"^device/", include("kolibri.core.device.api_urls")),
re_path(r"^lessons/", include("kolibri.core.lessons.api_urls")),
re_path(r"^discovery/", include("kolibri.core.discovery.api_urls")),
re_path(r"^notifications/", include("kolibri.core.analytics.api_urls")),
re_path(r"^public/", include("kolibri.core.public.api_urls")),
]
14 changes: 7 additions & 7 deletions kolibri/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.apps import AppConfig
from django.conf import settings
from django.db.backends.signals import connection_created
from django.db.models.query import F
from django.db.utils import DatabaseError
from django_filters.filters import UUIDFilter
from django_filters.rest_framework.filterset import FilterSet
Expand Down Expand Up @@ -51,10 +50,6 @@ def ready(self):
# Register any django apps that may have kolibri plugin
# modules inside them
registered_plugins.register_non_plugins(settings.INSTALLED_APPS)
# Fixes issue using OuterRef within Cast() that is patched in later Django version
# Patch from https://github.com/django/django/commit/c412926a2e359afb40738d8177c9f3bef80ee04e
# https://code.djangoproject.com/ticket/29142
F.relabeled_clone = lambda self, relabels: self

@staticmethod
def activate_pragmas_per_connection(sender, connection, **kwargs):
Expand Down Expand Up @@ -116,10 +111,15 @@ def check_redis_settings(): # noqa C901
if we are configured to do so, and if we should, otherwise make some logging noise.
"""

from redis.exceptions import ConnectionError

if OPTIONS["Cache"]["CACHE_BACKEND"] != "redis":
return

# Don't import until we've confirmed we're using Redis
# to avoid a hard dependency on Redis
# the options config has already been validated at this point
# so we know that redis is available.
from redis.exceptions import ConnectionError

config_maxmemory = OPTIONS["Cache"]["CACHE_REDIS_MAXMEMORY"]
config_maxmemory_policy = OPTIONS["Cache"]["CACHE_REDIS_MAXMEMORY_POLICY"]

Expand Down
14 changes: 8 additions & 6 deletions kolibri/core/auth/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class FacilityDatasetViewSet(ValuesViewset):
KolibriAuthPermissionsFilter,
DjangoFilterBackend,
)
filter_class = FacilityDatasetFilter
filterset_class = FacilityDatasetFilter
serializer_class = FacilityDatasetSerializer

values = (
Expand Down Expand Up @@ -353,6 +353,8 @@ class PublicFacilityUserViewSet(ReadOnlyValuesViewset):
}

def get_queryset(self):
if self.request.user.is_anonymous:
return FacilityUser.objects.none()
facility_id = self.request.query_params.get(
"facility_id", self.request.user.facility_id
)
Expand Down Expand Up @@ -395,9 +397,9 @@ class FacilityUserViewSet(ValuesViewset):
)
order_by_field = "username"

queryset = FacilityUser.objects.all()
queryset = FacilityUser.objects.all().order_by(order_by_field)
serializer_class = FacilityUserSerializer
filter_class = FacilityUserFilter
filterset_class = FacilityUserFilter
search_fields = ("username", "full_name")

values = (
Expand Down Expand Up @@ -524,7 +526,7 @@ class MembershipViewSet(BulkDeleteMixin, BulkCreateMixin, viewsets.ModelViewSet)
filter_backends = (KolibriAuthPermissionsFilter, DjangoFilterBackend)
queryset = Membership.objects.all()
serializer_class = MembershipSerializer
filter_class = MembershipFilter
filterset_class = MembershipFilter
filter_fields = ["user", "collection", "user_ids"]


Expand All @@ -544,7 +546,7 @@ class RoleViewSet(BulkDeleteMixin, BulkCreateMixin, viewsets.ModelViewSet):
filter_backends = (KolibriAuthPermissionsFilter, DjangoFilterBackend)
queryset = Role.objects.all()
serializer_class = RoleSerializer
filter_class = RoleFilter
filterset_class = RoleFilter
filter_fields = ["user", "collection", "kind", "user_ids"]


Expand Down Expand Up @@ -695,7 +697,7 @@ class ClassroomViewSet(ValuesViewset):
filter_backends = (KolibriAuthPermissionsFilter, DjangoFilterBackend)
queryset = Classroom.objects.all()
serializer_class = ClassroomSerializer
filter_class = ClassroomFilter
filterset_class = ClassroomFilter

values = (
"id",
Expand Down
8 changes: 4 additions & 4 deletions kolibri/core/auth/api_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path
from rest_framework import routers

from .api import ClassroomViewSet
Expand Down Expand Up @@ -40,17 +40,17 @@
router.urls
+ bulk_delete_router.urls
+ [
url(
re_path(
r"^setnonspecifiedpassword$",
SetNonSpecifiedPasswordView.as_view(),
name="setnonspecifiedpassword",
),
url(
re_path(
r"^usernameavailable$",
UsernameAvailableView.as_view(),
name="usernameavailable",
),
url(
re_path(
r"^ispinvalid/(?P<pk>[a-f0-9]{32})$",
IsPINValidView.as_view(),
name="ispinvalid",
Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/auth/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, get_response):
def __call__(self, request):
response = self.get_response(request)
if response and response.status_code == 401 and request.is_ajax():
del response["WWW-Authenticate"]
del response.headers["WWW-Authenticate"]
return response


Expand Down
Loading

0 comments on commit 142b0a9

Please sign in to comment.