diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py
index f319b2db..f94a68e0 100644
--- a/note_kfet/settings/base.py
+++ b/note_kfet/settings/base.py
@@ -245,7 +245,7 @@ REST_FRAMEWORK = {
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
# After login redirect user to transfer page
-LOGIN_REDIRECT_URL = '/note/transfer/'
+LOGIN_REDIRECT_URL = '/'
# An user session will expired after 3 hours
SESSION_COOKIE_AGE = 60 * 60 * 3
diff --git a/note_kfet/templates/base.html b/note_kfet/templates/base.html
index e597d5ca..1e740012 100644
--- a/note_kfet/templates/base.html
+++ b/note_kfet/templates/base.html
@@ -64,7 +64,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% trans 'Consumptions' %}
{% endif %}
- {% if "note.transaction"|not_empty_model_list %}
+ {# FIXME Find a better solution to check if a user has the right to see the transfer page #}
+ {% if "note.alias"|model_list_length >= 2 %}
{% url 'note:transfer' as url %}
{% trans 'Transfer' %}
diff --git a/note_kfet/urls.py b/note_kfet/urls.py
index d9e51b63..d4341bc6 100644
--- a/note_kfet/urls.py
+++ b/note_kfet/urls.py
@@ -5,15 +5,14 @@ from django.conf import settings
from django.conf.urls.static import static
from django.urls import path, include
from django.views.defaults import bad_request, permission_denied, page_not_found, server_error
-from django.views.generic import RedirectView
-
from member.views import CustomLoginView
from .admin import admin_site
+from .views import IndexView
urlpatterns = [
# Dev so redirect to something random
- path('', RedirectView.as_view(pattern_name='note:transfer'), name='index'),
+ path('', IndexView.as_view(), name='index'),
# Include project routers
path('note/', include('note.urls')),
diff --git a/note_kfet/views.py b/note_kfet/views.py
new file mode 100644
index 00000000..bd2b2424
--- /dev/null
+++ b/note_kfet/views.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from django.contrib.auth.mixins import LoginRequiredMixin
+from django.urls import reverse
+from django.views.generic import RedirectView
+from note.models import Alias
+from permission.backends import PermissionBackend
+
+
+class IndexView(LoginRequiredMixin, RedirectView):
+ def get_redirect_url(self, *args, **kwargs):
+ """
+ Calculate the index page according to the roles.
+ A normal user will have access to the transfer page.
+ A non-Kfet member will have access to its user detail page.
+ The user "note" will display the consumption interface.
+ """
+ user = self.request.user
+
+ # The account note will have the consumption page as default page
+ if not PermissionBackend.check_perm(user, "auth.view_user", user):
+ return reverse("note:consos")
+
+ # People that can see the alias BDE are Kfet members
+ if PermissionBackend.check_perm(user, "alias.view_alias", Alias.objects.get(name="BDE")):
+ return reverse("note:transfer")
+
+ # Non-Kfet members will don't see the transfer page, but their profile page
+ return reverse("member:user_detail", args=(user.pk,))