Commit 92defad4 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

change settings namespace

Refs: #1997
parent 527d3f56
......@@ -39,7 +39,6 @@ from functools import wraps
from math import ceil
from smtplib import SMTPException
from django.conf import settings
from django.core.mail import send_mail
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect
......@@ -56,7 +55,7 @@ from astakos.im.forms import *
from astakos.im.views import render_response, index
from astakos.im.admin.forms import AdminProfileForm
from astakos.im.admin.forms import AdminUserCreationForm
from astakos.im.settings import BYPASS_ADMIN_AUTH, ADMIN_PAGE_LIMIT, DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL
def requires_admin(func):
"""
Decorator checkes whether the request.user is a superuser and if not
......@@ -64,7 +63,7 @@ def requires_admin(func):
"""
@wraps(func)
def wrapper(request, *args):
if not settings.BYPASS_ADMIN_AUTH:
if not BYPASS_ADMIN_AUTH:
if request.user.is_anonymous():
next = urlencode({'next': request.build_absolute_uri()})
login_uri = reverse(index) + '?' + next
......@@ -160,10 +159,10 @@ def users_list(request, template_name='users_list.html', extra_context={}):
page = int(request.GET.get('page', 1))
except ValueError:
page = 1
offset = max(0, page - 1) * settings.ADMIN_PAGE_LIMIT
limit = offset + settings.ADMIN_PAGE_LIMIT
offset = max(0, page - 1) * ADMIN_PAGE_LIMIT
limit = offset + ADMIN_PAGE_LIMIT
npages = int(ceil(1.0 * users.count() / settings.ADMIN_PAGE_LIMIT))
npages = int(ceil(1.0 * users.count() / ADMIN_PAGE_LIMIT))
prev = page - 1 if page > 1 else None
next = page + 1 if page < npages else None
......@@ -285,10 +284,10 @@ def pending_users(request, template_name='pending_users.html', extra_context={})
page = int(request.GET.get('page', 1))
except ValueError:
page = 1
offset = max(0, page - 1) * settings.ADMIN_PAGE_LIMIT
limit = offset + settings.ADMIN_PAGE_LIMIT
offset = max(0, page - 1) * ADMIN_PAGE_LIMIT
limit = offset + ADMIN_PAGE_LIMIT
npages = int(ceil(1.0 * users.count() / settings.ADMIN_PAGE_LIMIT))
npages = int(ceil(1.0 * users.count() / ADMIN_PAGE_LIMIT))
prev = page - 1 if page > 1 else None
next = page + 1 if page < npages else None
kwargs = {'users':users[offset:limit],
......@@ -309,8 +308,8 @@ def _send_greeting(request, user, template_name):
'url': sitedomain,
'baseurl': baseurl,
'site_name': sitename,
'support': settings.DEFAULT_CONTACT_EMAIL % sitename.lower()})
sender = settings.DEFAULT_FROM_EMAIL % sitename
'support': DEFAULT_CONTACT_EMAIL % sitename.lower()})
sender = DEFAULT_FROM_EMAIL % sitename
send_mail(subject, message, sender, [user.email])
logging.info('Sent greeting %s', user)
......@@ -369,10 +368,10 @@ def users_activate(request, user_id, template_name='pending_users.html', extra_c
page = int(request.POST.get('page', 1))
except ValueError:
page = 1
offset = max(0, page - 1) * settings.ADMIN_PAGE_LIMIT
limit = offset + settings.ADMIN_PAGE_LIMIT
offset = max(0, page - 1) * ADMIN_PAGE_LIMIT
limit = offset + ADMIN_PAGE_LIMIT
npages = int(ceil(1.0 * users.count() / settings.ADMIN_PAGE_LIMIT))
npages = int(ceil(1.0 * users.count() / ADMIN_PAGE_LIMIT))
prev = page - 1 if page > 1 else None
next = page + 1 if page < npages else None
kwargs = {'users':users[offset:limit],
......@@ -427,10 +426,10 @@ def invitations_list(request, template_name='invitations_list.html', extra_conte
page = int(request.GET.get('page', 1))
except ValueError:
page = 1
offset = max(0, page - 1) * settings.ADMIN_PAGE_LIMIT
limit = offset + settings.ADMIN_PAGE_LIMIT
offset = max(0, page - 1) * ADMIN_PAGE_LIMIT
limit = offset + ADMIN_PAGE_LIMIT
npages = int(ceil(1.0 * invitations.count() / settings.ADMIN_PAGE_LIMIT))
npages = int(ceil(1.0 * invitations.count() / ADMIN_PAGE_LIMIT))
prev = page - 1 if page > 1 else None
next = page + 1 if page < npages else None
kwargs = {'invitations':invitations[offset:limit],
......
......@@ -31,7 +31,6 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.conf import settings
from django.utils.importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from django.core.mail import send_mail
......@@ -47,6 +46,7 @@ from urllib import quote
from astakos.im.models import AstakosUser, Invitation
from astakos.im.forms import *
from astakos.im.util import get_invitation
from astakos.im.settings import INVITATIONS_ENABLED, DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL
import socket
import logging
......@@ -62,7 +62,7 @@ def get_backend(request):
is raised.
"""
module = 'astakos.im.backends'
prefix = 'Invitations' if settings.INVITATIONS_ENABLED else 'Simple'
prefix = 'Invitations' if INVITATIONS_ENABLED else 'Simple'
backend_class_name = '%sBackend' %prefix
try:
mod = import_module(module)
......@@ -248,7 +248,7 @@ def _send_verification(request, user, template_name):
'url': url,
'baseurl': baseurl,
'site_name': site.name,
'support': settings.DEFAULT_CONTACT_EMAIL % site.name.lower()})
sender = settings.DEFAULT_FROM_EMAIL % site.name
'support': DEFAULT_CONTACT_EMAIL % site.name.lower()})
sender = DEFAULT_FROM_EMAIL % site.name
send_mail('%s account activation' % site.name, message, sender, [user.email])
logging.info('Sent activation %s', user)
......@@ -31,10 +31,10 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.conf import settings
from astakos.im.settings import IM_MODULES, INVITATIONS_ENABLED, IM_MEDIA_URL
def im_modules(request):
return {'im_modules': settings.IM_MODULES}
return {'im_modules': IM_MODULES}
def next(request):
return {'next' : request.GET.get('next', '')}
......@@ -43,8 +43,8 @@ def code(request):
return {'code' : request.GET.get('code', '')}
def invitations(request):
return {'invitations_enabled' :settings.INVITATIONS_ENABLED}
return {'invitations_enabled' :INVITATIONS_ENABLED}
def media(request):
return {'IM_MEDIA_URL' : getattr(settings, 'IM_MEDIA_URL', '/static/im/')}
return {'IM_MEDIA_URL' : IM_MEDIA_URL}
......@@ -34,7 +34,6 @@
from django import forms
from django.utils.translation import ugettext as _
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordResetForm
from django.conf import settings
from django.core.mail import send_mail
from django.contrib.auth.tokens import default_token_generator
from django.template import Context, loader
......@@ -42,6 +41,7 @@ from django.utils.http import int_to_base36
from astakos.im.models import AstakosUser
from astakos.im.util import get_current_site
from astakos.im.settings import INVITATIONS_PER_LEVEL, DEFAULT_FROM_EMAIL
import logging
......@@ -115,7 +115,7 @@ class InvitedLocalUserCreationForm(LocalUserCreationForm):
user = super(InvitedLocalUserCreationForm, self).save(commit=False)
level = user.invitation.inviter.level + 1
user.level = level
user.invitations = settings.INVITATIONS_PER_LEVEL[level]
user.invitations = INVITATIONS_PER_LEVEL[level]
if commit:
user.save()
return user
......@@ -190,8 +190,8 @@ class FeedbackForm(forms.Form):
"""
feedback_msg = forms.CharField(widget=forms.Textarea(),
label=u'Message', required=False)
feedback_data = forms.CharField(widget=forms.Textarea(),
label=u'Data', required=False)
feedback_data = forms.CharField(widget=forms.HiddenInput(),
label='', required=False)
class SendInvitationForm(forms.Form):
"""
......@@ -227,6 +227,6 @@ class ExtendedPasswordResetForm(PasswordResetForm):
'token': token_generator.make_token(user),
'protocol': use_https and 'https' or 'http',
}
from_email = settings.DEFAULT_FROM_EMAIL % site_name
from_email = DEFAULT_FROM_EMAIL % site_name
send_mail(_("Password reset on %s") % site_name,
t.render(Context(c)), from_email, [user.email])
......@@ -31,18 +31,17 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.conf import settings
from astakos.im.settings import BACKEND_BLOCK_MODULE, BACKEND_BLOCK_PATH, BACKEND_DB_CONNECTION, BACKEND_DB_MODULE, BACKEND_QUOTA, BACKEND_VERSIONING
from pithos.backends import connect_backend
def get_backend():
backend = connect_backend(db_module=settings.BACKEND_DB_MODULE,
db_connection=settings.BACKEND_DB_CONNECTION,
block_module=settings.BACKEND_BLOCK_MODULE,
block_path=settings.BACKEND_BLOCK_PATH)
backend.default_policy['quota'] = settings.BACKEND_QUOTA
backend.default_policy['versioning'] = settings.BACKEND_VERSIONING
backend = connect_backend(db_module=BACKEND_DB_MODULE,
db_connection=BACKEND_DB_CONNECTION,
block_module=BACKEND_BLOCK_MODULE,
block_path=BACKEND_BLOCK_PATH)
backend.default_policy['quota'] = BACKEND_QUOTA
backend.default_policy['versioning'] = BACKEND_VERSIONING
return backend
def get_quota(user):
......
......@@ -38,11 +38,11 @@ from time import asctime
from datetime import datetime, timedelta
from base64 import b64encode
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User, UserManager
from astakos.im.interface import get_quota, set_quota
from astakos.im.settings import DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, AUTH_TOKEN_DURATION
class AstakosUser(User):
"""
......@@ -55,9 +55,9 @@ class AstakosUser(User):
provider = models.CharField('Provider', max_length=255, blank=True)
#for invitations
user_level = settings.DEFAULT_USER_LEVEL
user_level = DEFAULT_USER_LEVEL
level = models.IntegerField('Inviter level', default=user_level)
invitations = models.IntegerField('Invitations left', default=settings.INVITATIONS_PER_LEVEL[user_level])
invitations = models.IntegerField('Invitations left', default=INVITATIONS_PER_LEVEL[user_level])
auth_token = models.CharField('Authentication Token', max_length=32,
null=True, blank=True)
......@@ -124,7 +124,7 @@ class AstakosUser(User):
self.auth_token = b64encode(md5.digest())
self.auth_token_created = datetime.now()
self.auth_token_expires = self.auth_token_created + \
timedelta(hours=settings.AUTH_TOKEN_DURATION)
timedelta(hours=AUTH_TOKEN_DURATION)
def __unicode__(self):
return self.username
......
from django.conf import settings
from os.path import abspath, dirname, join
PROJECT_PATH = getattr(settings, 'PROJECT_PATH', dirname(dirname(abspath(__file__))))
# Set the expiration time of newly created auth tokens
# to be this many hours after their creation time.
AUTH_TOKEN_DURATION = getattr(settings, 'ASTAKOS_AUTH_TOKEN_DURATION', 30 * 24)
# Bypass authentication for user administration.
BYPASS_ADMIN_AUTH = getattr(settings, 'ASTAKOS_BYPASS_ADMIN_AUTH', False)
# Show these many users per page in admin interface.
ADMIN_PAGE_LIMIT = getattr(settings, 'ASTAKOS_ADMIN_PAGE_LIMIT', 100)
# Authenticate via Twitter.
TWITTER_KEY = getattr(settings, 'ASTAKOS_TWITTER_KEY', '')
TWITTER_SECRET = getattr(settings, 'ASTAKOS_TWITTER_SECRET', '')
DEFAULT_USER_LEVEL = getattr(settings, 'ASTAKOS_DEFAULT_USER_LEVEL', 4)
INVITATIONS_PER_LEVEL = getattr(settings, 'ASTAKOS_INVITATIONS_PER_LEVEL', {
0 : 100,
1 : 2,
2 : 0,
3 : 0,
4 : 0
})
# Address to use for outgoing emails
DEFAULT_FROM_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_FROM_EMAIL', '%s <no-reply@grnet.gr>')
DEFAULT_CONTACT_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_CONTACT_EMAIL', 'support@%s.grnet.gr')
# Identity Management enabled modules
IM_MODULES = getattr(settings, 'ASTAKOS_IM_MODULES', ['local', 'twitter', 'shibboleth'])
# Force user profile verification
FORCE_PROFILE_UPDATE = getattr(settings, 'ASTAKOS_FORCE_PROFILE_UPDATE', True)
#Enable invitations
INVITATIONS_ENABLED = getattr(settings, 'ASTAKOS_INVITATIONS_ENABLED', True)
# The URL where requests are redirected for login, especially when using the login_required() decorator.
LOGIN_URL = getattr(settings, 'ASTAKOS_LOGIN_URL', '/im')
COOKIE_NAME = getattr(settings, 'ASTAKOS_COOKIE_NAME', '_pithos2_a')
COOKIE_DOMAIN = getattr(settings, 'ASTAKOS_COOKIE_DOMAIN', None)
IM_MEDIA_URL = getattr(settings, 'ASTAKOS_IM_MEDIA_URL', '/im/static/im/')
# SQLAlchemy (choose SQLite/MySQL/PostgreSQL).
BACKEND_DB_MODULE = getattr(settings, 'PITHOS_BACKEND_DB_MODULE', 'pithos.backends.lib.sqlalchemy')
BACKEND_DB_CONNECTION = getattr(settings, 'PITHOS_BACKEND_DB_CONNECTION', 'sqlite:///' + join(PROJECT_PATH, 'backend.db'))
# Block storage.
BACKEND_BLOCK_MODULE = getattr(settings, 'PITHOS_BACKEND_BLOCK_MODULE', 'pithos.backends.lib.hashfiler')
BACKEND_BLOCK_PATH = getattr(settings, 'PITHOS_BACKEND_BLOCK_PATH', join(PROJECT_PATH, 'data/'))
# Default setting for new accounts.
BACKEND_QUOTA = getattr(settings, 'PITHOS_BACKEND_QUOTA', 50 * 1024 * 1024 * 1024)
BACKEND_VERSIONING = getattr(settings, 'PITHOS_BACKEND_VERSIONING', 'auto')
......@@ -36,7 +36,6 @@
import oauth2 as oauth
import urlparse
from django.conf import settings
from django.http import HttpResponse
from django.utils import simplejson as json
from django.contrib import messages
......@@ -47,10 +46,11 @@ from astakos.im.views import render_response, requires_anonymous
from astakos.im.forms import LocalUserCreationForm, ThirdPartyUserCreationForm
from astakos.im.faults import BadRequest
from astakos.im.backends import get_backend
from astakos.im.settings import TWITTER_KEY, TWITTER_SECRET, INVITATIONS_ENABLED, IM_MODULES
# It's probably a good idea to put your consumer's OAuth token and
# OAuth secret into your project's settings.
consumer = oauth.Consumer(settings.TWITTER_KEY, settings.TWITTER_SECRET)
consumer = oauth.Consumer(TWITTER_KEY, TWITTER_SECRET)
client = oauth.Client(consumer)
request_token_url = 'http://twitter.com/oauth/request_token'
......@@ -150,7 +150,7 @@ def authenticated(request, backend=None, login_template='im/login.html', on_sign
messages.add_message(request, messages.ERROR, message)
prefix = 'Invited' if request.session['invitation_code'] else ''
suffix = 'UserCreationForm'
for provider in settings.IM_MODULES:
for provider in IM_MODULES:
main = provider.capitalize() if provider == 'local' else 'ThirdParty'
formclass = '%s%s%s' % (prefix, main, suffix)
extra_context['%s_form' % provider] = globals()[formclass]()
......@@ -184,7 +184,7 @@ def create_user(request, form, backend=None, post_data={}, next = None, on_failu
The user activation will be delegated to the backend specified by the ``backend`` keyword argument
if present, otherwise to the ``astakos.im.backends.InvitationBackend``
if settings.INVITATIONS_ENABLED is True or ``astakos.im.backends.SimpleBackend`` if not
if settings.ASTAKOS_INVITATIONS_ENABLED is True or ``astakos.im.backends.SimpleBackend`` if not
(see backends);
Upon successful user creation if ``next`` url parameter is present the user is redirected there
......@@ -228,7 +228,7 @@ def create_user(request, form, backend=None, post_data={}, next = None, on_failu
messages.add_message(request, messages.ERROR, form.errors)
except (Invitation.DoesNotExist, ValueError), e:
messages.add_message(request, messages.ERROR, e)
for provider in settings.IM_MODULES:
for provider in IM_MODULES:
extra_context['%s_form' % provider] = backend.get_signup_form(provider)
return render_response(on_failure,
form = LocalUserCreationForm(),
......
......@@ -31,10 +31,10 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.conf import settings
from django.conf.urls.defaults import patterns, include, url
from astakos.im.forms import ExtendedPasswordResetForm
from astakos.im.settings import IM_MODULES, INVITATIONS_ENABLED, PROJECT_PATH
urlpatterns = patterns('astakos.im.views',
url(r'^$', 'index'),
......@@ -53,10 +53,10 @@ urlpatterns += patterns('astakos.im.target',
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.PROJECT_PATH + '/im/static'})
{'document_root': PROJECT_PATH + '/im/static'})
)
if 'local' in settings.IM_MODULES:
if 'local' in IM_MODULES:
urlpatterns += patterns('astakos.im.target',
url(r'^local/?$', 'local.login')
)
......@@ -71,17 +71,17 @@ if 'local' in settings.IM_MODULES:
url(r'^password/?$', 'password_change', {'post_change_redirect':'profile'})
)
if settings.INVITATIONS_ENABLED:
if INVITATIONS_ENABLED:
urlpatterns += patterns('astakos.im.views',
url(r'^invite/?$', 'invite'),
)
if 'shibboleth' in settings.IM_MODULES:
if 'shibboleth' in IM_MODULES:
urlpatterns += patterns('astakos.im.target',
url(r'^login/shibboleth/?$', 'shibboleth.login')
)
if 'twitter' in settings.IM_MODULES:
if 'twitter' in IM_MODULES:
urlpatterns += patterns('astakos.im.target',
url(r'^login/twitter/?$', 'twitter.login'),
url(r'^login/twitter/authenticated/?$', 'twitter.authenticated')
......
......@@ -40,7 +40,6 @@ from functools import wraps
from datetime import tzinfo, timedelta
from django.http import HttpResponse, urlencode
from django.conf import settings
from django.template import RequestContext
from django.contrib.sites.models import Site
from django.utils.translation import ugettext as _
......@@ -48,6 +47,7 @@ from django.contrib.auth import login, authenticate
from django.core.urlresolvers import reverse
from astakos.im.models import AstakosUser, Invitation
from astakos.im.settings import INVITATIONS_PER_LEVEL, COOKIE_NAME, COOKIE_DOMAIN, FORCE_PROFILE_UPDATE
class UTC(tzinfo):
def utcoffset(self, dt):
......@@ -73,7 +73,7 @@ def get_or_create_user(email, realname='', first_name='', last_name='', affiliat
'password':password,
'affiliation':affiliation,
'level':level,
'invitations':settings.INVITATIONS_PER_LEVEL[level],
'invitations':INVITATIONS_PER_LEVEL[level],
'provider':provider,
'realname':realname,
'first_name':first_name,
......@@ -141,7 +141,7 @@ def prepare_response(request, user, next='', renew=False):
user.renew_token()
user.save()
if settings.FORCE_PROFILE_UPDATE and not user.is_verified and not user.is_superuser:
if FORCE_PROFILE_UPDATE and not user.is_verified and not user.is_superuser:
params = ''
if next:
params = '?' + urlencode({'next': next})
......@@ -155,9 +155,9 @@ def prepare_response(request, user, next='', renew=False):
# set cookie
expire_fmt = user.auth_token_expires.strftime('%a, %d-%b-%Y %H:%M:%S %Z')
cookie_value = quote(user.email + '|' + user.auth_token)
response.set_cookie(settings.COOKIE_NAME, value=cookie_value,
response.set_cookie(COOKIE_NAME, value=cookie_value,
expires=expire_fmt, path='/',
domain = settings.COOKIE_DOMAIN)
domain = COOKIE_DOMAIN)
if not next:
next = reverse('astakos.im.views.index')
......
......@@ -39,7 +39,6 @@ from smtplib import SMTPException
from urllib import quote
from functools import wraps
from django.conf import settings
from django.core.mail import send_mail
from django.http import HttpResponse
from django.shortcuts import redirect
......@@ -57,6 +56,7 @@ from astakos.im.models import AstakosUser, Invitation
from astakos.im.backends import get_backend
from astakos.im.util import get_context, get_current_site, prepare_response
from astakos.im.forms import *
from astakos.im.settings import DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, COOKIE_NAME, IM_MODULES
def render_response(template, tab=None, status=200, context_instance=None, **kwargs):
"""
......@@ -137,8 +137,8 @@ def _send_invitation(request, baseurl, inv):
'url': url,
'baseurl': baseurl,
'service': sitename,
'support': settings.DEFAULT_CONTACT_EMAIL % sitename.lower()})
sender = settings.DEFAULT_FROM_EMAIL % sitename
'support': DEFAULT_CONTACT_EMAIL % sitename.lower()})
sender = DEFAULT_FROM_EMAIL % sitename
send_mail(subject, message, sender, [inv.username])
logging.info('Sent invitation %s', inv)
......@@ -155,7 +155,7 @@ def invite(request, template_name='im/invitations.html', extra_context={}):
The view uses commit_manually decorator in order to ensure the number of the
user invitations is going to be updated only if the email has been successfully sent.
If the user isn't logged in, redirects to settings.LOGIN_URL.
If the user isn't logged in, redirects to settings.ASTAKOS_LOGIN_URL.
**Arguments**
......@@ -230,7 +230,7 @@ def edit_profile(request, template_name='im/profile.html', extra_context={}):
In case of POST updates the user informantion and redirects to ``next``
url parameter if exists.
If the user isn't logged in, redirects to settings.LOGIN_URL.
If the user isn't logged in, redirects to settings.ASTAKOS_LOGIN_URL.
**Arguments**
......@@ -244,6 +244,12 @@ def edit_profile(request, template_name='im/profile.html', extra_context={}):
**Template:**
im/profile.html or ``template_name`` keyword argument.
**Settings:**
The view expectes the following settings are defined:
* LOGIN_URL: login uri
"""
form = ProfileForm(instance=request.user)
extra_context['next'] = request.GET.get('next')
......@@ -274,7 +280,7 @@ def signup(request, on_failure='im/signup.html', on_success='im/signup_complete.
The user activation will be delegated to the backend specified by the ``backend`` keyword argument
if present, otherwise to the ``astakos.im.backends.InvitationBackend``
if settings.INVITATIONS_ENABLED is True or ``astakos.im.backends.SimpleBackend`` if not
if settings.ASTAKOS_INVITATIONS_ENABLED is True or ``astakos.im.backends.SimpleBackend`` if not
(see backends);
Upon successful user creation if ``next`` url parameter is present the user is redirected there
......@@ -304,7 +310,7 @@ def signup(request, on_failure='im/signup.html', on_success='im/signup_complete.
try:
if not backend:
backend = get_backend(request)
for provider in settings.IM_MODULES:
for provider in IM_MODULES:
extra_context['%s_form' % provider] = backend.get_signup_form(provider)
if request.method == 'POST':
provider = request.POST.get('provider')
......@@ -326,7 +332,7 @@ def signup(request, on_failure='im/signup.html', on_success='im/signup_complete.
context_instance=get_context(request, extra_context))
except (Invitation.DoesNotExist, ValueError), e:
messages.add_message(request, messages.ERROR, e)
for provider in settings.IM_MODULES:
for provider in IM_MODULES:
main = provider.capitalize() if provider == 'local' else 'ThirdParty'
formclass = '%sUserCreationForm' % main
extra_context['%s_form' % provider] = globals()[formclass]()
......@@ -341,7 +347,7 @@ def send_feedback(request, template_name='im/feedback.html', email_template_name
In case of GET request renders a form for providing the feedback information.
In case of POST sends an email to support team.
If the user isn't logged in, redirects to settings.LOGIN_URL.
If the user isn't logged in, redirects to settings.ASTAKOS_LOGIN_URL.
**Arguments**
......@@ -358,6 +364,7 @@ def send_feedback(request, template_name='im/feedback.html', email_template_name
**Settings:**
* LOGIN_URL: login uri
* DEFAULT_CONTACT_EMAIL: List of feedback recipients
"""
if request.method == 'GET':
......@@ -371,7 +378,7 @@ def send_feedback(request, template_name='im/feedback.html', email_template_name
sitename, sitedomain = get_current_site(request, use_https=request.is_secure())
subject = _("Feedback from %s" % sitename)
from_email = request.user.email
recipient_list = [settings.DEFAULT_CONTACT_EMAIL % sitename.lower()]
recipient_list = [DEFAULT_CONTACT_EMAIL % sitename.lower()]
content = render_to_string(email_template_name, {
'message': form.cleaned_data['feedback_msg'],
'data': form.cleaned_data['feedback_data'],
......@@ -395,7 +402,7 @@ def logout(request, template='registration/logged_out.html', extra_context={}):
"""
auth_logout(request)
response = HttpResponse()
response.delete_cookie(settings.COOKIE_NAME)
response.delete_cookie(COOKIE_NAME)
next = request.GET.get('next')
if next:
response['Location'] = next
......
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'astakos.middleware.LoggingConfigMiddleware',
'astakos.middleware.SecureMiddleware'
)
ROOT_URLCONF = 'astakos.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'%s/im/admin/templates/' %PROJECT_PATH,
)
INSTALLED_APPS = (
'astakos.im',
'south',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.sessions'
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.messages.context_processors.messages',
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'astakos.im.context_processors.media',
'astakos.im.context_processors.im_modules',
'astakos.im.context_processors.next',
'astakos.im.context_processors.code',
'astakos.im.context_processors.invitations')
AUTHENTICATION_BACKENDS = ('astakos.im.auth_backends.EmailBackend',