Projet

Général

Profil

0001-redirect-user-to-welcome-page-on-first-login-6705.patch

Serghei Mihai, 06 juillet 2015 18:55

Télécharger (1,55 ko)

Voir les différences:

Subject: [PATCH] redirect user to welcome page on first login (#6705)

 combo/public/views.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
combo/public/views.py
16 16

  
17 17
import urllib
18 18
import urlparse
19
import datetime
19 20

  
20 21
from django.conf import settings
21 22
from django.contrib.auth import logout as auth_logout
......
33 34

  
34 35
from combo.data.models import CellBase, Page
35 36

  
37
def user_first_login_url(request):
38
    if request.user.is_authenticated() and not request.session.get('welcome_displayed'):
39
        user = request.user
40
        if hasattr(settings, 'WELCOME_PAGE_PATH') and settings.WELCOME_PAGE_PATH:
41
            if user.last_login and user.last_login < user.date_joined + datetime.timedelta(seconds=2):
42
                request.session['welcome_displayed'] = True
43
                return settings.WELCOME_PAGE_PATH
36 44

  
37 45
def login(request, *args, **kwargs):
38 46
    if any(get_idps()):
......
165 173

  
166 174

  
167 175
def page(request):
168
    url = request.path_info
169
    parts = [x for x in request.path_info.strip('/').split('/') if x]
176
    url = user_first_login_url(request) or request.path_info
177
    parts = [x for x in url.strip('/').split('/') if x]
170 178
    if not parts:
171 179
        parts = ['index']
172 180
    try:
173
-