Beispiel #1
0
def login(req):
    # This is a wrapper around the _login view

    if settings.SERVER_ENVIRONMENT in settings.ICDS_ENVS:
        login_url = reverse('domain_login', kwargs={'domain': 'icds-cas'})
        return HttpResponseRedirect(login_url)

    req_params = req.GET if req.method == 'GET' else req.POST
    domain = req_params.get('domain', None)
    return _login(req, domain, get_custom_login_page(req.get_host()))
Beispiel #2
0
def domain_login(req, domain, custom_template_name=None, extra_context=None):
    # This is a wrapper around the _login view which sets a different template
    project = Domain.get_by_name(domain)
    if not project:
        raise Http404

    # FYI, the domain context_processor will pick this up and apply the
    # necessary domain contexts:
    req.project = project
    if custom_template_name is None:
        custom_template_name = get_custom_login_page(req.get_host())
    return _login(req, domain, custom_template_name, extra_context)
 def test_nothing_configured(self):
     self.assertEqual(None, get_custom_login_page('example.com'))
 def test_dict_default(self):
     self.assertEqual('custom/login.html',
                      get_custom_login_page('example.com'))
     self.assertEqual('normal/login.html',
                      get_custom_login_page('commcarehq.org'))
 def test_dict_mismatch(self):
     self.assertEqual(None, get_custom_login_page('commcarehq.org'))
 def test_dict_match(self):
     self.assertEqual('custom/login.html',
                      get_custom_login_page('example.com'))
 def test_string_configured(self):
     self.assertEqual('custom/login.html',
                      get_custom_login_page('example.com'))