offline avatar offline committed dd78ff2

settings cleanup

Comments (0)

Files changed (9)

openauth/backends/__init__.py

         request.flash['success'] =  _('OpenId record was added to your account')
         auth.authenticate(identity=self.get_identity(), provider=self.provider)
         auth.login(request, user)
-        raise Redirect(settings.LOGIN_REDIRECT_URL)
+        raise Redirect(global_settings.LOGIN_REDIRECT_URL)
 
     def login_user(self, request):
         if settings.SOCIALID_ACTIVATION_REQUIRED and not request.user.is_active:
         if user:
             request.flash['success'] =  _('You have successfully authenticated')
             auth.login(request, user)
-            raise Redirect(settings.LOGIN_REDIRECT_URL)
+            raise Redirect(global_settings.LOGIN_REDIRECT_URL)
 
     def set_profile_fields(self, request, extra):
         """
                     redirect_url = request.session['next_url']
                     del request.session['next_url']
                 except KeyError:
-                    redirect_url = settings.LOGIN_REDIRECT_URL
+                    redirect_url = global_settings.LOGIN_REDIRECT_URL
                 raise Redirect(redirect_url)
         else:
             return data

openauth/settings.py

 REGISTRATION_ALLOWED = get_config("REGISTRATION_ALLOWED", True)                                    #
 ####################################################################################################
 
-### ACTIVATION_REQUIRED ############################################################################
-# Activation is provided by seperate application, django-confirmation                              #
-# http://bitbucket.org/offline/django-confirmation/                                                #
-# Please read wiki page of this application to fully understand what it does.                      #
-# If activation is not required, user will be signed in immidiatly after the registration process  #
-ACTIVATION_REQUIRED = get_config("ACTIVATION_REQUIRED", False)                                     #
-####################################################################################################
-
-### LOGIN_URL ######################################################################################
-# When anonymous user try to access page that wrapped by login_required decorator, it will         #
-# redirect him to this url.                                                                        #
-LOGIN_URL = get_config("LOGIN_URL", "/auth/login/")                                                #
-####################################################################################################
-
-### LOGIN_REDIRECT_URL #############################################################################
-# URL that user is redirected after successfull login attempt                                      #
-LOGIN_REDIRECT_URL = get_config("LOGIN_REDIRECT_URL", "/auth/user/")                               #
-####################################################################################################
-
-### AUTO_LOGIN #####################################################################################
-# This allow login automaticaly after registration if actiovation doesn't required                 #
-AUTO_LOGIN = get_config("AUTO_LOGIN", True)                                                        #
-####################################################################################################
-
-### ACTIVATION_AUTO_LOGIN ##########################################################################
-# This allow login automaticaly after clicking the  activation link in email in case your site     #
-# require activation                                                                               #
-ACTIVATION_AUTO_LOGIN = get_config("ACTIVATION_AUTO_LOGIN", False)                                 #
-####################################################################################################
-
-### CONFIRMATION TYPES #############################################################################
-# django-confirmation use confirmation types to distinct confirmations. Please don't change this   #
-# settings                                                                                         #
-ACTIVATION_TYPE = get_config("ACTIVATION_TYPE", 1)                                                 #
-####################################################################################################
-
 ### SOCIALID_REGISTRATION_FORM #####################################################################
 # See REGISTRATION_FORM description above                                                          #
 SOCIALID_EXTRA_FORM = get_config("SOCIALID_EXTRA_FORM", "openauth.forms.SocialIDExtraForm")        #
 ####################################################################################################
 
-### SOCIAL_ACTIVATION_REQUIRED #####################################################################
-# If activation is not required, user will be signed in immidiatly after OpenID registration       #
-# process. By default this activation is depend on regular activation setting                      #
-SOCIALID_ACTIVATION_REQUIRED = get_config("SOCIALID_ACTIVATION_REQUIRED", ACTIVATION_REQUIRED)     #
-####################################################################################################
-
 ### AX_URIS ########################################################################################
 # This dict contains mapping of SREG fields to AX uris, you probably don't need to change it       #
 # http://www.axschema.org/types/                                                                   #
     'google': 'openauth.backends.google.GoogleBackend',                                            #
     'twitter': 'openauth.backends.twitter.TwitterBackend',                                         #
     'facebook': 'openauth.backends.facebook.FacebookBackend',                                      #
-    #'oauth': 'openauth.backends.oauth.OAuthBackend',                                              #
     }                                                                                              #
 )                                                                                                  #
 ####################################################################################################
 
-### DEFAULT_LOGIN_TEMPLATE #########################################################################
-DEFAULT_LOGIN_TEMPLATE = get_config("DEFAULT_LOGIN_TEMPLATE", "openauth/login.html")               #
-                                                                                                   #
-####################################################################################################
-
-### DEFAULT_LOGIN_TEMPLATE #########################################################################
-DEFAULT_LOGIN_FORM = get_config("DEFAULT_LOGIN_FORM", "openauth.backends.openid.OpenIDBackend")    #
-                                                                                                   #
-####################################################################################################
-
 REGISTRATION_DISABLED_REDIRECT = get_config("REGISTRATION_DISABLED_REDIRECT", "/")
 
+SOCIALID_ACTIVATION_REQUIRED = get_config("SOCIALID_ACTIVATION_REQUIRED", False)
Add a comment to this file

openauth/tests/__init__.py

Empty file removed.

Add a comment to this file

openauth/tests/models.py

Empty file removed.

openauth/tests/settings.py

-DEBUG = True
-DATABASE_ENGINE = 'sqlite3'
-
-ROOT_URLCONF = 'openauth.tests.urls'
-
-INSTALLED_APPS = (
-    'django.contrib.admin',
-    'django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.sessions',
-    'django.contrib.sites',
-    'confirmation',
-    'notify',
-    'openauth',
-    'openauth.tests'
-)
-SECRET_KEY = '-oy*asd55p(+&5-(=-z0aajy&sdfkjsdfjg723)$c^xom8-j))'
-
-SITE_ID = 1
-
-AUTHENTICATION_BACKENDS = (
-    'django.contrib.auth.backends.ModelBackend',
-    'openauth.backends.OpenIDBackend',
-)
-
-TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.load_template_source',
-    'django.template.loaders.app_directories.load_template_source',
-    'django.template.loaders.eggs.load_template_source',
-)
-
-TEMPLATE_CONTEXT_PROCESSORS = (
-    'django.core.context_processors.auth',
-    'django.core.context_processors.request',
-    'flashcookie.flash_context',
-    )
-
-MIDDLEWARE_CLASSES = (
-    'django.middleware.common.CommonMiddleware',
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    'flashcookie.FlashMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-)

openauth/tests/templates/base.html

-{% block content %}
-{% endblock %}

openauth/tests/tests.py

-import re
-
-from django.core.urlresolvers import reverse
-from django.contrib.auth.models import User
-from django.test import Client, TestCase
-from django.conf import settings
-
-import notify
-import openauth
-from openauth import views
-from openauth import forms
-
-EMAIL_REGEX = re.compile(
-    r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # dot-atom
-    r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
-    r')@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$', re.IGNORECASE)
-
-USER_REGEX = re.compile(r"[a-z0-9][_a-z0-9]*[a-z0-9]$", re.I)
-
-class RegistrationTest(TestCase):
-
-    def setUp(self):
-        openauth.settings.REGISTRATION_ALLOWED = True
-        openauth.settings.DISPLAYNAME_REQUIRED = True
-        openauth.settings.LOGIN_REGEX = EMAIL_REGEX
-        openauth.settings.AUTHENTICATION_TYPES = ['email']
-        openauth.settings.REGISTRATION_FORM = "openauth.forms.RegistrationForm"
-        self.client = Client()
-        self.registration_url = reverse('openauth-registration')
-
-    def test_registration(self):
-        response = self.client.post(self.registration_url, {'username': 'petya', 'login': 'admin@example.com', 'password': 'test', 'password_dup': 'test'}) 
-        user = User.objects.get(email='admin@example.com')
-        self.failUnlessEqual(user.username, 'petya')
-
-    def test_disabled_registration(self):
-        openauth.settings.REGISTRATION_ALLOWED = False
-        response = self.client.post(self.registration_url, {'username': 'petya', 'email': 'admin@example.com', 'password': 'test', 'password_dup': 'test'}) 
-        self.failUnlessRaises(User.DoesNotExist, User.objects.get, username='petya')
-
-
-class LoginTest(TestCase):
-
-    def setUp(self):
-        notify.settings.NOTIFY_TYPE = 'flashcookie'
-        openauth.settings.REGISTRATION_ALLOWED = True
-        openauth.settings.ACTIVATION_REQUIRED = True
-        openauth.settings.LOGIN_REDIRECT_URL = "/auth/user/"
-        openauth.settings.LOGIN_REGEX = USER_REGEX
-        openauth.settings.AUTHENTICATION_TYPES = ['username']
-        self.client = Client()
-        self.login_url = reverse('openauth-login')
-        self.active_user = User.objects.create_user('ivan', 'ivan@example.com', password='test')
-        self.active_user.is_active = True
-        self.active_user.save()
-        self.inactive_user = User.objects.create_user('vova', 'vova@example.com', password='test')
-        self.inactive_user.is_active = False
-        self.inactive_user.save()
-
-    def tearDown(self):
-        self.active_user.delete()
-        self.inactive_user.delete()
-
-    def test_valid_active_user_activation_enabled(self):
-        response = self.client.post(self.login_url, {'login': self.active_user.username, 'password': 'test'})
-        self.assertRedirects(response, openauth.settings.LOGIN_REDIRECT_URL)
-
-    def test_invalid_active_user_activation_enabled(self):
-        response = self.client.post(self.login_url, {'login': self.active_user.username, 'password': 'INCORRECT'})
-        self.assertEqual(response.status_code, 200) #not redirect to LOGIN_REDIRECT_URL
-
-    def test_inactive_user_activation_enabled(self):
-        response = self.client.post(self.login_url, {'login': self.inactive_user.username, 'password': 'test'})
-        self.assertEqual(response.status_code, 200)
-
-    def test_inactive_user_activation_disabled(self):
-        openauth.settings.ACTIVATION_REQUIRED = False
-        response = self.client.post(self.login_url, {'login': self.inactive_user.username, 'password': 'test'})
-        self.assertRedirects(response, openauth.settings.LOGIN_REDIRECT_URL)

openauth/tests/urls.py

-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('',
-    (r'', include('confirmation.urls')),
-    (r'^auth/', include('openauth.urls')),
-)
-

openauth/views.py

 from django.shortcuts import redirect
 from django.http import Http404
 from django.contrib import auth 
+from django.conf import settings as global_settings
 
 from annoying.decorators import render_to
 
         data = request.GET.copy()
         data.update(request.POST)
 
-        request.session['next_url'] = request.GET.get("next") or settings.LOGIN_REDIRECT_URL
+        request.session['next_url'] = request.GET.get("next") or global_settings.LOGIN_REDIRECT_URL
         
         # start the authentication process 
         backend = get_backend(provider)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.