2012-02-04 17:40:31 -06:00
|
|
|
# Copyright 2012 Nebula, Inc.
|
2011-07-03 20:55:00 -07:00
|
|
|
#
|
2011-01-12 13:43:31 -08:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2011-07-03 20:55:00 -07:00
|
|
|
|
2012-10-04 15:43:40 -07:00
|
|
|
from django import shortcuts
|
2014-07-29 16:57:39 +02:00
|
|
|
import django.views.decorators.vary
|
2011-10-31 11:31:05 -07:00
|
|
|
|
|
|
|
import horizon
|
2014-04-11 16:26:35 -06:00
|
|
|
from horizon import base
|
2015-02-05 09:25:24 +00:00
|
|
|
from horizon import exceptions
|
2011-01-15 01:16:25 -08:00
|
|
|
|
2012-03-26 18:08:48 -07:00
|
|
|
|
2012-10-04 15:43:40 -07:00
|
|
|
def get_user_home(user):
|
2014-04-11 16:26:35 -06:00
|
|
|
dashboard = None
|
2012-10-04 15:43:40 -07:00
|
|
|
if user.is_superuser:
|
2014-04-11 16:26:35 -06:00
|
|
|
try:
|
|
|
|
dashboard = horizon.get_dashboard('admin')
|
|
|
|
except base.NotRegistered:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if dashboard is None:
|
|
|
|
dashboard = horizon.get_default_dashboard()
|
|
|
|
|
|
|
|
return dashboard.get_absolute_url()
|
2012-03-26 18:08:48 -07:00
|
|
|
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2014-07-29 16:57:39 +02:00
|
|
|
@django.views.decorators.vary.vary_on_cookie
|
2012-10-04 15:43:40 -07:00
|
|
|
def splash(request):
|
2015-02-05 09:25:24 +00:00
|
|
|
if not request.user.is_authenticated():
|
|
|
|
raise exceptions.NotAuthenticated()
|
|
|
|
|
|
|
|
response = shortcuts.redirect(horizon.get_user_home(request.user))
|
2014-11-20 08:49:09 -07:00
|
|
|
if 'logout_reason' in request.COOKIES:
|
|
|
|
response.delete_cookie('logout_reason')
|
2014-06-18 16:34:59 +05:30
|
|
|
return response
|