Commit bb720f75 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

astakos: unified settings handling

Import astakos settings module instead of importing specific settings
parent 76fa1f15
......@@ -46,8 +46,7 @@ from django.contrib.auth.models import User
from snf_django.lib import api
from astakos.im.models import Service
from astakos.im.settings import (INVITATIONS_ENABLED, QUOTAHOLDER_URL,
PROJECTS_VISIBLE)
from astakos.im import settings
import logging
logger = logging.getLogger(__name__)
......@@ -103,14 +102,14 @@ def get_menu(request, with_extra_links=False, with_signout=True):
name="Profile"))
if with_extra_links:
if INVITATIONS_ENABLED:
if settings.INVITATIONS_ENABLED:
append(item(url=absolute(request, reverse('invite')),
name="Invitations"))
append(item(url=absolute(request, reverse('resource_usage')),
name="Usage"))
if QUOTAHOLDER_URL and PROJECTS_VISIBLE:
if settings.PROJECTS_VISIBLE:
append(item(url=absolute(request, reverse('project_list')),
name="Projects"))
#append(item(
......
......@@ -34,7 +34,7 @@
from django.contrib.auth.backends import ModelBackend
from astakos.im.models import AstakosUser
from astakos.im.settings import LOGGING_LEVEL
from astakos.im import settings
import logging
......@@ -54,7 +54,7 @@ class TokenBackend(ModelBackend):
return None
else:
msg = 'Invalid token during authentication for %s' % email
logger._log(LOGGING_LEVEL, msg, [])
logger._log(settings.LOGGING_LEVEL, msg, [])
def get_user(self, user_id):
try:
......@@ -81,7 +81,7 @@ class EmailBackend(ModelBackend):
return user
else:
msg = 'Invalid password during authentication for %s' % username
logger._log(LOGGING_LEVEL, msg, [])
logger._log(settings.LOGGING_LEVEL, msg, [])
def get_user(self, user_id):
......
......@@ -31,11 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from astakos.im.settings import (
IM_MODULES, INVITATIONS_ENABLED, IM_STATIC_URL,
LOGIN_MESSAGES, SIGNUP_MESSAGES, PROFILE_MESSAGES,
GLOBAL_MESSAGES, PROFILE_EXTRA_LINKS,
)
from astakos.im import settings
from astakos.im import presentation
from astakos.api import get_menu
from astakos.im.util import get_query
......@@ -43,13 +39,19 @@ from astakos.im.auth_providers import PROVIDERS as AUTH_PROVIDERS
from django.utils import simplejson as json
GLOBAL_MESSAGES = settings.GLOBAL_MESSAGES
SIGNUP_MESSAGES = settings.SIGNUP_MESSAGES
LOGIN_MESSAGES = settings.LOGIN_MESSAGES
PROFILE_MESSAGES = settings.PROFILE_MESSAGES
PROFILE_EXTRA_LINKS = settings.PROFILE_EXTRA_LINKS
def im_modules(request):
return {'im_modules': IM_MODULES}
return {'im_modules': settings.IM_MODULES}
def auth_providers(request):
active_auth_providers = []
for module in IM_MODULES:
for module in settings.IM_MODULES:
provider = AUTH_PROVIDERS.get(module, None)
if provider:
active_auth_providers.append(provider(request.user))
......@@ -68,11 +70,11 @@ def last_login_method(request):
return {'last_login_method': request.COOKIES.get('astakos_last_login_method', None)}
def invitations(request):
return {'invitations_enabled': INVITATIONS_ENABLED}
return {'invitations_enabled': settings.INVITATIONS_ENABLED}
def media(request):
return {'IM_STATIC_URL': IM_STATIC_URL}
return {'IM_STATIC_URL': settings.IM_STATIC_URL}
def custom_messages(request):
......
......@@ -38,9 +38,7 @@ from urllib import quote, unquote
from django.contrib.auth.models import AnonymousUser
from django.utils.translation import ugettext as _
from astakos.im.settings import (
COOKIE_NAME, COOKIE_DOMAIN, COOKIE_SECURE, LOGGING_LEVEL, TRANSLATE_UUIDS)
from astakos.im import settings
import astakos.im.messages as astakos_messages
logger = logging.getLogger(__name__)
......@@ -49,7 +47,7 @@ logger = logging.getLogger(__name__)
class CookieHandler():
def __init__(self, request, response=None):
cookies = getattr(request, 'COOKIES', {})
cookie = unquote(cookies.get(COOKIE_NAME, ''))
cookie = unquote(cookies.get(settings.COOKIE_NAME, ''))
self.uuid, sep, self.auth_token = cookie.partition('|')
self.request = request
self.response = response
......@@ -69,7 +67,7 @@ class CookieHandler():
@property
def is_valid(self):
cookie_attribute = 'uuid' if not TRANSLATE_UUIDS else 'username'
cookie_attribute = 'uuid' if not settings.TRANSLATE_UUIDS else 'username'
return (self.uuid == getattr(self.user, cookie_attribute, '') and
self.auth_token == getattr(self.user, 'auth_token', ''))
......@@ -83,25 +81,25 @@ class CookieHandler():
user = self.user
expire_fmt = user.auth_token_expires.strftime(
'%a, %d-%b-%Y %H:%M:%S %Z')
if TRANSLATE_UUIDS:
if settings.TRANSLATE_UUIDS:
cookie_value = quote(user.username + '|' + user.auth_token)
else:
cookie_value = quote(user.uuid + '|' + user.auth_token)
self.response.set_cookie(
COOKIE_NAME, value=cookie_value, expires=expire_fmt, path='/',
domain=COOKIE_DOMAIN, secure=COOKIE_SECURE
settings.COOKIE_NAME, value=cookie_value, expires=expire_fmt, path='/',
domain=settings.COOKIE_DOMAIN, secure=settings.COOKIE_SECURE
)
msg = str(('Cookie [expiring %(auth_token_expires)s]',
'set for %(uuid)s')) % user.__dict__
logger._log(LOGGING_LEVEL, msg, [])
logger._log(settings.LOGGING_LEVEL, msg, [])
def __delete(self):
if not self.response:
raise ValueError(_(astakos_messages.NO_RESPONSE))
self.response.delete_cookie(
COOKIE_NAME, path='/', domain=COOKIE_DOMAIN)
settings.COOKIE_NAME, path='/', domain=settings.COOKIE_DOMAIN)
msg = 'Cookie deleted for %(uuid)s' % self.__dict__
logger._log(LOGGING_LEVEL, msg, [])
logger._log(settings.LOGGING_LEVEL, msg, [])
def fix(self, response=None):
self.response = response or self.response
......
......@@ -42,7 +42,6 @@ from django.contrib.auth.tokens import default_token_generator
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.utils.encoding import smart_str
from django.conf import settings
from django.db import transaction
from django.core import validators
from django.core.exceptions import PermissionDenied
......@@ -51,9 +50,6 @@ from synnefo_branding.utils import render_to_string
from synnefo.lib import join_urls
from astakos.im.models import AstakosUser, EmailChange, Invitation, Resource, \
PendingThirdPartyUser, get_latest_terms, ProjectApplication, Project
from astakos.im.settings import BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY, \
RECAPTCHA_ENABLED, CONTACT_EMAIL, PASSWORD_RESET_EMAIL_SUBJECT, \
NEWPASSWD_INVALIDATE_TOKEN, EMAILCHANGE_ENABLED
from astakos.im import presentation
from astakos.im.widgets import DummyWidget, RecaptchaWidget
from astakos.im.functions import send_change_email, submit_application, \
......@@ -61,6 +57,7 @@ from astakos.im.functions import send_change_email, submit_application, \
from astakos.im.util import reserved_verified_email, model_to_dict
from astakos.im import auth_providers
from astakos.im import settings
import astakos.im.messages as astakos_messages
......@@ -132,7 +129,7 @@ class LocalUserCreationForm(UserCreationForm, StoreUserMixin):
self.fields.keyOrder = ['email', 'first_name', 'last_name',
'password1', 'password2']
if RECAPTCHA_ENABLED:
if settings.RECAPTCHA_ENABLED:
self.fields.keyOrder.extend(['recaptcha_challenge_field',
'recaptcha_response_field', ])
if get_latest_terms():
......@@ -173,9 +170,11 @@ class LocalUserCreationForm(UserCreationForm, StoreUserMixin):
def validate_captcha(self):
rcf = self.cleaned_data['recaptcha_challenge_field']
rrf = self.cleaned_data['recaptcha_response_field']
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip)
check = captcha.submit(
rcf, rrf, settings.RECAPTCHA_PRIVATE_KEY, self.ip)
if not check.is_valid:
raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR))
raise forms.ValidationError(_(
astakos_messages.CAPTCHA_VALIDATION_ERR))
def post_store_user(self, user, request=None):
"""
......@@ -370,7 +369,7 @@ class LoginForm(AuthenticationForm):
super(LoginForm, self).__init__(*args, **kwargs)
self.fields.keyOrder = ['username', 'password']
if was_limited and RECAPTCHA_ENABLED:
if was_limited and settings.RECAPTCHA_ENABLED:
self.fields.keyOrder.extend(['recaptcha_challenge_field',
'recaptcha_response_field', ])
......@@ -390,9 +389,11 @@ class LoginForm(AuthenticationForm):
def validate_captcha(self):
rcf = self.cleaned_data['recaptcha_challenge_field']
rrf = self.cleaned_data['recaptcha_response_field']
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip)
check = captcha.submit(
rcf, rrf, settings.RECAPTCHA_PRIVATE_KEY, self.ip)
if not check.is_valid:
raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR))
raise forms.ValidationError(_(
astakos_messages.CAPTCHA_VALIDATION_ERR))
def clean(self):
"""
......@@ -535,18 +536,18 @@ class ExtendedPasswordResetForm(PasswordResetForm):
"""
for user in self.users_cache:
url = user.astakosuser.get_password_reset_url(token_generator)
url = join_urls(BASEURL, url)
url = join_urls(settings.BASEURL, url)
c = {
'email': user.email,
'url': url,
'site_name': SITENAME,
'site_name': settings.SITENAME,
'user': user,
'baseurl': BASEURL,
'support': CONTACT_EMAIL
'baseurl': settings.BASEURL,
'support': settings.CONTACT_EMAIL
}
message = render_to_string(email_template_name, c)
from_email = settings.SERVER_EMAIL
send_mail(_(PASSWORD_RESET_EMAIL_SUBJECT),
send_mail(_(settings.PASSWORD_RESET_EMAIL_SUBJECT),
message,
from_email,
[user.email],
......@@ -628,7 +629,7 @@ class ExtendedPasswordChangeForm(PasswordChangeForm):
Extends PasswordChangeForm by enabling user
to optionally renew also the token.
"""
if not NEWPASSWD_INVALIDATE_TOKEN:
if not settings.NEWPASSWD_INVALIDATE_TOKEN:
renew = forms.BooleanField(label='Renew token', required=False,
initial=True,
help_text='Unsetting this may result in security risk.')
......@@ -639,7 +640,8 @@ class ExtendedPasswordChangeForm(PasswordChangeForm):
def save(self, commit=True):
try:
if NEWPASSWD_INVALIDATE_TOKEN or self.cleaned_data.get('renew'):
if settings.NEWPASSWD_INVALIDATE_TOKEN or \
self.cleaned_data.get('renew'):
self.user.renew_token()
self.user.flush_sessions(current_key=self.session_key)
except AttributeError:
......@@ -652,7 +654,7 @@ class ExtendedSetPasswordForm(SetPasswordForm):
Extends SetPasswordForm by enabling user
to optionally renew also the token.
"""
if not NEWPASSWD_INVALIDATE_TOKEN:
if not settings.NEWPASSWD_INVALIDATE_TOKEN:
renew = forms.BooleanField(
label='Renew token',
required=False,
......@@ -666,7 +668,8 @@ class ExtendedSetPasswordForm(SetPasswordForm):
def save(self, commit=True):
try:
self.user = AstakosUser.objects.get(id=self.user.id)
if NEWPASSWD_INVALIDATE_TOKEN or self.cleaned_data.get('renew'):
if settings.NEWPASSWD_INVALIDATE_TOKEN or \
self.cleaned_data.get('renew'):
self.user.renew_token()
provider = auth_providers.get_provider('local', self.user)
......@@ -1038,7 +1041,7 @@ class ExtendedProfileForm(ProfileForm):
self.fields_list.remove('change_password')
del self.fields['change_password']
if EMAILCHANGE_ENABLED and self.instance.can_change_email():
if settings.EMAILCHANGE_ENABLED and self.instance.can_change_email():
self.email_change = True
else:
self.fields_list.remove('new_email_address')
......
......@@ -36,9 +36,7 @@ import logging
from django.utils.translation import ugettext as _
from django.core.mail import send_mail, get_connection
from django.core.urlresolvers import reverse
from django.contrib.auth import (
login as auth_login,
logout as auth_logout)
from django.contrib.auth import login as auth_login, logout as auth_logout
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.http import Http404
......@@ -46,27 +44,18 @@ from django.http import Http404
from synnefo_branding.utils import render_to_string
from synnefo.lib import join_urls
from astakos.im.settings import (
CONTACT_EMAIL, SITENAME, BASEURL, LOGGING_LEVEL,
VERIFICATION_EMAIL_SUBJECT, ACCOUNT_CREATION_SUBJECT,
HELPDESK_NOTIFICATION_EMAIL_SUBJECT,
INVITATION_EMAIL_SUBJECT, GREETING_EMAIL_SUBJECT, FEEDBACK_EMAIL_SUBJECT,
EMAIL_CHANGE_EMAIL_SUBJECT,
)
from astakos.im.models import (
AstakosUser, Invitation, ProjectMembership, ProjectApplication, Project,
Chain, new_chain)
from astakos.im.quotas import (qh_sync_user, get_pending_app_quota,
register_pending_apps, qh_sync_project,
qh_sync_locked_users, get_users_for_update,
members_to_sync)
from astakos.im.project_notif import (
membership_change_notify, membership_enroll_notify,
membership_request_notify, membership_leave_request_notify,
application_submit_notify, application_approve_notify,
application_deny_notify,
project_termination_notify, project_suspension_notify)
from astakos.im.models import AstakosUser, Invitation, ProjectMembership, \
ProjectApplication, Project, Chain, new_chain
from astakos.im.quotas import qh_sync_user, get_pending_app_quota, \
register_pending_apps, qh_sync_project, qh_sync_locked_users, \
get_users_for_update, members_to_sync
from astakos.im.project_notif import membership_change_notify, \
membership_enroll_notify, membership_request_notify, \
membership_leave_request_notify, application_submit_notify, \
application_approve_notify, application_deny_notify, \
project_termination_notify, project_suspension_notify
from astakos.im import settings
import astakos.im.messages as astakos_messages
logger = logging.getLogger(__name__)
......@@ -92,15 +81,15 @@ def send_verification(user, template_name='im/activation_email.txt'):
"""
Send email to user to verify his/her email and activate his/her account.
"""
url = join_urls(BASEURL, user.get_activation_url(nxt=reverse('index')))
url = join_urls(settings.BASEURL, user.get_activation_url(nxt=reverse('index')))
message = render_to_string(template_name, {
'user': user,
'url': url,
'baseurl': BASEURL,
'site_name': SITENAME,
'support': CONTACT_EMAIL})
'baseurl': settings.BASEURL,
'site_name': settings.SITENAME,
'support': settings.CONTACT_EMAIL})
sender = settings.SERVER_EMAIL
send_mail(_(VERIFICATION_EMAIL_SUBJECT), message, sender, [user.email],
send_mail(_(settings.VERIFICATION_EMAIL_SUBJECT), message, sender, [user.email],
connection=get_connection())
logger.info("Sent user verirfication email: %s", user.log_display)
......@@ -131,7 +120,7 @@ def _send_admin_notification(template_name,
else:
msg = 'Sent admin notification (%s)' % msg
logger.log(LOGGING_LEVEL, msg)
logger.log(settings.LOGGING_LEVEL, msg)
def send_account_pending_moderation_notification(
......@@ -141,7 +130,7 @@ def send_account_pending_moderation_notification(
Notify admins that a new user has verified his email address and moderation
step is required to activate his account.
"""
subject = _(ACCOUNT_CREATION_SUBJECT) % {'user': user.email}
subject = _(settings.ACCOUNT_CREATION_SUBJECT) % {'user': user.email}
return _send_admin_notification(template_name, {}, subject=subject,
user=user, msg="account creation")
......@@ -160,29 +149,29 @@ def send_account_activated_notification(
sender = settings.SERVER_EMAIL
recipient_list = [e[1] for e in settings.HELPDESK +
settings.MANAGERS + settings.ADMINS]
send_mail(_(HELPDESK_NOTIFICATION_EMAIL_SUBJECT) % {'user': user.email},
send_mail(_(settings.HELPDESK_NOTIFICATION_EMAIL_SUBJECT) % {'user': user.email},
message, sender, recipient_list, connection=get_connection())
msg = 'Sent helpdesk admin notification for %s' % user.email
logger.log(LOGGING_LEVEL, msg)
logger.log(settings.LOGGING_LEVEL, msg)
def send_invitation(invitation, template_name='im/invitation.txt'):
"""
Send invitation email.
"""
subject = _(INVITATION_EMAIL_SUBJECT)
url = '%s?code=%d' % (join_urls(BASEURL, reverse('index')), invitation.code)
subject = _(settings.INVITATION_EMAIL_SUBJECT)
url = '%s?code=%d' % (join_urls(settings.BASEURL, reverse('index')), invitation.code)
message = render_to_string(template_name, {
'invitation': invitation,
'url': url,
'baseurl': BASEURL,
'site_name': SITENAME,
'support': CONTACT_EMAIL})
'baseurl': settings.BASEURL,
'site_name': settings.SITENAME,
'support': settings.CONTACT_EMAIL})
sender = settings.SERVER_EMAIL
send_mail(subject, message, sender, [invitation.username],
connection=get_connection())
msg = 'Sent invitation %s' % invitation
logger.log(LOGGING_LEVEL, msg)
logger.log(settings.LOGGING_LEVEL, msg)
inviter_invitations = invitation.inviter.invitations
invitation.inviter.invitations = max(0, inviter_invitations - 1)
invitation.inviter.save()
......@@ -194,22 +183,22 @@ def send_greeting(user, email_template_name='im/welcome_email.txt'):
Raises SMTPException, socket.error
"""
subject = _(GREETING_EMAIL_SUBJECT)
subject = _(settings.GREETING_EMAIL_SUBJECT)
message = render_to_string(email_template_name, {
'user': user,
'url': join_urls(BASEURL, reverse('index')),
'baseurl': BASEURL,
'site_name': SITENAME,
'support': CONTACT_EMAIL})
'url': join_urls(settings.BASEURL, reverse('index')),
'baseurl': settings.BASEURL,
'site_name': settings.SITENAME,
'support': settings.CONTACT_EMAIL})
sender = settings.SERVER_EMAIL
send_mail(subject, message, sender, [user.email],
connection=get_connection())
msg = 'Sent greeting %s' % user.log_display
logger.log(LOGGING_LEVEL, msg)
logger.log(settings.LOGGING_LEVEL, msg)
def send_feedback(msg, data, user, email_template_name='im/feedback_mail.txt'):
subject = _(FEEDBACK_EMAIL_SUBJECT)
subject = _(settings.FEEDBACK_EMAIL_SUBJECT)
from_email = settings.SERVER_EMAIL
recipient_list = [e[1] for e in settings.HELPDESK]
content = render_to_string(email_template_name, {
......@@ -219,21 +208,21 @@ def send_feedback(msg, data, user, email_template_name='im/feedback_mail.txt'):
send_mail(subject, content, from_email, recipient_list,
connection=get_connection())
msg = 'Sent feedback from %s' % user.log_display
logger.log(LOGGING_LEVEL, msg)
logger.log(settings.LOGGING_LEVEL, msg)
def send_change_email(
ec, request, email_template_name='registration/email_change_email.txt'):
url = ec.get_url()
url = request.build_absolute_uri(url)
c = {'url': url, 'site_name': SITENAME, 'support': CONTACT_EMAIL,
c = {'url': url, 'site_name': settings.SITENAME, 'support': settings.CONTACT_EMAIL,
'ec': ec}
message = render_to_string(email_template_name, c)
from_email = settings.SERVER_EMAIL
send_mail(_(EMAIL_CHANGE_EMAIL_SUBJECT), message, from_email,
send_mail(_(settings.EMAIL_CHANGE_EMAIL_SUBJECT), message, from_email,
[ec.new_email_address], connection=get_connection())
msg = 'Sent change email for %s' % ec.user.log_display
logger.log(LOGGING_LEVEL, msg)
logger.log(settings.LOGGING_LEVEL, msg)
def invite(inviter, email, realname):
......
......@@ -39,7 +39,7 @@ from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import Group
from django.core.exceptions import ValidationError
from astakos.im.models import AstakosUser
from astakos.im.models import AstakosUser, Resource
from astakos.im import quotas
from astakos.im import activation_backends
from ._common import remove_user_permission, add_user_permission, is_uuid
......
......@@ -60,8 +60,6 @@ from django.utils.safestring import mark_safe
from synnefo.lib.utils import dict_merge
from astakos.im.settings import DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, \
AUTH_TOKEN_DURATION, EMAILCHANGE_ACTIVATION_DAYS, LOGGING_LEVEL
from astakos.im import settings as astakos_settings
from astakos.im import auth_providers as auth
......@@ -320,10 +318,10 @@ class AstakosUser(User):
null=True)
#for invitations
user_level = DEFAULT_USER_LEVEL
user_level = astakos_settings.DEFAULT_USER_LEVEL
level = models.IntegerField(_('Inviter level'), default=user_level)
invitations = models.IntegerField(
_('Invitations left'), default=INVITATIONS_PER_LEVEL.get(user_level, 0))
_('Invitations left'), default=astakos_settings.INVITATIONS_PER_LEVEL.get(user_level, 0))
auth_token = models.CharField(_('Authentication Token'),
max_length=32,
......@@ -510,11 +508,11 @@ 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=AUTH_TOKEN_DURATION)
timedelta(hours=astakos_settings.AUTH_TOKEN_DURATION)
if flush_sessions:
self.flush_sessions(current_key)
msg = 'Token renewed for %s' % self.log_display
logger.log(LOGGING_LEVEL, msg)
logger.log(astakos_settings.LOGGING_LEVEL, msg)
def flush_sessions(self, current_key=None):
q = self.sessions
......@@ -524,7 +522,7 @@ class AstakosUser(User):
keys = q.values_list('session_key', flat=True)
if keys:
msg = 'Flushing sessions: %s' % ','.join(keys)
logger.log(LOGGING_LEVEL, msg, [])
logger.log(astakos_settings.LOGGING_LEVEL, msg, [])
engine = import_module(settings.SESSION_ENGINE)
for k in keys:
s = engine.SessionStore(k)
......@@ -592,7 +590,7 @@ class AstakosUser(User):
"""
level = self.invitation.inviter.level + 1
self.level = level
self.invitations = INVITATIONS_PER_LEVEL.get(level, 0)
self.invitations = astakos_settings.INVITATIONS_PER_LEVEL.get(level, 0)
def can_change_password(self):
return self.has_auth_provider('local', auth_backend='astakos')
......@@ -1075,7 +1073,7 @@ class EmailChangeManager(models.Manager):
msg = "User %s changed email from %s to %s" % (user.log_display,
old_email,
user.email)
logger.log(LOGGING_LEVEL, msg)
logger.log(astakos_settings.LOGGING_LEVEL, msg)
return user
except EmailChange.DoesNotExist:
raise ValueError(_('Invalid activation key.'))
......@@ -1100,7 +1098,7 @@ class EmailChange(models.Model):
kwargs={'activation_key': self.activation_key})
def activation_key_expired(self):
expiration_date = timedelta(days=EMAILCHANGE_ACTIVATION_DAYS)
expiration_date = timedelta(days=astakos_settings.EMAILCHANGE_ACTIVATION_DAYS)
return self.requested_at + expiration_date < datetime.now()
......
import logging
from django.utils.translation import ugettext as _
import astakos.im.settings as settings
from astakos.im import settings
from astakos.im.notifications import build_notification, NotificationError
logger = logging.getLogger(__name__)
......
......@@ -21,6 +21,8 @@ HELPDESK = getattr(settings, 'HELPDESK', ADMINS)
CONTACT_EMAIL = settings.CONTACT_EMAIL
SERVER_EMAIL = settings.SERVER_EMAIL
SECRET_KEY = settings.SECRET_KEY
SESSION_ENGINE = settings.SESSION_ENGINE
# Identity Management enabled modules
# Supported modules are: 'local', 'twitter' and 'shibboleth'
......
......@@ -130,7 +130,7 @@ def paginate(l, args):
default = datetime.datetime.utcfromtimestamp(0)
l.sort(key=lambda i: getattr(i, sorting)
if getattr(i, sorting) else default)
paginator = Paginator(l, PAGINATE_BY)
paginator = Paginator(l, settings.PAGINATE_BY)
try:
paginator.len
except AttributeError:
......
......@@ -62,10 +62,8 @@ from astakos.im.forms import LoginForm, InvitationForm, FeedbackForm, \
from astakos.im.forms import ExtendedProfileForm as ProfileForm
from astakos.im.functions import send_feedback, logout as auth_logout, \
invite as invite_func
from astakos.im.settings import COOKIE_DOMAIN, LOGOUT_NEXT, \
ACTIVATION_REDIRECT_URL
from astakos.im import presentation