Nouvelle API :

Avec

  * API sur les consoles en utilisant Django Rest Framework
  * Tri par nom de console
  * Nouveaux tests sur l'API
  * Documentation pour l'API
  * Ajout d'une description au champ "name" pour Console et sa traduction
  * Nouvelles dépendances à coreapi et djangorestframework
This commit is contained in:
2017-09-04 23:42:57 +02:00
parent ff228ab845
commit 9b0def75b7
10 changed files with 125 additions and 23 deletions

View File

@ -0,0 +1,8 @@
# API - Django Rest Framework
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAdminUser',
],
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'UNICODE_JSON': True,
}

View File

@ -26,6 +26,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'core',
'games.apps.GamesConfig',
]

View File

@ -18,6 +18,7 @@ base_settings = [
'components/common.py', # standard django settings
'components/database.py', # SQLite 3
'components/i18n.py', # Internationalisation and localization
'components/api.py', # API (django rest framework)
# Select the right env:
'environments/%s.py' % ENV,

View File

@ -16,14 +16,25 @@ Including another URLconf
from django.conf.urls import url, include
from django.contrib import admin
from collection import __version__ as app_version
from games.views import GameList
from games.views import GameList, ConsoleViewSet
from rest_framework import routers
from rest_framework.documentation import include_docs_urls
# Admin config
admin.site.site_title = 'OpenBackloggery'
admin.site.site_header = '%s %s' % (admin.site.site_title, app_version)
# Django Rest Framework router
router = routers.DefaultRouter()
router.register(r'consoles', ConsoleViewSet)
urlpatterns = [
url(r'^$', GameList.as_view(), name='homepage'),
url(r'^games/', include('games.urls', namespace='games'), name='games'),
url(r'^admin/', admin.site.urls),
url(r'^api/v1/', include(router.urls), name='api'),
url(r'^api/v1/docs/', include_docs_urls(title=' '.join(
[admin.site.site_title,
'API']))),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]