Skip to content

Commit 7429a4a

Browse files
authored
Merge pull request #172 from DakaraProject/dependencies/update2
Update dependencies
2 parents af07083 + 1056232 commit 7429a4a

29 files changed

+189
-121
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
- macos-latest
1919
- windows-latest
2020
python-version:
21-
- "3.9"
2221
- "3.10"
2322
- "3.11"
2423
- "3.12"

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.2.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ Any important notes regarding the update.
4242

4343
### Changed
4444

45+
- Self documentation of the API is now handled by `drf-spectacular`.
4546
- Playlist is integrated to the digest view in its minimal form.
4647
- Played and queuing playlist entries can be accessed in a library fashion (using pagination), their routes are `playlist/played` and `playlist/queuing`.
4748

4849
### Removed
4950

51+
- Removed documentation URL entry point `api-doc`.
52+
- Dropped Python 3.9 support.
5053
- Dropped Python 3.8 support.
5154
- Dropped Python 3.7 support.
5255
- Playlist entries in digest view don't have pre-calculated date of play any more. This data has to be calculated by the front now.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Installation guidelines are provided over here:
1919

2020
### System requirements
2121

22-
* Python3, to make everything up and running (supported versions: 3.9, 3.10, 3.11, and 3.12).
22+
* Python3, to make everything up and running (supported versions: 3.10, 3.11, and 3.12).
2323

2424
Linux, Mac and Windows are supported.
2525

dakara_server/dakara_server/settings/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"django.contrib.staticfiles",
3232
"rest_framework",
3333
"rest_framework.authtoken",
34+
"drf_spectacular",
3435
"channels",
3536
"ordered_model",
3637
"rest_registration",
@@ -118,7 +119,15 @@
118119
"DEFAULT_PAGINATION_CLASS": "internal.pagination.PageNumberPaginationCustom",
119120
"PAGE_SIZE": 10,
120121
"TEST_REQUEST_DEFAULT_FORMAT": "json",
121-
"DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema",
122+
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
123+
}
124+
125+
# DRF Spectacular settings
126+
SPECTACULAR_SETTINGS = {
127+
"TITLE": "Dakara server API",
128+
"DESCRIPTION": "Server for the Dakara project",
129+
"VERSION": VERSION,
130+
"SERVE_INCLUDE_SCHEMA": False,
122131
}
123132

124133

dakara_server/dakara_server/token_auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
From: https://gist.github.com/rluts/22e05ed8f53f97bdd02eafdf38f3d60a
44
From: https://gist.github.com/AliRn76/1fb99688315bedb2bf32fc4af0e50157
55
"""
6+
67
from urllib.parse import parse_qs
78

89
from channels.db import database_sync_to_async

dakara_server/dakara_server/urls.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
1. Add an import: from blog import urls as blog_urls
1414
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
1515
"""
16+
1617
from django.conf import settings
17-
from django.conf.urls import re_path
1818
from django.contrib import admin
1919
from django.contrib.staticfiles.views import serve
20-
from django.urls import include, path
21-
from rest_framework.documentation import include_docs_urls
20+
from django.urls import include, path, re_path
2221

2322
from internal import views as internal_views
2423
from library import views as library_views
@@ -158,17 +157,14 @@
158157
library_views.SongTagView.as_view(),
159158
name="library-songtag",
160159
),
161-
# API documentation routes
162-
path("api-docs/", include_docs_urls(title="Dakara server API")),
163160
]
164161

165162
if settings.DEBUG:
166163
urlpatterns.extend(
167164
[
168165
# Default to main page
169166
re_path(
170-
r"^(?!api/|api-docs/?)", # serve everything but the API routes
171-
# API documentation routes
167+
r"^(?!api/?)", # serve everything but the API routes
172168
serve,
173169
kwargs={"path": "index.html"},
174170
)

dakara_server/internal/apps.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import os
21
from abc import ABC
32

43
from django.apps import AppConfig
54

5+
from internal.reloader import is_reloader
66
from internal.version import check_version
77

88

@@ -15,21 +15,11 @@ class DakaraConfig(AppConfig, ABC):
1515
"""
1616

1717
def ready(self):
18-
"""Method called when app start.
19-
20-
When the server is run with the `runserver` command, two instances of
21-
the project are running and hence this method is called twice: one for
22-
the reloader and one for the actual development server. The reloader
23-
creates the environment variable `RUN_MAIN` with the value "true", so
24-
it can be distinguighed.
25-
26-
See: https://stackoverflow.com/q/33814615
27-
See: django/utils/autoreload.py
28-
"""
18+
"""Method called when app start."""
2919
# The code below can be executed by the reloader
3020
self.ready_reload()
3121

32-
if os.environ.get("RUN_MAIN") == "true":
22+
if is_reloader():
3323
return
3424

3525
# The code bellow cannot be executed by the reloader

dakara_server/internal/reloader.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
4+
def is_reloader():
5+
"""Detect if the current instance is a reloader.
6+
7+
When the server is run with the `runserver` command, two instances of the
8+
project are running and hence this method is called twice: one for the
9+
reloader and one for the actual development server. The reloader creates
10+
the environment variable `RUN_MAIN` with the value "true", so it can be
11+
distinguighed.
12+
13+
Returns:
14+
bool: True if the current instance is a reloader.
15+
16+
See: https://stackoverflow.com/q/33814615
17+
See: django/utils/autoreload.py
18+
"""
19+
return os.environ.get("RUN_MAIN") == "true"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from rest_framework import serializers
2+
3+
4+
class SettingsSerializer(serializers.Serializer):
5+
"""Settings."""
6+
7+
version = serializers.CharField(read_only=True)
8+
date = serializers.DateTimeField(read_only=True)
9+
email_enabled = serializers.BooleanField(read_only=True)

0 commit comments

Comments
 (0)