Package madrona :: Package openid :: Module urls
[hide private]

Source Code for Module madrona.openid.urls

  1  # -*- coding: utf-8 -*- 
  2  # Copyright 2007, 2008,2009 by Benoît Chesneau <benoitc@e-engura.org> 
  3  #  
  4  # Licensed under the Apache License, Version 2.0 (the "License"); 
  5  # you may not use this file except in compliance with the License. 
  6  # You may obtain a copy of the License at 
  7  # 
  8  #     http://www.apache.org/licenses/LICENSE-2.0 
  9  # 
 10  # Unless required by applicable law or agreed to in writing, software 
 11  # distributed under the License is distributed on an "AS IS" BASIS, 
 12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 13  # See the License for the specific language governing permissions and 
 14  # limitations under the License. 
 15   
 16  from django.conf.urls.defaults import patterns, url 
 17  from django.views.generic.base import TemplateView 
 18   
 19  # views 
 20  from django.contrib.auth import views as auth_views 
 21  from django.conf import settings 
 22  from madrona.openid import views as oid_views 
 23  from registration import views as reg_views 
 24  from registration.views import activate 
 25  from registration.views import register 
 26  from madrona.common.registration_backend.forms import MadronaRegistrationForm 
 27   
 28  urlpatterns = patterns('', 
 29      url(r'^password/reset/$', auth_views.password_reset, name='auth_password_reset'), 
 30      url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 
 31          auth_views.password_reset_confirm, 
 32          name='auth_password_reset_confirm'), 
 33      url(r'^password/reset/complete/$', 
 34          auth_views.password_reset_complete, 
 35          name='auth_password_reset_complete'), 
 36      url(r'^password/reset/done/$', 
 37          auth_views.password_reset_done, 
 38          name='auth_password_reset_done'), 
 39      url(r'^password/$',oid_views.password_change, name='auth_password_change'), 
 40   
 41      # manage account registration 
 42      url(r'^associate/complete/$', oid_views.complete_associate, name='user_complete_associate'), 
 43      url(r'^associate/$', oid_views.associate, name='user_associate'), 
 44      url(r'^dissociate/$', oid_views.dissociate, name='user_dissociate'), 
 45      url(r'^register/$', oid_views.register, name='user_register'), 
 46      url(r'^signout/$', oid_views.signout, {'next_page':  settings.LOGIN_REDIRECT_URL}, name='user_signout'), 
 47      url(r'^signout/$', oid_views.signout, {'next_page': settings.LOGIN_REDIRECT_URL}, name='auth_logout'), 
 48      url(r'^signin/complete/$', oid_views.complete_signin, name='user_complete_signin'), 
 49      url( 
 50          r'^signup/$', 
 51          reg_views.register, 
 52          {'backend': 'registration.backends.default.DefaultBackend',  
 53           'form_class': MadronaRegistrationForm}, 
 54          name='registration_register' 
 55      ), 
 56      url(r'^signup/complete/$', 
 57          TemplateView.as_view(template_name='registration/registration_complete.html'), 
 58          name='registration_complete'), 
 59   
 60      url(r'^activate/complete/$', 
 61          TemplateView.as_view(template_name='registration/activation_complete.html'), 
 62          {'extra_context': {'group_request_email': settings.GROUP_REQUEST_EMAIL}}, 
 63          name='registration_activation_complete'), 
 64      # Activation keys get matched by \w+ instead of the more specific 
 65      # [a-fA-F0-9]{40} because a bad activation key should still get to the view; 
 66      # that way it can return a sensible "invalid key" message instead of a 
 67      # confusing 404. 
 68      url(r'^activate/(?P<activation_key>\w+)/$', 
 69          activate, 
 70          {'backend': 'madrona.common.registration_backend.LingcodBackend'}, 
 71          name='registration_activate'), 
 72      url(r'^register/closed/$', 
 73          TemplateView.as_view(template_name='registration/registration_closed.html'), 
 74          name='registration_disallowed'), 
 75   
 76      # yadis uri 
 77      url(r'^yadis.xrdf$', oid_views.xrdf, name='oid_xrdf'), 
 78  ) 
 79   
 80   
 81  ## The openid login behavior can be 'hidden' by use of a  
 82  # template which only allows local user/pass authentication 
 83  # Note that this does not disable openid completely; user could still 
 84  # POST openid credentials if they wanted to 
 85  try: 
 86      use_openid = settings.OPENID_ENABLED 
 87  except: 
 88      use_openid = False 
 89   
 90  if use_openid: 
 91      template_name = 'authopenid/signin.html' 
 92  else: 
 93      template_name = 'authopenid/signin_local.html' 
 94   
 95  urlpatterns += patterns('', 
 96      url(r'^signin/$', oid_views.signin, {'template_name':template_name}, name='user_signin'), 
 97      url(r'^signin/$', oid_views.signin, {'template_name':template_name}, name='auth_login'), 
 98  ) 
 99