Revision 304acb60 snf-astakos-app/astakos/im/api/__init__.py

b/snf-astakos-app/astakos/im/api/__init__.py
146 146

  
147 147
@api_method()
148 148
def get_menu(request, with_extra_links=False, with_signout=True):
149
    index_url = reverse('index')
149
    user = request.user
150
    if not isinstance(user, AstakosUser):
151
        cookie = unquote(request.COOKIES.get(COOKIE_NAME, ''))
152
        email = cookie.partition('|')[0]
153
        try:
154
            if email:
155
                user = AstakosUser.objects.get(email=email, is_active=True)
156
        except AstakosUser.DoesNotExist:
157
            pass
158
    
150 159
    absolute = lambda (url): request.build_absolute_uri(url)
151
    l = [{ 'url': absolute(index_url), 'name': "Sign in"}]
152
    cookie = unquote(request.COOKIES.get(COOKIE_NAME, ''))
153
    email = cookie.partition('|')[0]
154
    try:
155
        if not email:
156
            raise ValueError
157
        user = AstakosUser.objects.get(email=email, is_active=True)
158
    except AstakosUser.DoesNotExist:
159
        pass
160
    except ValueError:
161
        pass
160
    if not isinstance(user, AstakosUser):
161
        index_url = reverse('index')
162
        l = [{ 'url': absolute(index_url), 'name': "Sign in"}]
162 163
    else:
163 164
        l = []
164 165
        l.append(dict(url=absolute(reverse('index')), name=user.email))

Also available in: Unified diff