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

employ new logging mechanism

parent c6187f4d
......@@ -39,6 +39,8 @@ from astakos.im.forms import LocalUserCreationForm
import logging
logger = logging.getLogger(__name__)
class AdminProfileForm(forms.ModelForm):
"""
Subclass of ``ModelForm`` for permiting user to edit his/her profile.
......@@ -95,5 +97,5 @@ class AdminUserCreationForm(LocalUserCreationForm):
user.renew_token()
if commit:
user.save()
logging.info('Created user %s', user)
logger.info('Created user %s', user)
return user
\ No newline at end of file
......@@ -56,6 +56,9 @@ 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
logger = logging.getLogger(__name__)
def requires_admin(func):
"""
Decorator checkes whether the request.user is a superuser and if not
......@@ -311,7 +314,7 @@ def _send_greeting(request, user, template_name):
'support': DEFAULT_CONTACT_EMAIL % sitename.lower()})
sender = DEFAULT_FROM_EMAIL % sitename
send_mail(subject, message, sender, [user.email])
logging.info('Sent greeting %s', user)
logger.info('Sent greeting %s', user)
@requires_admin
@transaction.commit_manually
......
......@@ -51,6 +51,8 @@ from astakos.im.settings import INVITATIONS_ENABLED, DEFAULT_CONTACT_EMAIL, DEFA
import socket
import logging
logger = logging.getLogger(__name__)
def get_backend(request):
"""
Returns an instance of a registration backend,
......@@ -251,4 +253,4 @@ def _send_verification(request, user, template_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)
logger.info('Sent activation %s', user)
......@@ -45,6 +45,8 @@ from astakos.im.settings import INVITATIONS_PER_LEVEL, DEFAULT_FROM_EMAIL
import logging
logger = logging.getLogger(__name__)
class LocalUserCreationForm(UserCreationForm):
"""
Extends the built in UserCreationForm in several ways:
......@@ -85,7 +87,7 @@ class LocalUserCreationForm(UserCreationForm):
user.renew_token()
if commit:
user.save()
logging.info('Created user %s', user)
logger.info('Created user %s', user)
return user
class InvitedLocalUserCreationForm(LocalUserCreationForm):
......@@ -175,7 +177,7 @@ class ThirdPartyUserCreationForm(ProfileForm):
user.renew_token()
if commit:
user.save()
logging.info('Created user %s', user)
logger.info('Created user %s', user)
return user
class InvitedThirdPartyUserCreationForm(ThirdPartyUserCreationForm):
......
......@@ -44,6 +44,10 @@ from urlparse import urlunsplit, urlsplit
from astakos.im.settings import COOKIE_NAME, COOKIE_DOMAIN
import logging
logger = logging.getLogger(__name__)
def login(request):
"""
If the request user is authenticated, redirects to `next` request parameter
......@@ -71,6 +75,7 @@ def login(request):
response.set_cookie(COOKIE_NAME, value=cookie_value,
expires=expire_fmt, path='/',
domain = COOKIE_DOMAIN)
logger.info('Token reset for %s' % request.user.email)
parts = list(urlsplit(next))
parts[3] = urlencode({'user': request.user.email, 'token': request.user.auth_token})
url = urlunsplit(parts)
......
......@@ -49,6 +49,8 @@ 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
logger = logging.getLogger(__name__)
class UTC(tzinfo):
def utcoffset(self, dt):
return timedelta(0)
......@@ -82,7 +84,7 @@ def get_or_create_user(email, realname='', first_name='', last_name='', affiliat
if created:
user.renew_token()
user.save()
logging.info('Created user %s', user)
logger.info('Created user %s', user)
return user
......
......@@ -58,6 +58,8 @@ 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
logger = logging.getLogger(__name__)
def render_response(template, tab=None, status=200, context_instance=None, **kwargs):
"""
Calls ``django.template.loader.render_to_string`` with an additional ``tab``
......@@ -140,7 +142,7 @@ def _send_invitation(request, baseurl, inv):
'support': DEFAULT_CONTACT_EMAIL % sitename.lower()})
sender = DEFAULT_FROM_EMAIL % sitename
send_mail(subject, message, sender, [inv.username])
logging.info('Sent invitation %s', inv)
logger.info('Sent invitation %s', inv)
@login_required
@transaction.commit_manually
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment