Maintenance électrique le 12 août, nos services, et y compris Gitlab, seront fortement impactés autour de cette date. Retour à un état normal prévu dans le milieu de la semaine prochaine.

Verified Commit 6a791694 authored by erdnaxe's avatar erdnaxe 🎇


parent 670f7dfa
Pipeline #1462 failed with stage
in 4 minutes and 57 seconds
......@@ -34,6 +34,7 @@ INSTALLED_APPS = [
# External apps
# Django contrib
......@@ -150,6 +151,13 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
# Example: "", ""
STATIC_URL = '/static/'
# Django REST Framework
# Med configuration
......@@ -2,21 +2,42 @@
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import PasswordResetView
from django.urls import include, path
from django.views.generic import RedirectView
from django.views.generic import RedirectView, TemplateView
from rest_framework import routers
from rest_framework.schemas import get_schema_view
from media.views import index
import media.views
import users.views
from .admin import admin_site
# API router
router = routers.DefaultRouter()
router.register(r'authors', media.views.AuteurViewSet)
router.register(r'media', media.views.MediaViewSet)
router.register(r'borrowed_items', media.views.EmpruntViewSet)
router.register(r'games', media.views.JeuViewSet)
router.register(r'users', users.views.UserViewSet)
router.register(r'groups', users.views.GroupViewSet)
urlpatterns = [
path('', index, name='index'),
path('', media.views.index, name='index'),
# Include project routers
path('users/', include('users.urls')),
path('media/', include('media.urls')),
path('logs/', include('logs.urls')),
path('api/', include(router.urls)),
path('api-auth/', include('rest_framework.urls')),
path('openapi', login_required(get_schema_view()), name='openapi-schema'),
# Include Django Contrib and Core routers
path('accounts/password_reset/', PasswordResetView.as_view(),
from rest_framework import serializers
from .models import Auteur, Media, Emprunt, Jeu
class AuteurSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Auteur
fields = ['url', 'name']
class MediaSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Media
fields = ['url', 'isbn', 'title', 'subtitle', 'external_url',
'side_identifier', 'authors', 'number_of_pages',
class EmpruntSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Emprunt
fields = ['url', 'media', 'user', 'date_emprunt', 'date_rendu',
'permanencier_emprunt', 'permanencier_rendu']
class JeuSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Jeu
fields = ['url', 'name', 'proprietaire', 'duree', 'nombre_joueurs_min',
'nombre_joueurs_max', 'comment']
......@@ -8,9 +8,12 @@ from django.db import transaction
from django.shortcuts import redirect, render
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from rest_framework import viewsets
from reversion import revisions as reversion
from .models import Emprunt
from .models import Auteur, Media, Emprunt, Jeu
from .serializers import AuteurSerializer, MediaSerializer, \
EmpruntSerializer, JeuSerializer
......@@ -40,3 +43,35 @@ def index(request):
return render(request, 'admin/index.html', {
'title': _('Welcome to the Mediatek database'),
class AuteurViewSet(viewsets.ModelViewSet):
API endpoint that allows authors to be viewed or edited.
queryset = Auteur.objects.all()
serializer_class = AuteurSerializer
class MediaViewSet(viewsets.ModelViewSet):
API endpoint that allows media to be viewed or edited.
queryset = Media.objects.all()
serializer_class = MediaSerializer
class EmpruntViewSet(viewsets.ModelViewSet):
API endpoint that allows borrowed items to be viewed or edited.
queryset = Emprunt.objects.all()
serializer_class = EmpruntSerializer
class JeuViewSet(viewsets.ModelViewSet):
API endpoint that allows games to be viewed or edited.
queryset = Jeu.objects.all()
serializer_class = JeuSerializer
......@@ -5,4 +5,7 @@ pytz==2019.1
\ No newline at end of file
\ No newline at end of file
......@@ -152,4 +152,14 @@ img.poulpy {
max-width: 100%;
width: 1000px;
height: auto;
/* No padding content for special pages */
#content.nopadding {
padding: 0;
/* Fix Redoc */ {
display: none;
\ No newline at end of file
......@@ -93,9 +93,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
<input type="submit">
Mediatek 2017-2020 &mdash;
<a href="">Nous contactez</a>
Mediatek 2017-2020 &mdash;
<a href="">Nous contactez</a> &mdash;
<a href="{% url "redoc" %}">Explorer l'API</a>
{% endif %}
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n static %}
{% block coltype %}nopadding{% endblock %}
{% block content %}
<redoc spec-url='{% url "openapi-schema" %}'></redoc>
<script src=""></script>
{% endblock %}
from django.contrib.auth.models import Group
from rest_framework import serializers
from .models import User
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['url', 'username', 'first_name', 'last_name', 'email',
'groups', 'telephone', 'address', 'maxemprunt', 'comment',
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ['url', 'name']
......@@ -4,14 +4,17 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User, Group
from django.db import transaction
from django.shortcuts import redirect, render
from django.template.context_processors import csrf
from django.utils.translation import ugettext_lazy as _
from rest_framework import viewsets
from reversion import revisions as reversion
from users.forms import BaseInfoForm
from users.models import Adhesion, User
from .serializers import UserSerializer, GroupSerializer
def form(ctx, template, request):
......@@ -60,3 +63,19 @@ def adherer(request, userid):
reversion.set_comment("Adhesion de %s" % users)
messages.success(request, "Adhesion effectuee")
return redirect("admin:users_user_changelist")
class UserViewSet(viewsets.ModelViewSet):
API endpoint that allows users to be viewed or edited.
queryset = User.objects.all()
serializer_class = UserSerializer
class GroupViewSet(viewsets.ModelViewSet):
API endpoint that allows groups to be viewed or edited.
queryset = Group.objects.all()
serializer_class = GroupSerializer
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment