def redirect_to_default(req, domain=None): if not req.user.is_authenticated(): if domain != None: url = reverse('domain_login', args=[domain]) else: try: from corehq.apps.prelogin.views import HomePublicView url = reverse(HomePublicView.urlname) except ImportError: # this happens when the prelogin app is not included. url = reverse('landing_page') else: if domain: domain = normalize_domain_name(domain) domains = [Domain.get_by_name(domain)] else: domains = Domain.active_for_user(req.user) if 0 == len(domains) and not req.user.is_superuser: return redirect('registration_domain', domain_type=get_domain_type(None, req)) elif 1 == len(domains): if domains[0]: domain = domains[0].name if (req.couch_user.is_commcare_user() and not is_mobile_worker_with_report_access( req.couch_user, domain)): url = reverse("cloudcare_main", args=[domain, ""]) else: url = reverse('dashboard_default', args=[domain]) else: raise Http404 else: url = settings.DOMAIN_SELECT_URL return HttpResponseRedirect(url)
def redirect_to_default(req, domain=None): if not req.user.is_authenticated(): if domain != None: url = reverse('domain_login', args=[domain]) else: # this actually gets hijacked by the static site, but is necessary url = reverse('corehq.apps.hqwebapp.views.landing_page') else: if domain: domain = normalize_domain_name(domain) domains = [Domain.get_by_name(domain)] else: domains = Domain.active_for_user(req.user) if 0 == len(domains) and not req.user.is_superuser: return redirect('registration_domain', domain_type=get_domain_type(None, req)) elif 1 == len(domains): if domains[0]: domain = domains[0].name if (req.couch_user.is_commcare_user() and not is_mobile_worker_with_report_access( req.couch_user, domain)): url = reverse("cloudcare_main", args=[domain, ""]) else: url = reverse('dashboard_default', args=[domain]) else: raise Http404 else: url = settings.DOMAIN_SELECT_URL return HttpResponseRedirect(url)