openverse icon indicating copy to clipboard operation
openverse copied to clipboard

Update to `adrf` 0.1.7 and clean up `MediaViewSet` with new adrf viewsets

Open sarayourfriend opened this issue 5 months ago • 0 comments

Problem

To convert the MediaViewSet to async, we needed to combine a multiple adrf mixins to cover support for our usage of regular DRF's ModelViewSet. adrf's latest version, 0.1.7, should obviate the need for this.

https://github.com/em1208/adrf/releases/tag/0.1.7

Description

Upgrade to adrf 0.1.7, and then replace the AsyncViewSetMixin, AsyncAPIView, ReadOnlyViewSet base classes on MediaViewSet with adrf's ReadonlyModelViewSet.

https://github.com/WordPress/openverse/blob/1ea37d77ce732c31d14dd78adaaeb8b96a7e56db/api/api/views/media_views.py#L45

Here is adrf's code for the new viewsets:

https://github.com/em1208/adrf/blob/226e2f0e946e37a5cf0f338836c33ba9884dded1/adrf/viewsets.py#L176C7-L176C27

Additional context

This issue is help wanted because I believe it should be possible for a contributor experienced with Django and Python to complete it, and address any issues that come up in the unit tests. I would not recommend this issue be attempted by anyone who is not familiar with the following:

  • Python asyncio
  • Django and its async support
  • Django Rest Framework
  • Pytest

sarayourfriend avatar Sep 01 '24 03:09 sarayourfriend