Destroy Django 1.11 functions

This commit is contained in:
Yohann D'ANELLO 2021-10-23 19:00:45 +02:00
parent b638add396
commit 70018f0043
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 9 additions and 8 deletions

View File

@ -27,7 +27,7 @@ router.register(r'users', users.views.UserViewSet)
router.register(r'groups', users.views.GroupViewSet)
urlpatterns = [
path('', media.views.index, name='index'),
path('', media.views.IndexView, name='index'),
# Include project routers
path('users/', include('users.urls')),

View File

@ -40,16 +40,17 @@ def retour_emprunt(request, empruntid):
return redirect("admin:media_emprunt_changelist")
def index(request):
class IndexView(TemplateView):
"""
Home page which redirect to admin when logged in
"""
if request.user.is_authenticated:
return redirect('admin:index')
else:
return render(request, 'admin/index.html', {
'title': _('Welcome to the Mediatek database'),
})
extra_context = {'title': _('Welcome to the Mediatek database')}
template_name = 'admin/index.html'
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated:
return redirect('admin:index')
return super().dispatch(request, *args, **kwargs)
class FindMediumView(LoginRequiredMixin, TemplateView):